blob: 5ef4dce9193e4c758790a102ede17fb7eaa5e1e1 [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
Julian Lawrencefa790f62016-01-07 17:18:30 -080018import org.apache.felix.scr.annotations.Reference;
19import org.apache.felix.scr.annotations.ReferenceCardinality;
alshabibeff00542015-09-23 13:22:33 -070020import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
Julian Lawrencefa790f62016-01-07 17:18:30 -080023import org.onosproject.mfwd.impl.McastForwarding;
24import org.onosproject.net.ConnectPoint;
25import org.onosproject.net.mcast.McastRoute;
26import org.onosproject.net.mcast.MulticastRouteService;
alshabibeff00542015-09-23 13:22:33 -070027
28/**
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000029 * Deletes a multicast route.
alshabibeff00542015-09-23 13:22:33 -070030 */
31@Command(scope = "onos", name = "mcast-delete",
32 description = "Delete a multicast route flow")
33public class McastDeleteCommand extends AbstractShellCommand {
34
Julian Lawrencefa790f62016-01-07 17:18:30 -080035 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class);
37
alshabibeff00542015-09-23 13:22:33 -070038 @Argument(index = 0, name = "sAddr",
39 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
40 required = true, multiValued = false)
41 String sAddr = null;
42
43 @Argument(index = 1, name = "gAddr",
44 description = "IP Address of the multicast group",
45 required = true, multiValued = false)
46 String gAddr = null;
47
Julian Lawrence14c73182015-10-08 18:31:52 -070048 @Argument(index = 2, name = "egressList",
49 description = "Egress id/port",
50 required = false, multiValued = true)
51 String[] egressList = null;
52
53
alshabibeff00542015-09-23 13:22:33 -070054 @Override
55 protected void execute() {
Julian Lawrence14c73182015-10-08 18:31:52 -070056
Julian Lawrencefa790f62016-01-07 17:18:30 -080057 McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr);
Julian Lawrence14c73182015-10-08 18:31:52 -070058
59 if (egressList == null) {
Julian Lawrencefa790f62016-01-07 17:18:30 -080060 mcastRouteManager.remove(mRoute);
Julian Lawrence14c73182015-10-08 18:31:52 -070061 } else {
62 // check list for validity before we begin to delete.
63 for (String egress : egressList) {
Julian Lawrencefa790f62016-01-07 17:18:30 -080064 ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress);
65 mcastRouteManager.removeSink(mRoute, eCp);
Julian Lawrence14c73182015-10-08 18:31:52 -070066 }
67 }
alshabibeff00542015-09-23 13:22:33 -070068 }
Julian Lawrence14c73182015-10-08 18:31:52 -070069}