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 | 41a2c5f | 2014-09-19 09:20:35 -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.Port; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | import org.onosproject.net.provider.ProviderId; |
| 23 | import org.onosproject.store.Store; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 24 | |
| 25 | import java.util.List; |
| 26 | |
| 27 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 28 | * Manages inventory of infrastructure devices; not intended for direct use. |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 29 | */ |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 30 | public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Returns the number of devices known to the system. |
| 34 | * |
| 35 | * @return number of devices |
| 36 | */ |
| 37 | int getDeviceCount(); |
| 38 | |
| 39 | /** |
| 40 | * Returns an iterable collection of all devices known to the system. |
| 41 | * |
| 42 | * @return device collection |
| 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 currently available to the system. |
| 48 | * |
| 49 | * @return device collection |
| 50 | */ |
| 51 | Iterable<Device> getAvailableDevices(); |
| 52 | |
| 53 | |
| 54 | |
| 55 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 56 | * Returns the device with the specified identifier. |
| 57 | * |
| 58 | * @param deviceId device identifier |
| 59 | * @return device |
| 60 | */ |
| 61 | Device getDevice(DeviceId deviceId); |
| 62 | |
| 63 | /** |
| 64 | * Creates a new infrastructure device, or updates an existing one using |
| 65 | * the supplied device description. |
| 66 | * |
| 67 | * @param providerId provider identifier |
| 68 | * @param deviceId device identifier |
| 69 | * @param deviceDescription device description |
| 70 | * @return ready to send event describing what occurred; null if no change |
| 71 | */ |
| 72 | DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, |
| 73 | DeviceDescription deviceDescription); |
| 74 | |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 75 | // TODO: We may need to enforce that ancillary cannot interfere this state |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Removes the specified infrastructure device. |
| 78 | * |
| 79 | * @param deviceId device identifier |
| 80 | * @return ready to send event describing what occurred; null if no change |
| 81 | */ |
| 82 | DeviceEvent markOffline(DeviceId deviceId); |
| 83 | |
| 84 | /** |
| 85 | * Updates the ports of the specified infrastructure device using the given |
| 86 | * list of port descriptions. The list is assumed to be comprehensive. |
| 87 | * |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 88 | * @param providerId provider identifier |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 89 | * @param deviceId device identifier |
| 90 | * @param portDescriptions list of port descriptions |
| 91 | * @return ready to send events describing what occurred; empty list if no change |
| 92 | */ |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 93 | List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 94 | List<PortDescription> portDescriptions); |
| 95 | |
| 96 | /** |
| 97 | * Updates the port status of the specified infrastructure device using the |
| 98 | * given port description. |
| 99 | * |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 100 | * @param providerId provider identifier |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 101 | * @param deviceId device identifier |
| 102 | * @param portDescription port description |
| 103 | * @return ready to send event describing what occurred; null if no change |
| 104 | */ |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 105 | DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 106 | PortDescription portDescription); |
| 107 | |
| 108 | /** |
| 109 | * Returns the list of ports that belong to the specified device. |
| 110 | * |
| 111 | * @param deviceId device identifier |
| 112 | * @return list of device ports |
| 113 | */ |
| 114 | List<Port> getPorts(DeviceId deviceId); |
| 115 | |
| 116 | /** |
| 117 | * Returns the specified device port. |
| 118 | * |
| 119 | * @param deviceId device identifier |
| 120 | * @param portNumber port number |
| 121 | * @return device port |
| 122 | */ |
| 123 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
| 124 | |
| 125 | /** |
| 126 | * Indicates whether the specified device is available/online. |
| 127 | * |
| 128 | * @param deviceId device identifier |
| 129 | * @return true if device is available |
| 130 | */ |
| 131 | boolean isAvailable(DeviceId deviceId); |
| 132 | |
| 133 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 134 | * Administratively removes the specified device from the store. |
| 135 | * |
| 136 | * @param deviceId device to be removed |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 137 | * @return null if no such device, or was forwarded to remove master |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 138 | */ |
| 139 | DeviceEvent removeDevice(DeviceId deviceId); |
| 140 | } |