blob: 7d2a0dd77ac7bce1eaf4d8681791ea0029a6cefd [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 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080047 * Returns an iterable collection of all devices
48 * currently available to the system.
49 *
50 * @return device collection
51 */
52 Iterable<Device> getAvailableDevices();
53
54 /**
tome33cc1a2014-08-25 21:59:41 -070055 * Returns the device with the specified identifier.
56 *
57 * @param deviceId device identifier
58 * @return device or null if one with the given identifier is not known
59 */
60 Device getDevice(DeviceId deviceId);
61
tomad2d2092014-09-06 23:24:20 -070062 /**
63 * Returns the current mastership role for the specified device.
64 *
65 * @param deviceId device identifier
66 * @return designated mastership role
67 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070068 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070069 MastershipRole getRole(DeviceId deviceId);
70
tome33cc1a2014-08-25 21:59:41 -070071
tomb36046e2014-08-27 00:22:24 -070072 /**
73 * Returns the list of ports associated with the device.
74 *
75 * @param deviceId device identifier
76 * @return list of ports
77 */
78 List<Port> getPorts(DeviceId deviceId);
79
80 /**
81 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -070082 *
83 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -070084 * @param portNumber port number
85 * @return device port
86 */
87 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -070088
89 /**
tomff7eb7c2014-09-08 12:49:03 -070090 * Indicates whether or not the device is presently online and available.
91 *
92 * @param deviceId device identifier
93 * @return true if the device is available
94 */
95 boolean isAvailable(DeviceId deviceId);
96
97 /**
tome33cc1a2014-08-25 21:59:41 -070098 * Adds the specified device listener.
99 *
100 * @param listener device listener
101 */
102 void addListener(DeviceListener listener);
103
104 /**
105 * Removes the specified device listener.
106 *
107 * @param listener device listener
108 */
109 void removeListener(DeviceListener listener);
tomb36046e2014-08-27 00:22:24 -0700110
tome33cc1a2014-08-25 21:59:41 -0700111}