blob: 836493575e3b0d928d141ddf9574fbe428824893 [file] [log] [blame]
tome33cc1a2014-08-25 21:59:41 -07001package org.onlab.onos.net.device;
2
3import org.onlab.onos.net.Device;
4import org.onlab.onos.net.DeviceId;
5import org.onlab.onos.net.MastershipRole;
tomb36046e2014-08-27 00:22:24 -07006import org.onlab.onos.net.Port;
7import org.onlab.onos.net.PortNumber;
8
9import java.util.List;
tome33cc1a2014-08-25 21:59:41 -070010
11/**
12 * Service for interacting with the inventory of infrastructure devices.
13 */
14public interface DeviceService {
15
16 /**
tomad2d2092014-09-06 23:24:20 -070017 * Returns the number of infrastructure devices known to the system.
tome33cc1a2014-08-25 21:59:41 -070018 *
tomad2d2092014-09-06 23:24:20 -070019 * @return number of infrastructure devices
tome33cc1a2014-08-25 21:59:41 -070020 */
tomad2d2092014-09-06 23:24:20 -070021 int getDeviceCount();
tome33cc1a2014-08-25 21:59:41 -070022
23 /**
tomedf06bb2014-08-27 16:22:15 -070024 * Returns a collection of the currently known infrastructure
tome33cc1a2014-08-25 21:59:41 -070025 * devices.
26 *
27 * @return collection of devices
28 */
29 Iterable<Device> getDevices();
30
31 /**
32 * Returns the device with the specified identifier.
33 *
34 * @param deviceId device identifier
35 * @return device or null if one with the given identifier is not known
36 */
37 Device getDevice(DeviceId deviceId);
38
tomad2d2092014-09-06 23:24:20 -070039 /**
40 * Returns the current mastership role for the specified device.
41 *
42 * @param deviceId device identifier
43 * @return designated mastership role
44 */
45 MastershipRole getRole(DeviceId deviceId);
46
tome33cc1a2014-08-25 21:59:41 -070047
tomb36046e2014-08-27 00:22:24 -070048 /**
49 * Returns the list of ports associated with the device.
50 *
51 * @param deviceId device identifier
52 * @return list of ports
53 */
54 List<Port> getPorts(DeviceId deviceId);
55
56 /**
57 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -070058 *
59 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -070060 * @param portNumber port number
61 * @return device port
62 */
63 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -070064
65 /**
tomff7eb7c2014-09-08 12:49:03 -070066 * Indicates whether or not the device is presently online and available.
67 *
68 * @param deviceId device identifier
69 * @return true if the device is available
70 */
71 boolean isAvailable(DeviceId deviceId);
72
73 /**
tome33cc1a2014-08-25 21:59:41 -070074 * Adds the specified device listener.
75 *
76 * @param listener device listener
77 */
78 void addListener(DeviceListener listener);
79
80 /**
81 * Removes the specified device listener.
82 *
83 * @param listener device listener
84 */
85 void removeListener(DeviceListener listener);
tomb36046e2014-08-27 00:22:24 -070086
tome33cc1a2014-08-25 21:59:41 -070087}