blob: 7fa3a13a6c32d3b8611aa33cbd9dcee2c14b3a6a [file] [log] [blame]
alshabibeff00542015-09-23 13:22:33 -07001/*
2 * Copyright 2014-2015 Open Networking Laboratory
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 */
16package org.onosproject.mfwd.cli;
17
18import org.apache.karaf.shell.commands.Command;
alshabibeff00542015-09-23 13:22:33 -070019
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000020import com.fasterxml.jackson.databind.node.ObjectNode;
21import com.fasterxml.jackson.databind.JsonNode;
22
23import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.mfwd.impl.McastRouteTable;
25import org.onosproject.mfwd.impl.MRibCodec;
alshabibeff00542015-09-23 13:22:33 -070026
27import org.slf4j.Logger;
alshabibeff00542015-09-23 13:22:33 -070028import static org.slf4j.LoggerFactory.getLogger;
29
30/**
31 * Displays the source, multicast group flows entries.
32 */
33@Command(scope = "onos", name = "mcast-show", description = "Displays the source, multicast group flows")
34public class McastShowCommand extends AbstractShellCommand {
35
36 private final Logger log = getLogger(getClass());
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000037 private static final String MCAST_GROUP = "mcastgroup";
alshabibeff00542015-09-23 13:22:33 -070038
39 @Override
40 protected void execute() {
41 McastRouteTable mrt = McastRouteTable.getInstance();
42 if (outputJson()) {
43 print("%s", json(mrt));
44 } else {
45 printMrib4(mrt);
46 }
47 }
48
49 public JsonNode json(McastRouteTable mrt) {
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000050 ObjectNode pushContent = new MRibCodec().encode(mrt , this);
51 return pushContent;
alshabibeff00542015-09-23 13:22:33 -070052 }
53
54 /**
55 * Displays multicast route table entries.
56 *
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000057 * @param mrt Mutlicast Route Table
alshabibeff00542015-09-23 13:22:33 -070058 */
59 protected void printMrib4(McastRouteTable mrt) {
60 print(mrt.printMcastRouteTable());
61 }
62}