Jonathan Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Jonathan Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.cli.net; |
| 18 | |
| 19 | import org.apache.karaf.shell.commands.Argument; |
| 20 | import org.apache.karaf.shell.commands.Command; |
Jonathan Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.incubator.net.intf.InterfaceAdminService; |
| 23 | import 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") |
| 30 | public 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 Hart | 7dbe629 | 2015-11-10 08:33:17 -0800 | [diff] [blame] | 37 | @Argument(index = 1, name = "name", |
| 38 | description = "Interface name", |
Jonathan Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 39 | required = true, multiValued = false) |
Jonathan Hart | 7dbe629 | 2015-11-10 08:33:17 -0800 | [diff] [blame] | 40 | private String name = null; |
Jonathan Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 41 | |
| 42 | @Override |
| 43 | protected void execute() { |
| 44 | InterfaceAdminService interfaceService = get(InterfaceAdminService.class); |
| 45 | |
Jonathan Hart | 7dbe629 | 2015-11-10 08:33:17 -0800 | [diff] [blame] | 46 | 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 Hart | 0bdf837 | 2015-10-08 14:30:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } |