blob: 9d8f088fa97ae9b4addfe109bd19aa1a43b39d42 [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.Command;
25import org.onosproject.cli.AbstractShellCommand;
26import org.onosproject.patchpanel.impl.Patch;
27import org.onosproject.patchpanel.impl.PatchPanelService;
28
29/**
30 * Lists the patches.
31 */
32@Command(scope = "onos", name = "patches",
33 description = "Lists the patches")
34public class PatchListCommand extends AbstractShellCommand {
35
36 private static final String FORMAT = "%s: %s <-> %s";
37
38 @Override
39 protected void execute() {
40 PatchPanelService patchPanelService = get(PatchPanelService.class);
41
42 patchPanelService.getPatches().forEach(this::print);
43 }
44
45 private void print(Patch patch) {
46 print(FORMAT, patch.id(), patch.port1(), patch.port2());
47 }
48
49}