blob: a5f06eed751c83573aee7d14e7e19a2cdf4f6b68 [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/**
26 * Command line interface for removing openstack vTap rule.
27 */
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
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 Milkey86ad7bb2018-09-27 12:32:28 -070040 protected void doExecute() {
Jian Lic2538102018-07-03 22:42:07 +090041 OpenstackVtap vTap = vTapService.removeVtap(OpenstackVtapId.vTapId(vTapId));
42 if (vTap != null) {
43 print("Removed OpenstackVtap with id { %s }", vTap.id().toString());
44 } else {
Ray Milkey0354b452018-07-06 09:20:12 -070045 print("Failed to remove OpenstackVtap with id { %s }", vTapId);
Jian Lic2538102018-07-03 22:42:07 +090046 }
47 }
48}