blob: b3dd18d45f3a9cf666ee73d689ae5b3a014061c7 [file] [log] [blame]
tom6d2a43e2014-09-08 01:50:20 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Command;
4import org.onlab.onos.cli.AbstractShellCommand;
5import org.onlab.onos.net.Device;
6import org.onlab.onos.net.device.DeviceService;
7
8/**
9 * Lists all infrastructure devices.
10 */
11@Command(scope = "onos", name = "devices",
12 description = "Lists all infrastructure devices")
13public class DevicesListCommand extends AbstractShellCommand {
14
15 private static final String FMT =
16 "id=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s";
17
18 @Override
19 protected Object doExecute() throws Exception {
20 for (Device device : getService(DeviceService.class).getDevices()) {
21 print(FMT, device.id(), device.type(), device.manufacturer(),
22 device.hwVersion(), device.swVersion(), device.serialNumber());
23 }
24 return null;
25 }
26}