Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | package org.onosproject.cli.net; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.net.edge.EdgePortService; |
| 22 | |
| 23 | import 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.") |
| 30 | public 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 | } |