blob: 2b9a56a8ec2b284d83f36633396a478f84319d18 [file] [log] [blame]
alshabibeff00542015-09-23 13:22:33 -07001/*
Jonathan Hart1d006392016-02-11 09:12:56 -08002 * Copyright 2016 Open Networking Laboratory
alshabibeff00542015-09-23 13:22:33 -07003 *
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 Hart1d006392016-02-11 09:12:56 -080016package org.onosproject.cli.net;
alshabibeff00542015-09-23 13:22:33 -070017
18import org.apache.karaf.shell.commands.Command;
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000019import org.onosproject.cli.AbstractShellCommand;
Jonathan Hart1d006392016-02-11 09:12:56 -080020import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.mcast.McastRoute;
Julian Lawrencefa790f62016-01-07 17:18:30 -080022import org.onosproject.net.mcast.MulticastRouteService;
Jonathan Hart1d006392016-02-11 09:12:56 -080023
24import java.util.Set;
alshabibeff00542015-09-23 13:22:33 -070025
26/**
27 * Displays the source, multicast group flows entries.
28 */
29@Command(scope = "onos", name = "mcast-show", description = "Displays the source, multicast group flows")
30public class McastShowCommand extends AbstractShellCommand {
31
Jonathan Hart1d006392016-02-11 09:12:56 -080032 private static final String FORMAT = "route=%s, source=%s, sinks=%s";
alshabibeff00542015-09-23 13:22:33 -070033
34 @Override
35 protected void execute() {
Jonathan Hart1d006392016-02-11 09:12:56 -080036 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 }
alshabibeff00542015-09-23 13:22:33 -070046 }
47
alshabibeff00542015-09-23 13:22:33 -070048}