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