blob: 4992d7713028f6589863d79ecb5e52a37a6aa7d8 [file] [log] [blame]
Jonathan Hartbfc5c482016-04-05 18:57:00 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hartbfc5c482016-04-05 18:57:00 -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 */
16
17package org.onosproject.cli.net;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
Jonathan Hartfd176612016-04-11 10:42:10 -070021import org.onlab.packet.IpAddress;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070022import org.onlab.packet.IpPrefix;
23import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.incubator.net.routing.Route;
25import org.onosproject.incubator.net.routing.RouteAdminService;
26
27import java.util.Collections;
28
29/**
30 * Command to remove a route from the routing table.
31 */
32@Command(scope = "onos", name = "route-remove",
33 description = "Removes a route from the route table")
34public class RouteRemoveCommand extends AbstractShellCommand {
35
36 @Argument(index = 0, name = "prefix", description = "IP prefix of the route",
37 required = true)
38 String prefixString = null;
39
Jonathan Hartfd176612016-04-11 10:42:10 -070040 @Argument(index = 1, name = "prefix", description = "Next hop IP address",
41 required = true)
42 String nextHopString = null;
43
Jonathan Hartbfc5c482016-04-05 18:57:00 -070044 @Override
45 protected void execute() {
46 RouteAdminService service = AbstractShellCommand.get(RouteAdminService.class);
47
48 IpPrefix prefix = IpPrefix.valueOf(prefixString);
Jonathan Hartfd176612016-04-11 10:42:10 -070049 IpAddress nextHop = IpAddress.valueOf(nextHopString);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070050
Jonathan Hartfd176612016-04-11 10:42:10 -070051 service.withdraw(Collections.singleton(new Route(Route.Source.STATIC, prefix, nextHop)));
Jonathan Hartbfc5c482016-04-05 18:57:00 -070052 }
53
54}