blob: 53c48887f4cf52096567f3c63eb776cd71e99248 [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.Argument;
19import org.apache.karaf.shell.commands.Command;
Jonathan Hart1d006392016-02-11 09:12:56 -080020import org.onlab.packet.IpAddress;
alshabibeff00542015-09-23 13:22:33 -070021import org.onosproject.cli.AbstractShellCommand;
Julian Lawrencefa790f62016-01-07 17:18:30 -080022import org.onosproject.net.ConnectPoint;
23import org.onosproject.net.mcast.McastRoute;
24import org.onosproject.net.mcast.MulticastRouteService;
alshabibeff00542015-09-23 13:22:33 -070025
26/**
Rusty Eddyc0e3fea2015-09-28 21:20:41 +000027 * Deletes a multicast route.
alshabibeff00542015-09-23 13:22:33 -070028 */
29@Command(scope = "onos", name = "mcast-delete",
30 description = "Delete a multicast route flow")
31public class McastDeleteCommand extends AbstractShellCommand {
32
33 @Argument(index = 0, name = "sAddr",
34 description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
35 required = true, multiValued = false)
36 String sAddr = null;
37
38 @Argument(index = 1, name = "gAddr",
39 description = "IP Address of the multicast group",
40 required = true, multiValued = false)
41 String gAddr = null;
42
Julian Lawrence14c73182015-10-08 18:31:52 -070043 @Argument(index = 2, name = "egressList",
44 description = "Egress id/port",
45 required = false, multiValued = true)
46 String[] egressList = null;
47
48
alshabibeff00542015-09-23 13:22:33 -070049 @Override
50 protected void execute() {
Jonathan Hart1d006392016-02-11 09:12:56 -080051 MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
Julian Lawrence14c73182015-10-08 18:31:52 -070052
Jonathan Hart1d006392016-02-11 09:12:56 -080053 McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr),
54 IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
Julian Lawrence14c73182015-10-08 18:31:52 -070055
56 if (egressList == null) {
Julian Lawrencefa790f62016-01-07 17:18:30 -080057 mcastRouteManager.remove(mRoute);
Julian Lawrence14c73182015-10-08 18:31:52 -070058 } else {
59 // check list for validity before we begin to delete.
60 for (String egress : egressList) {
Julian Lawrencefa790f62016-01-07 17:18:30 -080061 ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress);
62 mcastRouteManager.removeSink(mRoute, eCp);
Julian Lawrence14c73182015-10-08 18:31:52 -070063 }
64 }
alshabibeff00542015-09-23 13:22:33 -070065 }
Julian Lawrence14c73182015-10-08 18:31:52 -070066}