blob: e2d37f72c0cb42139ef62f2588d0309f63d7dc42 [file] [log] [blame]
Jian Lic2538102018-07-03 22:42:07 +09001/*
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 */
16package org.onosproject.openstackvtap.cli;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070017import org.apache.karaf.shell.api.action.Command;
18import org.apache.karaf.shell.api.action.lifecycle.Service;
Jian Lic2538102018-07-03 22:42:07 +090019import org.onosproject.cli.AbstractShellCommand;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070020import org.apache.karaf.shell.api.action.Argument;
Jian Lic2538102018-07-03 22:42:07 +090021import org.onosproject.openstackvtap.api.OpenstackVtap;
22import org.onosproject.openstackvtap.api.OpenstackVtapAdminService;
23import org.onosproject.openstackvtap.api.OpenstackVtapId;
24
25/**
Jimo Jung14e87bf2018-09-03 16:28:13 +090026 * Delete a openstack vtap rule from the existing vtaps.
Jian Lic2538102018-07-03 22:42:07 +090027 */
Ray Milkey86ad7bb2018-09-27 12:32:28 -070028@Service
Jian Lic2538102018-07-03 22:42:07 +090029@Command(scope = "onos", name = "openstack-vtap-del",
30 description = "OpenstackVtap deactivate")
31public class OpenstackVtapDeleteCommand extends AbstractShellCommand {
32
Jimo Jung14e87bf2018-09-03 16:28:13 +090033 private final OpenstackVtapAdminService vtapService = get(OpenstackVtapAdminService.class);
Jian Lic2538102018-07-03 22:42:07 +090034
Jimo Jung14e87bf2018-09-03 16:28:13 +090035 @Argument(index = 0, name = "id", description = "vtap ID",
Jian Lic2538102018-07-03 22:42:07 +090036 required = true, multiValued = false)
Jimo Jung14e87bf2018-09-03 16:28:13 +090037 String vtapId = "";
Jian Lic2538102018-07-03 22:42:07 +090038
39 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070040 protected void doExecute() {
Jimo Jung14e87bf2018-09-03 16:28:13 +090041 OpenstackVtap vtap = vtapService.removeVtap(OpenstackVtapId.vtapId(vtapId));
42 if (vtap != null) {
43 print("Removed OpenstackVtap with id { %s }", vtap.id().toString());
Jian Lic2538102018-07-03 22:42:07 +090044 } else {
Jimo Jung14e87bf2018-09-03 16:28:13 +090045 print("Failed to remove OpenstackVtap with id { %s }", vtapId);
Jian Lic2538102018-07-03 22:42:07 +090046 }
47 }
48}