alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jonathan Hart | 1d00639 | 2016-02-11 09:12:56 -0800 | [diff] [blame] | 16 | package org.onosproject.cli.net; |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 17 | |
| 18 | import org.apache.karaf.shell.commands.Command; |
Rusty Eddy | c0e3fea | 2015-09-28 21:20:41 +0000 | [diff] [blame] | 19 | import org.onosproject.cli.AbstractShellCommand; |
Jonathan Hart | 1d00639 | 2016-02-11 09:12:56 -0800 | [diff] [blame] | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.mcast.McastRoute; |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame] | 22 | import org.onosproject.net.mcast.MulticastRouteService; |
Jonathan Hart | 1d00639 | 2016-02-11 09:12:56 -0800 | [diff] [blame] | 23 | |
| 24 | import java.util.Set; |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Displays the source, multicast group flows entries. |
| 28 | */ |
| 29 | @Command(scope = "onos", name = "mcast-show", description = "Displays the source, multicast group flows") |
| 30 | public class McastShowCommand extends AbstractShellCommand { |
| 31 | |
Jonathan Hart | 1d00639 | 2016-02-11 09:12:56 -0800 | [diff] [blame] | 32 | private static final String FORMAT = "route=%s, source=%s, sinks=%s"; |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 33 | |
| 34 | @Override |
| 35 | protected void execute() { |
Jonathan Hart | 1d00639 | 2016-02-11 09:12:56 -0800 | [diff] [blame] | 36 | MulticastRouteService mcastService = get(MulticastRouteService.class); |
| 37 | |
| 38 | Set<McastRoute> routes = mcastService.getRoutes(); |
| 39 | |
| 40 | for (McastRoute route : routes) { |
| 41 | Set<ConnectPoint> sinks = mcastService.fetchSinks(route); |
| 42 | ConnectPoint source = mcastService.fetchSource(route); |
| 43 | |
| 44 | print(FORMAT, route, source, sinks); |
| 45 | } |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 46 | } |
| 47 | |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 48 | } |