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