blob: 36847438cfd15afd6cad085fbc51599cefe2518f [file] [log] [blame]
Jonathan Hartbfc5c482016-04-05 18:57:00 -07001/*
2 * Copyright 2016 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 */
16
17package org.onosproject.cli.net;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.packet.IpPrefix;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.incubator.net.routing.Route;
24import org.onosproject.incubator.net.routing.RouteAdminService;
25
26import java.util.Collections;
27
28/**
29 * Command to remove a route from the routing table.
30 */
31@Command(scope = "onos", name = "route-remove",
32 description = "Removes a route from the route table")
33public class RouteRemoveCommand extends AbstractShellCommand {
34
35 @Argument(index = 0, name = "prefix", description = "IP prefix of the route",
36 required = true)
37 String prefixString = null;
38
39 @Override
40 protected void execute() {
41 RouteAdminService service = AbstractShellCommand.get(RouteAdminService.class);
42
43 IpPrefix prefix = IpPrefix.valueOf(prefixString);
44
45 service.withdraw(Collections.singleton(new Route(Route.Source.STATIC, prefix, null)));
46 }
47
48}