blob: e4a167b919c7d64c39bbbcdd63293f24d7b57fb4 [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/**
25 * Command line interface for removing openstack vTap rule.
26 */
27@Command(scope = "onos", name = "openstack-vtap-del",
28 description = "OpenstackVtap deactivate")
29public 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 {
Ray Milkey0354b452018-07-06 09:20:12 -070043 print("Failed to remove OpenstackVtap with id { %s }", vTapId);
Jian Lic2538102018-07-03 22:42:07 +090044 }
45 }
46}