blob: 17db27cb02d7c49949a56696d726d2520407cd66 [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;
Jian Lidb521c12018-11-19 17:42:35 +090018import org.apache.karaf.shell.api.action.Completion;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070019import org.apache.karaf.shell.api.action.lifecycle.Service;
Jian Lic2538102018-07-03 22:42:07 +090020import org.onosproject.cli.AbstractShellCommand;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070021import org.apache.karaf.shell.api.action.Argument;
Jian Lic2538102018-07-03 22:42:07 +090022import org.onosproject.openstackvtap.api.OpenstackVtap;
23import org.onosproject.openstackvtap.api.OpenstackVtapAdminService;
24import org.onosproject.openstackvtap.api.OpenstackVtapId;
25
26/**
Jimo Jung14e87bf2018-09-03 16:28:13 +090027 * Delete a openstack vtap rule from the existing vtaps.
Jian Lic2538102018-07-03 22:42:07 +090028 */
Ray Milkey86ad7bb2018-09-27 12:32:28 -070029@Service
Jian Lic2538102018-07-03 22:42:07 +090030@Command(scope = "onos", name = "openstack-vtap-del",
31 description = "OpenstackVtap deactivate")
32public class OpenstackVtapDeleteCommand extends AbstractShellCommand {
33
Jimo Jung14e87bf2018-09-03 16:28:13 +090034 private final OpenstackVtapAdminService vtapService = get(OpenstackVtapAdminService.class);
Jian Lic2538102018-07-03 22:42:07 +090035
Jimo Jung14e87bf2018-09-03 16:28:13 +090036 @Argument(index = 0, name = "id", description = "vtap ID",
Jian Lic2538102018-07-03 22:42:07 +090037 required = true, multiValued = false)
Jian Lidb521c12018-11-19 17:42:35 +090038 @Completion(VtapIdCompleter.class)
Jimo Jung14e87bf2018-09-03 16:28:13 +090039 String vtapId = "";
Jian Lic2538102018-07-03 22:42:07 +090040
41 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070042 protected void doExecute() {
Jimo Jung14e87bf2018-09-03 16:28:13 +090043 OpenstackVtap vtap = vtapService.removeVtap(OpenstackVtapId.vtapId(vtapId));
44 if (vtap != null) {
45 print("Removed OpenstackVtap with id { %s }", vtap.id().toString());
Jian Lic2538102018-07-03 22:42:07 +090046 } else {
Jimo Jung14e87bf2018-09-03 16:28:13 +090047 print("Failed to remove OpenstackVtap with id { %s }", vtapId);
Jian Lic2538102018-07-03 22:42:07 +090048 }
49 }
50}