| /* |
| * Copyright 2016-present Open Networking Foundation |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| /** |
| * This class defines the cli command for the PatchPanel class. It creates |
| * an instance of the PatchPanelService class to call it's method addPatch(). |
| * The command takes 2 parameters, 2 connectPoints. |
| */ |
| package org.onosproject.patchpanel.cli; |
| |
| import org.apache.karaf.shell.commands.Argument; |
| import org.apache.karaf.shell.commands.Command; |
| import org.onosproject.cli.AbstractShellCommand; |
| import org.onosproject.patchpanel.impl.PatchId; |
| import org.onosproject.patchpanel.impl.PatchPanelService; |
| |
| /** |
| * Removes a patch. |
| */ |
| @Command(scope = "onos", name = "patch-remove", |
| description = "Removes a patch") |
| public class PatchRemoveCommand extends AbstractShellCommand { |
| |
| @Argument(index = 0, name = "patchId", description = "ID of patch to remove", |
| required = true, multiValued = false) |
| String id = null; |
| |
| private PatchPanelService patchPanelService; |
| |
| @Override |
| protected void execute() { |
| patchPanelService = get(PatchPanelService.class); |
| boolean done = false; |
| |
| PatchId patchId = PatchId.patchId(Integer.parseInt(id)); |
| |
| done = patchPanelService.removePatch(patchId); |
| |
| if (done) { |
| log.info("This patch has been removed"); |
| } else { |
| log.info("This patch was NOT removed"); |
| } |
| |
| } |
| |
| } |