blob: 61296a08529cd1303ed392622b380b780e4f3ef9 [file] [log] [blame]
Jonathan Hart0bdf8372015-10-08 14:30:36 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart0bdf8372015-10-08 14:30:36 -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 Hart0bdf8372015-10-08 14:30:36 -070021import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.incubator.net.intf.InterfaceAdminService;
23import org.onosproject.net.ConnectPoint;
24
25/**
26 * Removes an interface configuration.
27 */
28@Command(scope = "onos", name = "remove-interface",
29 description = "Removes a configured interface")
30public class InterfaceRemoveCommand extends AbstractShellCommand {
31
32 @Argument(index = 0, name = "connectPoint",
33 description = "Connect point of the interface",
34 required = true, multiValued = false)
35 private String connectPoint = null;
36
Jonathan Hart7dbe6292015-11-10 08:33:17 -080037 @Argument(index = 1, name = "name",
38 description = "Interface name",
Jonathan Hart0bdf8372015-10-08 14:30:36 -070039 required = true, multiValued = false)
Jonathan Hart7dbe6292015-11-10 08:33:17 -080040 private String name = null;
Jonathan Hart0bdf8372015-10-08 14:30:36 -070041
42 @Override
43 protected void execute() {
44 InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
45
Jonathan Hart7dbe6292015-11-10 08:33:17 -080046 boolean success = interfaceService.remove(
47 ConnectPoint.deviceConnectPoint(connectPoint), name);
48
49 if (success) {
50 print("Interface removed");
51 } else {
52 print("Unable to remove interface");
53 }
Jonathan Hart0bdf8372015-10-08 14:30:36 -070054 }
55
56}