blob: 54b9d722dbd9ecd8dc18963ce59a8ae93387376b [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 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070045 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070046 MastershipRole getRole(DeviceId deviceId);
47
tome33cc1a2014-08-25 21:59:41 -070048
tomb36046e2014-08-27 00:22:24 -070049 /**
50 * Returns the list of ports associated with the device.
51 *
52 * @param deviceId device identifier
53 * @return list of ports
54 */
55 List<Port> getPorts(DeviceId deviceId);
56
57 /**
58 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -070059 *
60 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -070061 * @param portNumber port number
62 * @return device port
63 */
64 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -070065
66 /**
tomff7eb7c2014-09-08 12:49:03 -070067 * Indicates whether or not the device is presently online and available.
68 *
69 * @param deviceId device identifier
70 * @return true if the device is available
71 */
72 boolean isAvailable(DeviceId deviceId);
73
74 /**
tome33cc1a2014-08-25 21:59:41 -070075 * Adds the specified device listener.
76 *
77 * @param listener device listener
78 */
79 void addListener(DeviceListener listener);
80
81 /**
82 * Removes the specified device listener.
83 *
84 * @param listener device listener
85 */
86 void removeListener(DeviceListener listener);
tomb36046e2014-08-27 00:22:24 -070087
tome33cc1a2014-08-25 21:59:41 -070088}