Jian Li | c253810 | 2018-07-03 22:42:07 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | package org.onosproject.openstackvtap.cli; |
| 17 | import org.apache.karaf.shell.commands.Command; |
| 18 | import org.onosproject.cli.AbstractShellCommand; |
| 19 | import org.apache.karaf.shell.commands.Argument; |
| 20 | import org.onosproject.openstackvtap.api.OpenstackVtap; |
| 21 | import org.onosproject.openstackvtap.api.OpenstackVtapAdminService; |
| 22 | import org.onosproject.openstackvtap.api.OpenstackVtapId; |
| 23 | |
| 24 | /** |
| 25 | * Command line interface for removing openstack vTap rule. |
| 26 | */ |
| 27 | @Command(scope = "onos", name = "openstack-vtap-del", |
| 28 | description = "OpenstackVtap deactivate") |
| 29 | public class OpenstackVtapDeleteCommand extends AbstractShellCommand { |
| 30 | |
| 31 | private final OpenstackVtapAdminService vTapService = get(OpenstackVtapAdminService.class); |
| 32 | |
| 33 | @Argument(index = 0, name = "id", description = "vTap ID", |
| 34 | required = true, multiValued = false) |
| 35 | String vTapId = ""; |
| 36 | |
| 37 | @Override |
| 38 | protected void execute() { |
| 39 | OpenstackVtap vTap = vTapService.removeVtap(OpenstackVtapId.vTapId(vTapId)); |
| 40 | if (vTap != null) { |
| 41 | print("Removed OpenstackVtap with id { %s }", vTap.id().toString()); |
| 42 | } else { |
| 43 | print("Failed to remove OpenstackVtap with id { %s }", vTap.id().toString()); |
| 44 | } |
| 45 | } |
| 46 | } |