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 java.time.OffsetDateTime;
11 import java.time.ZoneOffset;
12 import java.time.format.DateTimeFormatter;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResult;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.ServicePathRpcResultBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.service.path.rpc.result.PathDescription;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.service.path.rpc.result.PathDescriptionBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInputBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
39 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirectionBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
41 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirectionBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.RpcStatusEx;
43 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.ServicePathNotificationTypes;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
46 public final class ServiceDataUtils {
48 public static ServiceCreateInput buildServiceCreateInput() {
50 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder();
51 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
52 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
54 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
55 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service
56 .create.input.ServiceZEndBuilder()
57 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
58 .setTxDirection(getTxDirection())
59 .setRxDirection(getRxDirection())
62 builtInput.setCommonId("commonId");
63 builtInput.setConnectionType(ConnectionType.Service);
64 builtInput.setCustomer("Customer");
65 builtInput.setServiceName("service 1");
66 builtInput.setServiceAEnd(serviceAEnd);
67 builtInput.setServiceZEnd(serviceZEnd);
68 builtInput.setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
69 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build());
71 return builtInput.build();
74 public static TempServiceCreateInput buildTempServiceCreateInput() {
76 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder();
77 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
78 .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
79 .temp.service.create.input.ServiceAEndBuilder()
80 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
81 .setTxDirection(getTxDirection())
82 .setRxDirection(getRxDirection())
84 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.create.input
85 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp
86 .service.create.input.ServiceZEndBuilder()
87 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-3-2")
88 .setTxDirection(getTxDirection())
89 .setRxDirection(getRxDirection())
92 builtInput.setCommonId("commonId");
93 builtInput.setConnectionType(ConnectionType.Service);
94 builtInput.setCustomer("Customer");
95 builtInput.setServiceAEnd(serviceAEnd);
96 builtInput.setServiceZEnd(serviceZEnd);
97 builtInput.setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
98 .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
100 return builtInput.build();
103 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
104 .ServiceAEndBuilder getServiceAEndBuild() {
105 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
106 .ServiceAEndBuilder()
107 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
108 .setTxDirection(getTxDirection())
109 .setRxDirection(getRxDirection());
112 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
113 .ServiceZEndBuilder getServiceZEndBuild() {
114 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
115 .ServiceZEndBuilder()
116 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
117 .setTxDirection(getTxDirection())
118 .setRxDirection(getRxDirection());
121 private static TxDirection getTxDirection() {
122 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
123 .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
124 .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
125 .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
126 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
127 .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
131 private static RxDirection getRxDirection() {
132 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
133 .endpoint.RxDirectionBuilder()
134 .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
135 .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
136 .setPortSubSlot("port subslot").setPortType("port type").build())
137 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
138 .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
139 .setLgxPortShelf("lgx port shelf").build())
143 public static ServiceDeleteInput buildServiceDeleteInput() {
144 ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
145 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
146 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
147 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
148 deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("service 1")
149 .setDueDate(datetime).setTailRetention(ServiceDeleteReqInfo.TailRetention.No).build());
150 SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder();
151 sdncBuilder.setNotificationUrl("notification url");
152 sdncBuilder.setRequestId("request 1");
153 sdncBuilder.setRequestSystemId("request system 1");
154 sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
155 deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
156 return deleteInputBldr.build();
159 public static TempServiceDeleteInput buildTempServiceDeleteInput() {
160 TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder();
161 deleteInputBldr.setCommonId("service 1");
162 return deleteInputBldr.build();
165 public static ServiceRerouteInput buildServiceRerouteInput() {
166 ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder();
167 builder.setServiceName("service 1");
168 return builder.build();
171 public static ServicePathRpcResult buildServicePathRpcResult() {
172 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
173 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
174 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
175 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
176 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
177 .setPathDescription(createPathDescription(0,1, 0, 1))
178 .setServiceName("service 1")
179 .setStatus(RpcStatusEx.Successful).setStatusMessage("success");
180 return builder.build();
183 public static ServicePathRpcResult buildFailedServicePathRpcResult() {
184 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
185 OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
186 DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
187 ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
188 builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
189 .setPathDescription(createPathDescription(0,1, 0, 1))
190 .setServiceName("service 1")
191 .setStatus(RpcStatusEx.Failed).setStatusMessage("success");
192 return builder.build();
195 private static PathDescription createPathDescription(long azRate, long azWaveLength, long zaRate,
197 AToZDirection atozDirection = new AToZDirectionBuilder()
199 .setAToZWavelengthNumber(azWaveLength)
202 ZToADirection ztoaDirection = new ZToADirectionBuilder()
204 .setZToAWavelengthNumber(zaWaveLength)
207 PathDescription pathDescription = new PathDescriptionBuilder()
208 .setAToZDirection(atozDirection)
209 .setZToADirection(ztoaDirection)
211 return pathDescription;
214 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
215 .ServiceAEndBuilder getServiceAEndBuildReconfigure() {
216 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
217 .ServiceAEndBuilder()
218 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
219 .setTxDirection(getTxDirection())
220 .setRxDirection(getRxDirection());
223 public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
224 .ServiceZEndBuilder getServiceZEndBuildReconfigure() {
225 return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
226 .ServiceZEndBuilder()
227 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
228 .setTxDirection(getTxDirection())
229 .setRxDirection(getRxDirection());
232 private ServiceDataUtils() {