blob: 18f13072e14b4d1021e4f6aabd273b97cc3bc339 [file] [log] [blame]
jiangruia0fc6052015-11-28 14:03:42 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jiangruia0fc6052015-11-28 14:03:42 +08003 *
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.vtnrsc.cli.routerinterface;
17
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.Option;
jiangruia0fc6052015-11-28 14:03:42 +080020import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.vtnrsc.RouterInterface;
22import org.onosproject.vtnrsc.SubnetId;
23import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
24
25/**
26 * Supports for remove a router interface.
27 */
28@Command(scope = "onos", name = "routerinterface-remove", description = "Supports for removing a router interface")
29public class RouterInterfaceRemoveCommand extends AbstractShellCommand {
30 @Option(name = "-s", aliases = "--subnetId", description = "The subnet identifier of router interface",
31 required = true, multiValued = false)
32 String subnetId = null;
33
34 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070035 protected void doExecute() {
jiangruia0fc6052015-11-28 14:03:42 +080036 RouterInterfaceService service = get(RouterInterfaceService.class);
37 try {
38 RouterInterface routerInterface = service
39 .getRouterInterface(SubnetId.subnetId(subnetId));
40 if (routerInterface == null) {
41 print(null, "subnet ID of interface doesn't exist");
42 return;
43 }
44 service.removeRouterInterface(routerInterface);
45 } catch (Exception e) {
46 print(null, e.getMessage());
47 }
48
49 }
50}