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;
16 import java.util.concurrent.Callable;
17 import java.util.concurrent.Executors;
18 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInputBuilder;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.ServicePathRpcResult;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.ServicePathRpcResultBuilder;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescription;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescriptionBuilder;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSpBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultShBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeader;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraintsBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraintsBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput.Option;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.feasibility.check.inputs.ServiceAEnd;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.feasibility.check.inputs.ServiceAEndBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.feasibility.check.inputs.ServiceZEnd;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.feasibility.check.inputs.ServiceZEndBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirection;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirection;
68 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder;
73 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
74 import org.opendaylight.yangtools.yang.common.Uint32;
76 public final class ServiceDataUtils {
78 public static ServiceCreateInput buildServiceCreateInput() {
80 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
81 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
83 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
84 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service
85 .create.input.ServiceZEndBuilder()
86 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
87 .setNodeId(new NodeIdType("XPONDER-3-2"))
88 .setTxDirection(getTxDirection())
89 .setRxDirection(getRxDirection())
92 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
93 .setCommonId("commonId")
94 .setConnectionType(ConnectionType.Service)
95 .setCustomer("Customer")
96 .setServiceName("service 1")
97 .setServiceAEnd(serviceAEnd)
98 .setServiceZEnd(serviceZEnd)
99 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
100 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build());
102 return builtInput.build();
105 public static ServiceCreateInput buildServiceCreateInputWithHardConstraints() {
107 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
108 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
110 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
111 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service
112 .create.input.ServiceZEndBuilder()
113 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
114 .setNodeId(new NodeIdType("XPONDER-3-2"))
115 .setTxDirection(getTxDirection())
116 .setRxDirection(getRxDirection())
119 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
120 .setCommonId("commonId")
121 .setConnectionType(ConnectionType.Service)
122 .setCustomer("Customer")
123 .setServiceName("service 1")
124 .setServiceAEnd(serviceAEnd)
125 .setServiceZEnd(serviceZEnd)
126 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
127 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
128 .setHardConstraints(new HardConstraintsBuilder().build());
130 return builtInput.build();
133 public static ServiceCreateInput buildServiceCreateInputWithSoftConstraints() {
135 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
136 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
138 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
139 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service
140 .create.input.ServiceZEndBuilder()
141 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
142 .setNodeId(new NodeIdType("XPONDER-3-2"))
143 .setTxDirection(getTxDirection())
144 .setRxDirection(getRxDirection())
147 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
148 .setCommonId("commonId")
149 .setConnectionType(ConnectionType.Service)
150 .setCustomer("Customer")
151 .setServiceName("service 1")
152 .setServiceAEnd(serviceAEnd)
153 .setServiceZEnd(serviceZEnd)
154 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
155 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
156 .setSoftConstraints(new SoftConstraintsBuilder().build());
158 return builtInput.build();
161 public static PathComputationRequestInput createPceRequestInput(ServiceCreateInput input) {
162 ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
163 SdncRequestHeader serviceHandler = input.getSdncRequestHeader();
164 if (serviceHandler != null) {
165 serviceHandlerHeader.setRequestId(serviceHandler.getRequestId());
167 return new PathComputationRequestInputBuilder()
168 .setServiceName(input.getServiceName())
169 .setResourceReserve(true)
170 .setServiceHandlerHeader(serviceHandlerHeader.build())
171 .setHardConstraints(input.getHardConstraints())
172 .setSoftConstraints(input.getSoftConstraints())
173 .setPceRoutingMetric(PceMetric.TEMetric)
174 .setServiceAEnd(ModelMappingUtils.createServiceAEnd(input.getServiceAEnd()))
175 .setServiceZEnd(ModelMappingUtils.createServiceZEnd(input.getServiceZEnd()))
179 public static TempServiceCreateInput buildTempServiceCreateInput() {
181 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.create.input
182 .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531
183 .temp.service.create.input.ServiceAEndBuilder()
184 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
185 .setNodeId(new NodeIdType("XPONDER-1-2"))
186 .setTxDirection(getTxDirection())
187 .setRxDirection(getRxDirection())
189 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp.service.create.input
190 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.temp
191 .service.create.input.ServiceZEndBuilder()
192 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
193 .setNodeId(new NodeIdType("XPONDER-3-2"))
194 .setTxDirection(getTxDirection())
195 .setRxDirection(getRxDirection())
198 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder()
199 .setCommonId("commonId")
200 .setConnectionType(ConnectionType.Service)
201 .setCustomer("Customer")
202 .setServiceAEnd(serviceAEnd)
203 .setServiceZEnd(serviceZEnd)
204 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
205 .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
207 return builtInput.build();
210 public static ServiceFeasibilityCheckInput buildServiceFeasibilityCheckInput() {
212 ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
213 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
214 .setNodeId(new NodeIdType("XPONDER-1-2"))
215 .setTxDirection(getTxDirection()).setRxDirection(getRxDirection()).build();
216 ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
217 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
218 .setNodeId(new NodeIdType("XPONDER-3-2"))
219 .setTxDirection(getTxDirection()).setRxDirection(getRxDirection()).build();
221 ServiceFeasibilityCheckInputBuilder builtInput = new ServiceFeasibilityCheckInputBuilder()
222 .setCommonId("commonId")
223 .setConnectionType(ConnectionType.Service)
224 .setCustomer("Customer")
225 .setServiceAEnd(serviceAEnd)
226 .setServiceZEnd(serviceZEnd)
227 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
228 .setRpcAction(RpcActions.ServiceFeasibilityCheck).setNotificationUrl("notification url").build());
229 return builtInput.build();
232 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
233 .ServiceAEndBuilder getServiceAEndBuild() {
234 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
235 .ServiceAEndBuilder()
236 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
237 .setNodeId(new NodeIdType("XPONDER-1-2"))
238 .setTxDirection(getTxDirection())
239 .setRxDirection(getRxDirection());
242 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
243 .ServiceZEndBuilder getServiceZEndBuild() {
244 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input
245 .ServiceZEndBuilder()
246 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
247 .setNodeId(new NodeIdType("XPONDER-1-2"))
248 .setTxDirection(getTxDirection())
249 .setRxDirection(getRxDirection());
252 private static TxDirection getTxDirection() {
253 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
254 .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
255 .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
256 .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
257 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
258 .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
262 private static RxDirection getRxDirection() {
263 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
264 .endpoint.RxDirectionBuilder()
265 .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
266 .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
267 .setPortSubSlot("port subslot").setPortType("port type").build())
268 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
269 .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
270 .setLgxPortShelf("lgx port shelf").build())
274 public static ServiceDeleteInput buildServiceDeleteInput() {
276 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
277 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
278 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
279 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
280 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("service 1")
281 .setDueDate(datetime).setTailRetention(ServiceDeleteReqInfo.TailRetention.No).build());
282 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
283 .setNotificationUrl("notification url")
284 .setRequestId("request 1")
285 .setRequestSystemId("request system 1")
286 .setRpcAction(RpcActions.ServiceDelete);
287 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
288 return deleteInputBldr.build();
291 public static TempServiceDeleteInput buildTempServiceDeleteInput() {
292 TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
293 .setCommonId("service 1");
294 return deleteInputBldr.build();
297 public static TempServiceDeleteInput buildTempServiceDeleteInput(String commonId) {
298 TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
299 .setCommonId(commonId);
300 return deleteInputBldr.build();
303 public static ServiceRerouteInput buildServiceRerouteInput() {
304 ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder()
305 .setServiceName("service 1");
306 return builder.build();
309 public static ServiceRestorationInput buildServiceRestorationInput() {
310 ServiceRestorationInputBuilder builder = new ServiceRestorationInputBuilder()
311 .setServiceName("service 1")
312 .setOption(Option.Permanent);
313 return builder.build();
316 public static ServiceReconfigureInput buildServiceReconfigureInput() {
318 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
319 .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service
320 .reconfigure.input.ServiceAEndBuilder()
321 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
322 .setNodeId(new NodeIdType("XPONDER-1-2")).setTxDirection(getTxDirection())
323 .setRxDirection(getRxDirection())
325 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
326 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service
327 .reconfigure.input.ServiceZEndBuilder()
328 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
329 .setNodeId(new NodeIdType("XPONDER-3-2")).setTxDirection(getTxDirection())
330 .setRxDirection(getRxDirection())
333 ServiceReconfigureInputBuilder builtInput = new ServiceReconfigureInputBuilder()
334 .setCommonId("commonId")
335 .setConnectionType(ConnectionType.Service)
336 .setCustomer("Customer")
337 .setServiceName("service 1")
338 .setServiceAEnd(serviceAEnd)
339 .setServiceZEnd(serviceZEnd);
340 return builtInput.build();
343 public static ServicePathRpcResult buildServicePathRpcResult() {
344 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
345 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
346 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
347 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
348 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
349 .setPathDescription(createPathDescription(0,1, 0, 1))
350 .setServiceName("service 1")
351 .setStatus(RpcStatusEx.Successful).setStatusMessage("success");
352 return builder.build();
355 public static ServicePathRpcResult buildServicePathRpcResult(
356 ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx,
357 String message, Boolean pathDescription) {
358 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
359 builder.setNotificationType(servicePathNotificationTypes)
360 .setServiceName(serviceName)
361 .setStatus(rpcStatusEx).setStatusMessage(message);
362 if (pathDescription) {
363 builder.setPathDescription(createPathDescription(0L, 5L, 0L, 5L));
365 return builder.build();
368 public static ServicePathRpcResult buildFailedPceServicePathRpcResult() {
369 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
370 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
371 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
372 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
373 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
374 .setPathDescription(createPathDescription(0, 1, 0, 1)).setServiceName("service 1")
375 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
376 return builder.build();
379 public static ServicePathRpcResult buildFailedServicePathRpcResult() {
380 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
381 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
382 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
383 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
384 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
385 .setPathDescription(createPathDescription(0,1, 0, 1))
386 .setServiceName("service 1")
387 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
388 return builder.build();
391 public static RendererRpcResultSp buildRendererRpcResultSp() {
392 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
393 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
394 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
395 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
396 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
397 .setServiceName("service 1").setStatus(RpcStatusEx.Successful).setStatusMessage("success");
398 return builder.build();
401 public static RendererRpcResultSp buildRendererRpcResultSp(
402 ServicePathNotificationTypes servicePathNotificationTypes,
403 String serviceName, RpcStatusEx rpcStatusEx, String message) {
404 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
405 builder.setNotificationType(servicePathNotificationTypes).setServiceName(serviceName)
406 .setStatus(rpcStatusEx).setStatusMessage(message);
407 return builder.build();
410 public static ServiceRpcResultSh buildServiceRpcResultSh(
411 ServiceNotificationTypes serviceNotificationTypes,
413 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx
416 ServiceRpcResultShBuilder builder = new ServiceRpcResultShBuilder();
417 builder.setNotificationType(serviceNotificationTypes).setServiceName(serviceName)
418 .setStatus(rpcStatusEx).setStatusMessage(message);
419 return builder.build();
422 public static RendererRpcResultSp buildFailedRendererRpcResultSp() {
423 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
424 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
425 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
426 RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
427 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
428 .setServiceName("service 1").setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
429 return builder.build();
432 public static PathDescription createPathDescription(long azRate, long azWaveLength, long zaRate,
434 AToZDirection atozDirection = new AToZDirectionBuilder()
435 .setRate(Uint32.valueOf(azRate))
436 .setAToZWavelengthNumber(Uint32.valueOf(azWaveLength))
438 ZToADirection ztoaDirection = new ZToADirectionBuilder()
439 .setRate(Uint32.valueOf(zaRate))
440 .setZToAWavelengthNumber(Uint32.valueOf(zaWaveLength))
442 PathDescription pathDescription = new PathDescriptionBuilder()
443 .setAToZDirection(atozDirection)
444 .setZToADirection(ztoaDirection)
446 return pathDescription;
449 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
450 .ServiceAEndBuilder getServiceAEndBuildReconfigure() {
451 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
452 .ServiceAEndBuilder()
453 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
454 .setNodeId(new NodeIdType("XPONDER-1-2"))
455 .setTxDirection(getTxDirection())
456 .setRxDirection(getRxDirection());
459 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
460 .ServiceZEndBuilder getServiceZEndBuildReconfigure() {
461 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.reconfigure.input
462 .ServiceZEndBuilder()
463 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
464 .setNodeId(new NodeIdType("XPONDER-1-2"))
465 .setTxDirection(getTxDirection())
466 .setRxDirection(getRxDirection());
469 public static <T> ListenableFuture<T> returnFuture(T output) {
470 final ListeningExecutorService executor =
471 MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
472 return executor.submit(new Callable<T>() {
474 public T call() throws Exception {
480 private ServiceDataUtils() {