2 * Copyright © 2018 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.servicehandler.utils;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.ListeningExecutorService;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import java.time.OffsetDateTime;
14 import java.time.ZoneOffset;
15 import java.time.format.DateTimeFormatter;
17 import java.util.concurrent.Callable;
18 import java.util.concurrent.Executors;
19 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInput;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInputBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResult;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResultBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescriptionBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSpBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultShBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceNotificationTypes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeader;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirection;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirection;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionKey;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.lgx.LgxBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraintsBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.SoftConstraintsBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput.Option;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfo;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.feasibility.check.inputs.ServiceAEnd;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.feasibility.check.inputs.ServiceAEndBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.feasibility.check.inputs.ServiceZEnd;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.feasibility.check.inputs.ServiceZEndBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
69 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric;
73 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
74 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes;
75 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder;
76 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
77 import org.opendaylight.yangtools.yang.common.Uint32;
78 import org.opendaylight.yangtools.yang.common.Uint8;
80 public final class ServiceDataUtils {
82 public static ServiceCreateInput buildServiceCreateInput() {
84 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
85 .ServiceAEnd serviceAEnd = getServiceAEndBuild().build();
86 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
87 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service
88 .create.input.ServiceZEndBuilder()
89 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
90 .setNodeId(new NodeIdType("XPONDER-3-2"))
91 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
92 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
95 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
96 .setCommonId("commonId")
97 .setConnectionType(ConnectionType.Service)
98 .setCustomer("Customer")
99 .setServiceName("service 1")
100 .setServiceAEnd(serviceAEnd)
101 .setServiceZEnd(serviceZEnd)
102 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
103 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build());
105 return builtInput.build();
108 public static ServiceCreateInput buildServiceCreateInputWithHardConstraints() {
110 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
111 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
113 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
114 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service
115 .create.input.ServiceZEndBuilder()
116 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
117 .setNodeId(new NodeIdType("XPONDER-3-2"))
118 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
119 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
122 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
123 .setCommonId("commonId")
124 .setConnectionType(ConnectionType.Service)
125 .setCustomer("Customer")
126 .setServiceName("service 1")
127 .setServiceAEnd(serviceAEnd)
128 .setServiceZEnd(serviceZEnd)
129 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
130 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
131 .setHardConstraints(new HardConstraintsBuilder().build());
133 return builtInput.build();
136 public static ServiceCreateInput buildServiceCreateInputWithSoftConstraints() {
138 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
139 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
141 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
142 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service
143 .create.input.ServiceZEndBuilder()
144 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
145 .setNodeId(new NodeIdType("XPONDER-3-2"))
146 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
147 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
150 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
151 .setCommonId("commonId")
152 .setConnectionType(ConnectionType.Service)
153 .setCustomer("Customer")
154 .setServiceName("service 1")
155 .setServiceAEnd(serviceAEnd)
156 .setServiceZEnd(serviceZEnd)
157 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
158 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
159 .setSoftConstraints(new SoftConstraintsBuilder().build());
161 return builtInput.build();
164 public static PathComputationRequestInput createPceRequestInput(ServiceCreateInput input) {
165 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
166 SdncRequestHeader serviceHandler = input.getSdncRequestHeader();
167 if (serviceHandler != null) {
168 serviceHandlerHeader.setRequestId(serviceHandler.getRequestId());
170 return new PathComputationRequestInputBuilder()
171 .setServiceName(input.getServiceName())
172 .setResourceReserve(true)
173 .setServiceHandlerHeader(serviceHandlerHeader.build())
174 .setHardConstraints(input.getHardConstraints())
175 .setSoftConstraints(input.getSoftConstraints())
176 .setPceRoutingMetric(PceMetric.TEMetric)
177 .setServiceAEnd(ModelMappingUtils.createServiceAEnd(input.getServiceAEnd()))
178 .setServiceZEnd(ModelMappingUtils.createServiceZEnd(input.getServiceZEnd()))
182 public static TempServiceCreateInput buildTempServiceCreateInput() {
184 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.create.input
185 .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp
186 .service.create.input.ServiceAEndBuilder()
187 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
188 .setNodeId(new NodeIdType("XPONDER-1-2"))
189 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
190 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
192 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.create.input
193 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp
194 .service.create.input.ServiceZEndBuilder()
195 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
196 .setNodeId(new NodeIdType("XPONDER-3-2"))
197 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
198 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
201 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder()
202 .setCommonId("commonId")
203 .setConnectionType(ConnectionType.Service)
204 .setCustomer("Customer")
205 .setServiceAEnd(serviceAEnd)
206 .setServiceZEnd(serviceZEnd)
207 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
208 .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
210 return builtInput.build();
213 public static ServiceFeasibilityCheckInput buildServiceFeasibilityCheckInput() {
215 ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
216 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
217 .setNodeId(new NodeIdType("XPONDER-1-2"))
218 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
219 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection())).build();
220 ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
221 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
222 .setNodeId(new NodeIdType("XPONDER-3-2"))
223 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
224 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection())).build();
226 ServiceFeasibilityCheckInputBuilder builtInput = new ServiceFeasibilityCheckInputBuilder()
227 .setCommonId("commonId")
228 .setConnectionType(ConnectionType.Service)
229 .setCustomer("Customer")
230 .setServiceAEnd(serviceAEnd)
231 .setServiceZEnd(serviceZEnd)
232 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
233 .setRpcAction(RpcActions.ServiceFeasibilityCheck).setNotificationUrl("notification url").build());
234 return builtInput.build();
237 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
238 .ServiceAEndBuilder getServiceAEndBuild() {
239 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
240 .ServiceAEndBuilder()
241 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
242 .setNodeId(new NodeIdType("XPONDER-1-2"))
243 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
244 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
247 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
248 .ServiceZEndBuilder getServiceZEndBuild() {
249 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input
250 .ServiceZEndBuilder()
251 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
252 .setNodeId(new NodeIdType("XPONDER-1-2"))
253 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
254 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
257 private static TxDirection getTxDirection() {
258 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
259 .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
260 .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
261 .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
262 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
263 .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
264 .setIndex(Uint8.ZERO)
268 private static RxDirection getRxDirection() {
269 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service
270 .endpoint.RxDirectionBuilder()
271 .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
272 .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
273 .setPortSubSlot("port subslot").setPortType("port type").build())
274 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
275 .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
276 .setLgxPortShelf("lgx port shelf").build())
277 .setIndex(Uint8.ZERO)
281 public static ServiceDeleteInput buildServiceDeleteInput() {
283 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
284 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
285 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
286 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
287 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("service 1")
288 .setDueDate(datetime).setTailRetention(ServiceDeleteReqInfo.TailRetention.No).build());
289 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
290 .setNotificationUrl("notification url")
291 .setRequestId("request 1")
292 .setRequestSystemId("request system 1")
293 .setRpcAction(RpcActions.ServiceDelete);
294 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
295 return deleteInputBldr.build();
298 public static TempServiceDeleteInput buildTempServiceDeleteInput() {
299 TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
300 .setCommonId("service 1");
301 return deleteInputBldr.build();
304 public static TempServiceDeleteInput buildTempServiceDeleteInput(String commonId) {
305 TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
306 .setCommonId(commonId);
307 return deleteInputBldr.build();
310 public static ServiceRerouteInput buildServiceRerouteInput() {
311 ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder()
312 .setServiceName("service 1");
313 return builder.build();
316 public static ServiceRestorationInput buildServiceRestorationInput() {
317 ServiceRestorationInputBuilder builder = new ServiceRestorationInputBuilder()
318 .setServiceName("service 1")
319 .setOption(Option.Permanent);
320 return builder.build();
323 public static ServiceReconfigureInput buildServiceReconfigureInput() {
325 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
326 .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service
327 .reconfigure.input.ServiceAEndBuilder()
328 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
329 .setNodeId(new NodeIdType("XPONDER-1-2"))
330 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
331 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
333 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
334 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service
335 .reconfigure.input.ServiceZEndBuilder()
336 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
337 .setNodeId(new NodeIdType("XPONDER-3-2"))
338 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
339 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
342 ServiceReconfigureInputBuilder builtInput = new ServiceReconfigureInputBuilder()
343 .setCommonId("commonId")
344 .setConnectionType(ConnectionType.Service)
345 .setCustomer("Customer")
346 .setServiceName("service 1")
347 .setServiceAEnd(serviceAEnd)
348 .setServiceZEnd(serviceZEnd);
349 return builtInput.build();
352 public static ServicePathRpcResult buildServicePathRpcResult() {
353 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
354 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
355 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
356 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
357 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
358 .setPathDescription(createPathDescription(0,1, 0, 1))
359 .setServiceName("service 1")
360 .setStatus(RpcStatusEx.Successful).setStatusMessage("success");
361 return builder.build();
364 public static ServicePathRpcResult buildServicePathRpcResult(
365 ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx,
366 String message, Boolean pathDescription) {
367 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
368 builder.setNotificationType(servicePathNotificationTypes)
369 .setServiceName(serviceName)
370 .setStatus(rpcStatusEx).setStatusMessage(message);
371 if (pathDescription) {
372 builder.setPathDescription(createPathDescription(0L, 5L, 0L, 5L));
374 return builder.build();
377 public static ServicePathRpcResult buildFailedPceServicePathRpcResult() {
378 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
379 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
380 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
381 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
382 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
383 .setPathDescription(createPathDescription(0, 1, 0, 1)).setServiceName("service 1")
384 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
385 return builder.build();
388 public static ServicePathRpcResult buildFailedServicePathRpcResult() {
389 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
390 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
391 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
392 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
393 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
394 .setPathDescription(createPathDescription(0,1, 0, 1))
395 .setServiceName("service 1")
396 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
397 return builder.build();
400 public static RendererRpcResultSp buildRendererRpcResultSp() {
401 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
402 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
403 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
404 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
405 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
406 .setServiceName("service 1").setStatus(RpcStatusEx.Successful).setStatusMessage("success");
407 return builder.build();
410 public static RendererRpcResultSp buildRendererRpcResultSp(
411 ServicePathNotificationTypes servicePathNotificationTypes,
412 String serviceName, RpcStatusEx rpcStatusEx, String message) {
413 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
414 builder.setNotificationType(servicePathNotificationTypes).setServiceName(serviceName)
415 .setStatus(rpcStatusEx).setStatusMessage(message);
416 return builder.build();
419 public static ServiceRpcResultSh buildServiceRpcResultSh(
420 ServiceNotificationTypes serviceNotificationTypes,
422 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx
425 ServiceRpcResultShBuilder builder = new ServiceRpcResultShBuilder();
426 builder.setNotificationType(serviceNotificationTypes).setServiceName(serviceName)
427 .setStatus(rpcStatusEx).setStatusMessage(message);
428 return builder.build();
431 public static RendererRpcResultSp buildFailedRendererRpcResultSp() {
432 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
433 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
434 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
435 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
436 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
437 .setServiceName("service 1").setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
438 return builder.build();
441 public static PathDescription createPathDescription(long azRate, long azWaveLength, long zaRate,
443 AToZDirection atozDirection = new AToZDirectionBuilder()
444 .setRate(Uint32.valueOf(azRate))
445 .setAToZWavelengthNumber(Uint32.valueOf(azWaveLength))
447 ZToADirection ztoaDirection = new ZToADirectionBuilder()
448 .setRate(Uint32.valueOf(zaRate))
449 .setZToAWavelengthNumber(Uint32.valueOf(zaWaveLength))
451 PathDescription pathDescription = new PathDescriptionBuilder()
452 .setAToZDirection(atozDirection)
453 .setZToADirection(ztoaDirection)
455 return pathDescription;
458 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
459 .ServiceAEndBuilder getServiceAEndBuildReconfigure() {
460 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
461 .ServiceAEndBuilder()
462 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
463 .setNodeId(new NodeIdType("XPONDER-1-2"))
464 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
465 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
468 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
469 .ServiceZEndBuilder getServiceZEndBuildReconfigure() {
470 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.reconfigure.input
471 .ServiceZEndBuilder()
472 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
473 .setNodeId(new NodeIdType("XPONDER-1-2"))
474 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
475 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
478 public static <T> ListenableFuture<T> returnFuture(T output) {
479 final ListeningExecutorService executor =
480 MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
481 return executor.submit(new Callable<T>() {
483 public T call() throws Exception {
489 private ServiceDataUtils() {