blob: d35b1af3e0d601525b822ccc4b1ca35724f402ae [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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 */
tome33cc1a2014-08-25 21:59:41 -070016package org.onlab.onos.net.device;
17
18import org.onlab.onos.net.Device;
19import org.onlab.onos.net.DeviceId;
20import org.onlab.onos.net.MastershipRole;
tomb36046e2014-08-27 00:22:24 -070021import org.onlab.onos.net.Port;
22import org.onlab.onos.net.PortNumber;
23
24import java.util.List;
tome33cc1a2014-08-25 21:59:41 -070025
26/**
27 * Service for interacting with the inventory of infrastructure devices.
28 */
29public interface DeviceService {
30
31 /**
tomad2d2092014-09-06 23:24:20 -070032 * Returns the number of infrastructure devices known to the system.
tome33cc1a2014-08-25 21:59:41 -070033 *
tomad2d2092014-09-06 23:24:20 -070034 * @return number of infrastructure devices
tome33cc1a2014-08-25 21:59:41 -070035 */
tomad2d2092014-09-06 23:24:20 -070036 int getDeviceCount();
tome33cc1a2014-08-25 21:59:41 -070037
38 /**
tomedf06bb2014-08-27 16:22:15 -070039 * Returns a collection of the currently known infrastructure
tome33cc1a2014-08-25 21:59:41 -070040 * devices.
41 *
42 * @return collection of devices
43 */
44 Iterable<Device> getDevices();
45
46 /**
47 * Returns the device with the specified identifier.
48 *
49 * @param deviceId device identifier
50 * @return device or null if one with the given identifier is not known
51 */
52 Device getDevice(DeviceId deviceId);
53
tomad2d2092014-09-06 23:24:20 -070054 /**
55 * Returns the current mastership role for the specified device.
56 *
57 * @param deviceId device identifier
58 * @return designated mastership role
59 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070060 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070061 MastershipRole getRole(DeviceId deviceId);
62
tome33cc1a2014-08-25 21:59:41 -070063
tomb36046e2014-08-27 00:22:24 -070064 /**
65 * Returns the list of ports associated with the device.
66 *
67 * @param deviceId device identifier
68 * @return list of ports
69 */
70 List<Port> getPorts(DeviceId deviceId);
71
72 /**
73 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -070074 *
75 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -070076 * @param portNumber port number
77 * @return device port
78 */
79 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -070080
81 /**
tomff7eb7c2014-09-08 12:49:03 -070082 * Indicates whether or not the device is presently online and available.
83 *
84 * @param deviceId device identifier
85 * @return true if the device is available
86 */
87 boolean isAvailable(DeviceId deviceId);
88
89 /**
tome33cc1a2014-08-25 21:59:41 -070090 * Adds the specified device listener.
91 *
92 * @param listener device listener
93 */
94 void addListener(DeviceListener listener);
95
96 /**
97 * Removes the specified device listener.
98 *
99 * @param listener device listener
100 */
101 void removeListener(DeviceListener listener);
tomb36046e2014-08-27 00:22:24 -0700102
tome33cc1a2014-08-25 21:59:41 -0700103}