blob: 6a9a23bb361e4020ff09a842ec08c92ddd3f8dc1 [file] [log] [blame]
Aaron Kruglikova2b59152015-06-24 14:01:41 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Aaron Kruglikova2b59152015-06-24 14:01:41 -07003 *
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.cli.net;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.edge.EdgePortService;
22
23import static org.onosproject.net.DeviceId.deviceId;
24
25/**
26 * Lists all edge ports.
27 */
28@Command(scope = "onos", name = "edge-ports",
29 description = "Lists all edge ports.")
30public class EdgePortsListCommand extends AbstractShellCommand {
31
32 private static final String FMT = "%s/%s";
33
34 @Argument(index = 0, name = "uri", description = "Device ID",
35 required = false, multiValued = false)
36 String uri = null;
37
38
39
40 @Override
41 protected void execute() {
42 EdgePortService service = get(EdgePortService.class);
43 if (uri == null) {
44 service.getEdgePoints().forEach(e -> print(FMT, e.deviceId(), e.port()));
45 } else {
46 service.getEdgePoints(deviceId(uri)).forEach(e -> print(FMT, e.deviceId(), e.port()));
47 }
48 }
49
50}