Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.roadm; |
| 17 | |
| 18 | import com.google.common.collect.Range; |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 19 | import org.onosproject.net.ConnectPoint; |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.OchSignal; |
| 22 | import org.onosproject.net.PortNumber; |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 23 | import org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState; |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 24 | import org.onosproject.net.flow.FlowId; |
| 25 | |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 26 | import java.util.Map; |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 27 | import java.util.Set; |
| 28 | |
| 29 | /** |
| 30 | * ROADM service interface. Provides an interface for ROADM power configuration. |
| 31 | * |
| 32 | * This application relies on the PowerConfig and LambdaQuery behaviours. |
| 33 | * |
| 34 | * The device's PowerConfig implementation should be parameterized as |
| 35 | * {@code PowerConfig<Object>} in order to support both Direction and OchSignal. |
| 36 | * For a reference implementation of PowerConfig, please see |
| 37 | * OplinkRoadmPowerConfig |
| 38 | * |
| 39 | * In this application, a "connection" refers to the selection of a channel |
| 40 | * to direct from an input to an output port. Connections are implemented |
| 41 | * using FlowRules with an input port selector, optical channel selector, |
| 42 | * and output port treatment (see RoadmManager#createConnection()). |
| 43 | * |
| 44 | * This application currently only supports fixed grid channels. |
| 45 | */ |
| 46 | public interface RoadmService { |
| 47 | |
| 48 | /** |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 49 | * Attempts to manually switch working path to the one specified by {@code index}. |
| 50 | * |
| 51 | * @param deviceId DeviceId of the device to configure |
| 52 | * @param index working path index to switch to |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 53 | * @deprecated 1.11.0 |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 54 | */ |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 55 | @Deprecated |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 56 | void setProtectionSwitchWorkingPath(DeviceId deviceId, int index); |
| 57 | |
| 58 | /** |
| 59 | * Retrieves protection switch specified port's service status. |
| 60 | * |
| 61 | * @param deviceId DeviceId of the device to configure |
| 62 | * @param portNumber the port |
| 63 | * @return port service status |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 64 | * @deprecated 1.11.0 |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 65 | */ |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 66 | @Deprecated |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 67 | String getProtectionSwitchPortState(DeviceId deviceId, PortNumber portNumber); |
| 68 | |
| 69 | /** |
MaoLu | 2846b11 | 2017-05-15 17:18:55 -0700 | [diff] [blame] | 70 | * Attempts to config protection switch by specified {@code operation} and {@code index}. |
| 71 | * |
| 72 | * @param deviceId DeviceId of the device to configure |
| 73 | * @param operation switch configuration, automatic, force or manual |
| 74 | * @param identifier {@link ConnectPoint} for the virtual Port representing protected path endpoint |
| 75 | * @param index working path index to switch to |
| 76 | */ |
| 77 | void configProtectionSwitch(DeviceId deviceId, String operation, ConnectPoint identifier, int index); |
| 78 | |
| 79 | /** |
| 80 | * Retrieves protection switch endpoint states. |
| 81 | * @param deviceId DeviceId of the device to configure |
| 82 | * @return map groups of underlying paths |
| 83 | */ |
| 84 | Map<ConnectPoint, ProtectedTransportEndpointState> getProtectionSwitchStates(DeviceId deviceId); |
| 85 | |
| 86 | /** |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 87 | * Set target power for a port if the port has configurable target power. |
| 88 | * |
| 89 | * @param deviceId DeviceId of the device to configure |
| 90 | * @param portNumber PortNumber of the port to configure |
| 91 | * @param power value to set target power to |
| 92 | */ |
| 93 | void setTargetPortPower(DeviceId deviceId, PortNumber portNumber, long power); |
| 94 | |
| 95 | /** |
Boyuan Yan | f3f6a8d | 2019-05-26 18:35:54 -0700 | [diff] [blame] | 96 | * Returns the target power stored in storage for a port if the port has configurable target power. |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 97 | * |
| 98 | * @param deviceId DeviceId of the device to configure |
| 99 | * @param portNumber PortNumber of the port to configure |
| 100 | * @return the target power if the port has a target power, null otherwise |
| 101 | */ |
| 102 | Long getTargetPortPower(DeviceId deviceId, PortNumber portNumber); |
| 103 | |
| 104 | /** |
Boyuan Yan | f3f6a8d | 2019-05-26 18:35:54 -0700 | [diff] [blame] | 105 | * Sync-up the target power for a port if the operator want to check the configuration. |
| 106 | * @param deviceId DeviceId of the device to configure |
| 107 | * @param portNumber PortNumber of the port to configure |
| 108 | * @return the target power if the port has a target power, null otherwise |
| 109 | */ |
| 110 | Long syncTargetPortPower(DeviceId deviceId, PortNumber portNumber); |
| 111 | |
| 112 | /** |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 113 | * Sets the attenuation of a connection. This does not check that attenuation |
| 114 | * is within the acceptable range. |
| 115 | * |
| 116 | * @param deviceId DeviceId of the device to configure |
| 117 | * @param portNumber PortNumber of either the input or output port |
| 118 | * @param ochSignal channel to set attenuation for |
| 119 | * @param attenuation attenuation value to set to |
| 120 | */ |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 121 | void setAttenuation(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal, long attenuation); |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Returns the attenuation of a connection. |
| 125 | * |
| 126 | * @param deviceId DeviceId of the device |
| 127 | * @param portNumber PortNumber of either the input or output port |
| 128 | * @param ochSignal channel to search for |
| 129 | * @return attenuation if found, null otherwise |
| 130 | */ |
| 131 | Long getAttenuation(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal); |
| 132 | |
| 133 | /** |
| 134 | * Returns the current port power. |
| 135 | * |
| 136 | * @param deviceId DeviceId of the device |
| 137 | * @param portNumber PortNumber of the port |
| 138 | * @return current power if found, null otherwise |
| 139 | */ |
| 140 | Long getCurrentPortPower(DeviceId deviceId, PortNumber portNumber); |
| 141 | |
| 142 | /** |
| 143 | * Returns the current channel power. |
| 144 | * |
| 145 | * @param deviceId DeviceId of the device |
| 146 | * @param portNumber PortNumber of either the input or output port of the connection |
| 147 | * @param ochSignal channel to search for |
| 148 | * @return channel power if found, null otherwise |
| 149 | */ |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 150 | Long getCurrentChannelPower(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal); |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * Returns the channels supported by a port. |
| 154 | * |
| 155 | * @param deviceId DeviceId of the device |
| 156 | * @param portNumber PortNumber of the port |
| 157 | * @return the set of supported channels |
| 158 | */ |
| 159 | Set<OchSignal> queryLambdas(DeviceId deviceId, PortNumber portNumber); |
| 160 | |
| 161 | /** |
| 162 | * Creates a new internal connection on a device without attenuation. This does |
| 163 | * not check that the connection is actually valid (e.g. an input port to an |
| 164 | * output port). |
| 165 | * |
| 166 | * Connections are represented as flows with an input port, output port, and |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 167 | * channel. |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 168 | * |
| 169 | * @param deviceId DeviceId of the device to create this connection for |
| 170 | * @param priority priority of the flow |
| 171 | * @param isPermanent permanence of the flow |
| 172 | * @param timeout timeout in seconds |
| 173 | * @param inPort input port |
| 174 | * @param outPort output port |
| 175 | * @param ochSignal channel to use |
| 176 | * @return FlowId of the FlowRule representing the connection |
| 177 | */ |
| 178 | FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent, |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 179 | int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal); |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Creates a new internal connection on a device with attenuation. This does |
| 183 | * not check that the connection is actually valid (e.g. an input port to an |
| 184 | * output port, attenuation if within the acceptable range). |
| 185 | * |
| 186 | * Connections are represented as flows with an input port, output port, and |
| 187 | * channel. Implementation of attenuation is up to the vendor. |
| 188 | * |
| 189 | * @param deviceId DeviceId of the device to create this connection for |
| 190 | * @param priority priority of the flow |
| 191 | * @param isPermanent permanence of the flow |
| 192 | * @param timeout timeout in seconds |
| 193 | * @param inPort input port |
| 194 | * @param outPort output port |
| 195 | * @param ochSignal channel to use |
| 196 | * @param attenuation attenuation of the connection |
| 197 | * @return FlowId of the FlowRule representing the connection |
| 198 | */ |
| 199 | FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent, |
| 200 | int timeout, PortNumber inPort, PortNumber outPort, |
| 201 | OchSignal ochSignal, long attenuation); |
| 202 | |
| 203 | /** |
| 204 | * Removes an internal connection from a device by matching the FlowId and |
| 205 | * removing the flow representing the connection. This will remove any flow |
| 206 | * from any device so FlowId should correspond with a connection flow. |
| 207 | * |
| 208 | * @param deviceId DeviceId of the device to remove the connection from |
| 209 | * @param flowId FlowId of the flow representing the connection to remove |
| 210 | */ |
| 211 | void removeConnection(DeviceId deviceId, FlowId flowId); |
| 212 | |
| 213 | /** |
| 214 | * Returns true if the target power for this port can be configured. |
| 215 | * |
| 216 | * @param deviceId DeviceId of the device |
| 217 | * @param portNumber PortNumber of the port to check |
| 218 | * @return true if the target power for this port can be configured, false |
| 219 | * otherwise |
| 220 | */ |
| 221 | boolean hasPortTargetPower(DeviceId deviceId, PortNumber portNumber); |
| 222 | |
| 223 | /** |
| 224 | * Returns true if value is within the acceptable target power range of the port. |
| 225 | * Returns false if the port does not have a configurable target |
| 226 | * power. |
| 227 | * |
| 228 | * @param deviceId DeviceId of the device to check |
| 229 | * @param portNumber PortNumber of the port to check |
| 230 | * @param power value to check |
| 231 | * @return true if value is within the acceptable target power range, false |
| 232 | * otherwise |
| 233 | */ |
| 234 | boolean portTargetPowerInRange(DeviceId deviceId, PortNumber portNumber, long power); |
| 235 | |
| 236 | /** |
| 237 | * Returns true if value is within the acceptable attenuation range of a |
| 238 | * connection, and always returns false if the connection does not support |
| 239 | * attenuation. The attenuation range is determined by either the input |
| 240 | * or output port of the connection. |
| 241 | * |
| 242 | * @param deviceId DeviceId of the device to check |
| 243 | * @param portNumber PortNumber of either the input or output port of the connection |
| 244 | * @param att value to check |
| 245 | * @return true if value is within the acceptable attenuation range, false |
| 246 | * otherwise |
| 247 | */ |
| 248 | boolean attenuationInRange(DeviceId deviceId, PortNumber portNumber, long att); |
| 249 | |
| 250 | /** |
| 251 | * Returns true if the port is an input port. |
| 252 | * |
| 253 | * @param deviceId DeviceId of the device to check |
| 254 | * @param portNumber PortNumber of the port to check |
| 255 | * @return true if the port is an input port, false otherwise |
| 256 | */ |
| 257 | boolean validInputPort(DeviceId deviceId, PortNumber portNumber); |
| 258 | |
| 259 | /** |
| 260 | * Returns true if the port is an output port. |
| 261 | * |
| 262 | * @param deviceId DeviceId of the device to check |
| 263 | * @param portNumber PortNumber of the port to check |
| 264 | * @return true if the port is an output port, false otherwise |
| 265 | */ |
| 266 | boolean validOutputPort(DeviceId deviceId, PortNumber portNumber); |
| 267 | |
| 268 | /** |
| 269 | * Returns true if the channel is supported by the port. The port can be either |
| 270 | * an input or output port. |
| 271 | * |
| 272 | * @param deviceId DeviceId of the device to check |
| 273 | * @param portNumber PortNumber of the port to check |
| 274 | * @param ochSignal channel to check |
| 275 | * @return true if the channel is supported by the port, false otherwise |
| 276 | */ |
| 277 | boolean validChannel(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal); |
| 278 | |
| 279 | /** |
| 280 | * Returns true if the channel is not being used by a connection on the |
| 281 | * device. |
| 282 | * |
| 283 | * @param deviceId DeviceId of the device to check |
| 284 | * @param ochSignal channel to check |
| 285 | * @return true if the channel is not in use, false otherwise |
| 286 | */ |
| 287 | boolean channelAvailable(DeviceId deviceId, OchSignal ochSignal); |
| 288 | |
| 289 | /** |
| 290 | * Returns true if the connection from the input port to the output port is |
| 291 | * valid. This currently only checks if the given input and output ports are, |
| 292 | * respectively, valid input and output ports. |
| 293 | * |
| 294 | * @param deviceId DeviceId of the device to check |
| 295 | * @param inPort input port of the connection |
| 296 | * @param outPort output port of the connection |
| 297 | * @return true if the connection is valid, false otherwise |
| 298 | */ |
| 299 | boolean validConnection(DeviceId deviceId, PortNumber inPort, PortNumber outPort); |
| 300 | |
| 301 | /** |
| 302 | * Returns the acceptable target port power range for a port. |
| 303 | * |
| 304 | * @param deviceId DeviceId of the device |
| 305 | * @param portNumber PortNumber of the port |
| 306 | * @return range if found, null otherwise |
| 307 | */ |
| 308 | Range<Long> targetPortPowerRange(DeviceId deviceId, PortNumber portNumber); |
| 309 | |
| 310 | /** |
| 311 | * Returns the acceptable attenuation range for a connection. |
| 312 | * |
| 313 | * @param deviceId DeviceId of the device |
| 314 | * @param portNumber PortNumber of either the input or output port |
| 315 | * @param ochSignal channel to check |
| 316 | * @return range if found, null otherwise |
| 317 | */ |
MaoLu | 937cf42 | 2017-03-03 23:31:46 -0800 | [diff] [blame] | 318 | Range<Long> attenuationRange(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal); |
Jimmy Yan | da878fc | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 319 | |
| 320 | /** |
| 321 | * Returns the expected input power range for an input port. |
| 322 | * |
| 323 | * @param deviceId DeviceId of the device |
| 324 | * @param portNumber PortNumber of an input port |
| 325 | * @return range if found, null otherwise |
| 326 | */ |
| 327 | Range<Long> inputPortPowerRange(DeviceId deviceId, PortNumber portNumber); |
| 328 | } |