blob: 7645f1d7f09d8702d2214838505b3fc67745ea79 [file] [log] [blame]
Jonathan Hart0bdf8372015-10-08 14:30:36 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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
Ray Milkeyd84f89b2018-08-17 14:54:17 -070019import org.apache.karaf.shell.api.action.Argument;
20import org.apache.karaf.shell.api.action.Command;
21import org.apache.karaf.shell.api.action.lifecycle.Service;
Jonathan Hart0bdf8372015-10-08 14:30:36 -070022import org.onosproject.cli.AbstractShellCommand;
Ray Milkeyfacf2862017-08-03 11:58:29 -070023import org.onosproject.net.intf.InterfaceAdminService;
Jonathan Hart0bdf8372015-10-08 14:30:36 -070024import org.onosproject.net.ConnectPoint;
25
26/**
27 * Removes an interface configuration.
28 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070029@Service
Andreas Pantelopoulosb6a2f782016-11-12 17:29:42 +010030@Command(scope = "onos", name = "interface-remove",
Jonathan Hart0bdf8372015-10-08 14:30:36 -070031 description = "Removes a configured interface")
32public class InterfaceRemoveCommand extends AbstractShellCommand {
33
34 @Argument(index = 0, name = "connectPoint",
35 description = "Connect point of the interface",
36 required = true, multiValued = false)
37 private String connectPoint = null;
38
Jonathan Hart7dbe6292015-11-10 08:33:17 -080039 @Argument(index = 1, name = "name",
40 description = "Interface name",
Jonathan Hart0bdf8372015-10-08 14:30:36 -070041 required = true, multiValued = false)
Jonathan Hart7dbe6292015-11-10 08:33:17 -080042 private String name = null;
Jonathan Hart0bdf8372015-10-08 14:30:36 -070043
44 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070045 protected void doExecute() {
Jonathan Hart0bdf8372015-10-08 14:30:36 -070046 InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
47
Jonathan Hart7dbe6292015-11-10 08:33:17 -080048 boolean success = interfaceService.remove(
49 ConnectPoint.deviceConnectPoint(connectPoint), name);
50
51 if (success) {
52 print("Interface removed");
53 } else {
54 print("Unable to remove interface");
55 }
Jonathan Hart0bdf8372015-10-08 14:30:36 -070056 }
57
58}