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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.device; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.net.Device; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.MastershipRole; |
| 21 | import org.onosproject.net.Port; |
| 22 | import org.onosproject.net.PortNumber; |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 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 | /** |
Yuta HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 47 | * 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 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 55 | * 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 | |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 62 | /** |
| 63 | * Returns the current mastership role for the specified device. |
| 64 | * |
| 65 | * @param deviceId device identifier |
| 66 | * @return designated mastership role |
| 67 | */ |
Ayaka Koshibe | 25fd23a | 2014-10-03 15:50:43 -0700 | [diff] [blame] | 68 | //XXX do we want this method here when MastershipService already does? |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 69 | MastershipRole getRole(DeviceId deviceId); |
| 70 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 71 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 72 | /** |
| 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. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 82 | * |
| 83 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 84 | * @param portNumber port number |
| 85 | * @return device port |
| 86 | */ |
| 87 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 90 | * 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 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 98 | * 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); |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 110 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 111 | } |