Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.device; |
| 17 | |
| 18 | import org.onlab.onos.net.Device; |
| 19 | import org.onlab.onos.net.DeviceId; |
| 20 | import org.onlab.onos.net.MastershipRole; |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.Port; |
| 22 | import org.onlab.onos.net.PortNumber; |
| 23 | |
| 24 | import java.util.List; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Service for interacting with the inventory of infrastructure devices. |
| 28 | */ |
| 29 | public interface DeviceService { |
| 30 | |
| 31 | /** |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 32 | * Returns the number of infrastructure devices known to the system. |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 33 | * |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 34 | * @return number of infrastructure devices |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 35 | */ |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 36 | int getDeviceCount(); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 39 | * Returns a collection of the currently known infrastructure |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 40 | * 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 | |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 54 | /** |
| 55 | * Returns the current mastership role for the specified device. |
| 56 | * |
| 57 | * @param deviceId device identifier |
| 58 | * @return designated mastership role |
| 59 | */ |
Ayaka Koshibe | 25fd23a | 2014-10-03 15:50:43 -0700 | [diff] [blame] | 60 | //XXX do we want this method here when MastershipService already does? |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 61 | MastershipRole getRole(DeviceId deviceId); |
| 62 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 63 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 64 | /** |
| 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. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 74 | * |
| 75 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 76 | * @param portNumber port number |
| 77 | * @return device port |
| 78 | */ |
| 79 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 82 | * 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 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 90 | * 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); |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 102 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 103 | } |