blob: c794c8005af2ea0213270e7088510e53297610fc [file] [log] [blame]
alshabibeff00542015-09-23 13:22:33 -07001/*
Rusty Eddyc0e3fea2015-09-28 21:20:41 +00002 * Copyright 2015 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 */
16package org.onosproject.mfwd.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
alshabibeff00542015-09-23 13:22:33 -070021import org.onosproject.mfwd.impl.McastRouteTable;
22
23/**
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000024 * Deletes a multicast route.
alshabibeff00542015-09-23 13:22:33 -070025 */
26@Command(scope = "onos", name = "mcast-delete",
27 description = "Delete a multicast route flow")
28public class McastDeleteCommand extends AbstractShellCommand {
29
30 @Argument(index = 0, name = "sAddr",
31 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
32 required = true, multiValued = false)
33 String sAddr = null;
34
35 @Argument(index = 1, name = "gAddr",
36 description = "IP Address of the multicast group",
37 required = true, multiValued = false)
38 String gAddr = null;
39
Julian Lawrence14c73182015-10-08 18:31:52 -070040 @Argument(index = 2, name = "egressList",
41 description = "Egress id/port",
42 required = false, multiValued = true)
43 String[] egressList = null;
44
45
alshabibeff00542015-09-23 13:22:33 -070046 @Override
47 protected void execute() {
Julian Lawrence14c73182015-10-08 18:31:52 -070048
49 boolean deleted = false;
alshabibeff00542015-09-23 13:22:33 -070050 McastRouteTable mrib = McastRouteTable.getInstance();
Julian Lawrence14c73182015-10-08 18:31:52 -070051
52 if (egressList == null) {
53 mrib.removeRoute(sAddr, gAddr);
54 deleted = true;
55 } else {
56 // check list for validity before we begin to delete.
57 for (String egress : egressList) {
58 deleted = mrib.removeEgress(sAddr, gAddr, egress);
59 }
60 }
61
62 if (deleted) {
63 print("Successful delete");
64 } else {
65 print("Failed to delete");
66 }
alshabibeff00542015-09-23 13:22:33 -070067 }
Julian Lawrence14c73182015-10-08 18:31:52 -070068}