blob: 429cd5010f76aa644d97a990a30839ea00e2f908 [file] [log] [blame]
Jonathan Hart194e7642016-12-15 15:33:34 -08001/*
2 * Copyright 2016-present Open Networking Laboratory
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 */
16
17/**
18 * This class defines the cli command for the PatchPanel class. It creates
19 * an instance of the PatchPanelService class to call it's method addPatch().
20 * The command takes 2 parameters, 2 connectPoints.
21 */
22package org.onosproject.patchpanel.cli;
23
24import org.apache.karaf.shell.commands.Argument;
25import org.apache.karaf.shell.commands.Command;
26import org.onosproject.cli.AbstractShellCommand;
27import org.onosproject.patchpanel.impl.PatchId;
28import org.onosproject.patchpanel.impl.PatchPanelService;
29
30/**
31 * Removes a patch.
32 */
33@Command(scope = "onos", name = "patch-remove",
34 description = "Removes a patch")
35public class PatchRemoveCommand extends AbstractShellCommand {
36
37 @Argument(index = 0, name = "patchId", description = "ID of patch to remove",
38 required = true, multiValued = false)
39 String id = null;
40
41 private PatchPanelService patchPanelService;
42
43 @Override
44 protected void execute() {
45 patchPanelService = get(PatchPanelService.class);
46 boolean done = false;
47
48 PatchId patchId = PatchId.patchId(Integer.parseInt(id));
49
50 done = patchPanelService.removePatch(patchId);
51
52 if (done) {
53 log.info("This patch has been removed");
54 } else {
55 log.info("This patch was NOT removed");
56 }
57
58 }
59
60}