blob: e54f6ac48c5d27d71c77f10b3b23a1aa2df37e97 [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;
17import org.apache.karaf.shell.commands.Command;
18import org.onosproject.cli.AbstractShellCommand;
19import org.apache.karaf.shell.commands.Argument;
20import org.onosproject.openstackvtap.api.OpenstackVtap;
21import org.onosproject.openstackvtap.api.OpenstackVtapAdminService;
22import org.onosproject.openstackvtap.api.OpenstackVtapId;
23
24/**
Jimo Jung14e87bf2018-09-03 16:28:13 +090025 * Delete a openstack vtap rule from the existing vtaps.
Jian Lic2538102018-07-03 22:42:07 +090026 */
27@Command(scope = "onos", name = "openstack-vtap-del",
28 description = "OpenstackVtap deactivate")
29public class OpenstackVtapDeleteCommand extends AbstractShellCommand {
30
Jimo Jung14e87bf2018-09-03 16:28:13 +090031 private final OpenstackVtapAdminService vtapService = get(OpenstackVtapAdminService.class);
Jian Lic2538102018-07-03 22:42:07 +090032
Jimo Jung14e87bf2018-09-03 16:28:13 +090033 @Argument(index = 0, name = "id", description = "vtap ID",
Jian Lic2538102018-07-03 22:42:07 +090034 required = true, multiValued = false)
Jimo Jung14e87bf2018-09-03 16:28:13 +090035 String vtapId = "";
Jian Lic2538102018-07-03 22:42:07 +090036
37 @Override
38 protected void execute() {
Jimo Jung14e87bf2018-09-03 16:28:13 +090039 OpenstackVtap vtap = vtapService.removeVtap(OpenstackVtapId.vtapId(vtapId));
40 if (vtap != null) {
41 print("Removed OpenstackVtap with id { %s }", vtap.id().toString());
Jian Lic2538102018-07-03 22:42:07 +090042 } else {
Jimo Jung14e87bf2018-09-03 16:28:13 +090043 print("Failed to remove OpenstackVtap with id { %s }", vtapId);
Jian Lic2538102018-07-03 22:42:07 +090044 }
45 }
46}