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