2 * Copyright © 2018 Orange & 2021 Nokia, 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.tapi.connectivity;
10 import java.nio.charset.Charset;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Comparator;
14 import java.util.HashMap;
15 import java.util.List;
17 import java.util.Optional;
18 import java.util.UUID;
19 import java.util.stream.Collectors;
20 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
21 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
22 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
23 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
24 import org.opendaylight.transportpce.tapi.utils.TapiContext;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev181130.OpticTypes;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.Service;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.SubrateEthSlaBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.OTU4;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEnd;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEndBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEnd;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEndBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription;
46 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
47 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
48 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToA;
49 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToAKey;
50 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Node;
51 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
52 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.BandwidthProfileBuilder;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ProtectionRole;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ServiceType;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePoint;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePointBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionKey;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.CapacityBuilder;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.ConnectivityConstraint;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
90 import org.opendaylight.yangtools.yang.common.Uint16;
91 import org.opendaylight.yangtools.yang.common.Uint32;
92 import org.opendaylight.yangtools.yang.common.Uint64;
93 import org.slf4j.Logger;
94 import org.slf4j.LoggerFactory;
96 public final class ConnectivityUtils {
98 private static final String LGX_PORT_NAME = "Some lgx-port-name";
99 private static final String PORT_TYPE = "some port type";
100 private static final String LGX_DEVICE_NAME = "Some lgx-device-name";
101 private static final String PORT_RACK_VALUE = "000000.00";
102 private static final String DSR = "DSR";
103 private static final String ODU = "ODU";
104 private static final String E_ODU = "eODU";
105 private static final String I_ODU = "iODU";
106 private static final String OTSI = "OTSi";
107 private static final String E_OTSI = "eOTSi";
108 private static final String I_OTSI = "iOTSi";
109 private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA";
110 private static final String MC = "MEDIA_CHANNEL";
111 private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL";
112 private static final String TP = "TerminationPoint";
113 private static final String NODE = "Node";
114 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
115 .getBytes(Charset.forName("UTF-8"))).toString());
116 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
118 private final ServiceDataStoreOperations serviceDataStoreOperations;
119 private final TapiContext tapiContext;
120 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
121 private final Map<org.opendaylight.yang.gen.v1.urn
122 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
123 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
124 connectionFullMap; // this variable is for complete connection objects
125 private Map<String, Map<String, Boolean>> networkMap = new HashMap<>();
127 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
128 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
129 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext) {
130 this.serviceDataStoreOperations = serviceDataStoreOperations;
131 this.tapiContext = tapiContext;
132 this.sipMap = sipMap;
133 this.connectionFullMap = new HashMap<>();
136 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
137 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
138 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
139 if (serviceAEnd == null || serviceZEnd == null) {
140 LOG.warn("One of the endpoints could not be identified");
143 return new ServiceCreateInputBuilder()
144 .setCommonId("commonId")
145 .setConnectionType(ConnectionType.Service)
146 .setCustomer("Customer")
147 .setServiceName("service test")
148 .setServiceAEnd(serviceAEnd)
149 .setServiceZEnd(serviceZEnd)
150 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
151 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
157 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
158 String txPortName, String rxPortDeviceName, String rxPortName) {
159 return new ServiceAEndBuilder()
161 .setNodeId(new NodeIdType(nodeid))
162 .setOpticType(OpticTypes.Gray)
163 .setServiceFormat(ServiceFormat.Ethernet)
164 .setServiceRate(Uint32.valueOf(100))
165 .setTxDirection(new TxDirectionBuilder()
166 .setPort(new PortBuilder()
167 .setPortDeviceName(txPortDeviceName)
168 .setPortName(txPortName)
169 .setPortRack(PORT_RACK_VALUE)
171 .setPortType(PORT_TYPE)
173 .setLgx(new LgxBuilder()
174 .setLgxDeviceName(LGX_DEVICE_NAME)
175 .setLgxPortName(LGX_PORT_NAME)
176 .setLgxPortRack(PORT_RACK_VALUE)
177 .setLgxPortShelf("00")
180 .setRxDirection(new RxDirectionBuilder()
181 .setPort(new PortBuilder()
182 .setPortDeviceName(rxPortDeviceName)
183 .setPortName(rxPortName)
184 .setPortRack(PORT_RACK_VALUE)
186 .setPortType(PORT_TYPE)
188 .setLgx(new LgxBuilder()
189 .setLgxDeviceName(LGX_DEVICE_NAME)
190 .setLgxPortName(LGX_PORT_NAME)
191 .setLgxPortRack(PORT_RACK_VALUE)
192 .setLgxPortShelf("00")
198 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
199 String txPortName, String rxPortDeviceName, String rxPortName) {
200 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
201 .setOpticType(OpticTypes.Gray)
202 .setServiceFormat(ServiceFormat.Ethernet)
203 .setServiceRate(Uint32.valueOf(100))
204 .setTxDirection(new TxDirectionBuilder()
205 .setPort(new PortBuilder()
206 .setPortDeviceName(txPortDeviceName)
207 .setPortName(txPortName)
208 .setPortRack(PORT_RACK_VALUE)
210 .setPortType(PORT_TYPE)
212 .setLgx(new LgxBuilder()
213 .setLgxDeviceName(LGX_DEVICE_NAME)
214 .setLgxPortName(LGX_PORT_NAME)
215 .setLgxPortRack(PORT_RACK_VALUE)
216 .setLgxPortShelf("00")
219 .setRxDirection(new RxDirectionBuilder()
220 .setPort(new PortBuilder()
221 .setPortDeviceName(rxPortDeviceName)
222 .setPortName(rxPortName)
223 .setPortRack(PORT_RACK_VALUE)
225 .setPortType(PORT_TYPE)
227 .setLgx(new LgxBuilder()
228 .setLgxDeviceName(LGX_DEVICE_NAME)
229 .setLgxPortName(LGX_PORT_NAME)
230 .setLgxPortRack(PORT_RACK_VALUE)
231 .setLgxPortShelf("00")
237 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
238 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
239 return new ServiceAEndBuilder(sepA.getValue()).build();
240 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
241 return new ServiceAEndBuilder(sepZ.getValue()).build();
247 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
248 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
249 return new ServiceZEndBuilder(sepA.getValue()).build();
250 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
251 return new ServiceZEndBuilder(sepZ.getValue()).build();
257 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
261 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
262 // Get service path with the description in OR based models.
263 LOG.info("Service = {}", service);
264 Optional<ServicePaths> optServicePaths =
265 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
266 if (!optServicePaths.isPresent()) {
267 LOG.error("No service path found for service {}", service.getServiceName());
270 ServicePaths servicePaths = optServicePaths.get();
271 PathDescription pathDescription = servicePaths.getPathDescription();
272 LOG.info("Path description of service = {}", pathDescription);
273 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd
274 = service.getServiceAEnd();
276 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
277 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd
278 = service.getServiceZEnd();
279 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
280 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
281 endPointMap.put(endPoint1.key(), endPoint1);
282 endPointMap.put(endPoint2.key(), endPoint2);
283 LOG.info("EndPoints of connectivity services = {}", endPointMap);
285 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
287 // Connection creation
288 Map<ConnectionKey, Connection> connMap =
289 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
290 // TODO: full connectivity service?? With constraints and the rest of fields...
291 return new ConnectivityServiceBuilder()
292 .setAdministrativeState(AdministrativeState.UNLOCKED)
293 .setOperationalState(OperationalState.ENABLED)
294 .setLifecycleState(LifecycleState.INSTALLED)
295 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
297 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat()))
298 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
299 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
300 .setName(Map.of(name.key(), name))
301 .setConnection(connMap)
302 .setEndPoint(endPointMap)
306 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat) {
307 switch (serviceFormat) {
310 return LayerProtocolName.PHOTONICMEDIA;
312 return LayerProtocolName.ODU;
314 return LayerProtocolName.DSR;
316 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
321 private Map<ConnectionKey, Connection> createConnectionsFromService(
322 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
324 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
326 PathDescription pathDescription) {
327 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
328 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
329 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
330 // and the connections
332 List<String> xpdrClientTplist = new ArrayList<>();
333 List<String> xpdrNetworkTplist = new ArrayList<>();
334 List<String> rdmAddDropTplist = new ArrayList<>();
335 List<String> rdmDegTplist = new ArrayList<>();
336 List<String> rdmNodelist = new ArrayList<>();
337 List<String> xpdrNodelist = new ArrayList<>();
338 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
339 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
340 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
341 switch (resourceType) {
343 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
344 String tpID = tp.getTpId();
346 if (tpID.contains("CLIENT")) {
347 tpNode = tp.getTpNodeId();
348 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
349 xpdrClientTplist.add(String.join("+", tpNode, tpID));
352 if (tpID.contains("NETWORK")) {
353 tpNode = tp.getTpNodeId();
354 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
355 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
358 if (tpID.contains("PP")) {
359 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
360 LOG.info("ROADM Node of tp = {}", tpNode);
361 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
362 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
365 if (tpID.contains("TTP")) {
366 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
367 LOG.info("ROADM Node of tp = {}", tpNode);
368 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
369 rdmDegTplist.add(String.join("+", tpNode, tpID));
374 Node node = (Node) elem.getResource().getResource();
375 String nodeId = node.getNodeId();
376 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
377 LOG.info("Node id = {}", nodeId);
378 if (!xpdrNodelist.contains(nodeId)) {
379 xpdrNodelist.add(nodeId); // should contain only 2
382 if (nodeId.contains("ROADM")) {
383 nodeId = getIdBasedOnModelVersion(nodeId);
384 LOG.info("Node id = {}", nodeId);
385 if (!rdmNodelist.contains(nodeId)) {
386 rdmNodelist.add(nodeId);
391 LOG.warn("Resource is a {}", resourceType);
394 LOG.info("ROADM node list = {}", rdmNodelist);
395 LOG.info("ROADM degree list = {}", rdmDegTplist);
396 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
397 LOG.info("XPDR node list = {}", xpdrNodelist);
398 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
399 LOG.info("XPDR client list = {}", xpdrClientTplist);
400 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
401 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
402 // to trigger all the steps or not
403 String edgeRoadm1 = "";
404 String edgeRoadm2 = "";
405 if (!rdmNodelist.isEmpty()) {
406 edgeRoadm1 = rdmNodelist.get(0);
407 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
408 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
409 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
411 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
412 // CEPs must be included in the topology context as an augmentation for each ONEP!!
413 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
414 // TODO -> better mechanism to map services???
415 switch (serviceFormat) {
417 // Identify number of ROADMs
418 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
419 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
420 // - Top Connection MC betwwen MC CEPs of different roadms
421 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
422 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
423 edgeRoadm1, edgeRoadm2));
426 // Identify number of ROADMs between XPDRs and check if OC is created
427 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
428 // - Top Connection MC betwwen MC CEPs of different roadms
429 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
430 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
431 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
432 edgeRoadm1, edgeRoadm2));
433 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
434 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
435 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
438 // Check if OC and OTU are created
439 if (!rdmNodelist.isEmpty()) {
440 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
441 edgeRoadm1, edgeRoadm2));
442 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
444 // - XC Connection OTSi betwwen iODU and eODU of xpdr
445 // - Top connection in the ODU layer, between xpdr eODU ports (?)
446 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
449 // Check if OC, OTU and ODU are created
450 if (!rdmNodelist.isEmpty()) {
451 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
452 edgeRoadm1, edgeRoadm2));
453 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
454 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
456 // Top connection in the DSR layer, between client ports of the xpdrs
457 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNodelist));
460 LOG.error("Service type format not supported");
462 return connectionServMap;
465 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
466 List<String> xpdrNodelist) {
467 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
468 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
469 ConnectionEndPoint> cepMap = new HashMap<>();
471 // Create 1 cep per Xpdr in the CLIENT and a top connection DSR between the CLIENT xpdrs
472 for (String xpdr:xpdrNodelist) {
473 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
474 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
476 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, DSR, DSR, LayerProtocolName.DSR);
477 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, DSR, DSR, netCep1);
479 cepMap.put(netCep1.key(), netCep1);
482 // DSR top connection between edge xpdr CLIENT DSR
483 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
484 .get(0))).findFirst().get();
485 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
486 .get(xpdrNodelist.size() - 1))).findFirst().get();
487 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
488 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, DSR, LayerProtocolName.DSR);
489 this.connectionFullMap.put(connection.key(), connection);
491 // ODU top connection that will be added to the service object
492 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
493 connServMap.put(conn.key(), conn);
498 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
499 List<String> xpdrNodelist) {
500 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
501 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
502 ConnectionEndPoint> cepMap = new HashMap<>();
503 // Create 1 cep per Xpdr in the I_ODU and E_ODU, X connection between iODU and eODU and a top
504 // connection iODU between the xpdrs
505 for (String xpdr:xpdrNodelist) {
506 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
507 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
509 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, E_ODU, DSR, LayerProtocolName.ODU);
510 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_ODU, DSR, netCep1);
511 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, I_ODU, DSR, LayerProtocolName.ODU);
512 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_ODU, DSR, netCep2);
514 cepMap.put(netCep1.key(), netCep1);
515 cepMap.put(netCep2.key(), netCep2);
517 // Create x connection between I_ODU and E_ODU within xpdr
518 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
519 connection = createXCBetweenCeps(netCep1, netCep2, spcXpdrNetwork, spcXpdrNetwork, ODU,
520 LayerProtocolName.ODU);
521 this.connectionFullMap.put(connection.key(), connection);
523 // Create X connection that will be added to the service object
524 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
525 connServMap.put(conn.key(), conn);
528 // ODU top connection between edge xpdr e_ODU
529 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
530 .get(0))).findFirst().get();
531 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
532 .get(xpdrNodelist.size() - 1))).findFirst().get();
533 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
534 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, E_ODU, LayerProtocolName.ODU);
535 this.connectionFullMap.put(connection.key(), connection);
537 // ODU top connection that will be added to the service object
538 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
539 connServMap.put(conn.key(), conn);
544 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
545 List<String> xpdrNodelist) {
546 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
547 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
548 ConnectionEndPoint> cepMap = new HashMap<>();
550 // create ceps and x connections within xpdr
551 for (String xpdr:xpdrNodelist) {
552 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
553 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
554 // There should be 1 network tp per xpdr
555 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
556 // 3 different MC CEPs giving different IDs to show that they are different
557 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
558 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, PHTNC_MEDIA, OTSI,
559 LayerProtocolName.PHOTONICMEDIA);
560 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, PHTNC_MEDIA, OTSI, netCep1);
561 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, E_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA);
562 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_OTSI, OTSI, netCep2);
563 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, I_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA);
564 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_OTSI, OTSI, netCep3);
565 cepMap.put(netCep1.key(), netCep1);
566 cepMap.put(netCep2.key(), netCep2);
567 cepMap.put(netCep3.key(), netCep3);
569 // Create x connection between I_OTSi and E_OTSi within xpdr
570 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
571 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork, OTSI,
572 LayerProtocolName.PHOTONICMEDIA);
573 this.connectionFullMap.put(connection.key(), connection);
575 // Create X connection that will be added to the service object
576 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
577 connServMap.put(conn.key(), conn);
579 // OTSi top connection between edge I_OTSI Xpdr
580 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
581 .get(0))).findFirst().get();
582 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
583 .get(xpdrNodelist.size() - 1))).findFirst().get();
584 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
585 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, I_OTSI, LayerProtocolName.PHOTONICMEDIA);
586 this.connectionFullMap.put(connection.key(), connection);
588 // OTSi top connection that will be added to the service object
589 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
590 connServMap.put(conn.key(), conn);
596 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
597 List<String> rdmDegTplist,
598 List<String> rdmNodelist,
599 String edgeRoadm1, String edgeRoadm2) {
600 // TODO: will need to check if things exist already or not
601 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
602 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
603 ConnectionEndPoint> cepMap = new HashMap<>();
604 // create ceps and x connections within roadm
605 for (String roadm : rdmNodelist) {
606 LOG.info("Creating ceps and xc for roadm {}", roadm);
607 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
608 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
609 // There should be only 1 AD and 1 DEG per roadm
610 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
611 // 3 different MC CEPs giving different IDs to show that they are different
612 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
613 // created in the topology creation
614 // add CEPs to the topology to the corresponding ONEP
615 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, PHTNC_MEDIA);
616 putRdmCepInTopologyContext(roadm, spcRdmAD, PHTNC_MEDIA, adCep1);
617 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, MC);
618 putRdmCepInTopologyContext(roadm, spcRdmAD, MC, adCep2);
619 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, OTSI_MC);
620 putRdmCepInTopologyContext(roadm, spcRdmAD, OTSI_MC, adCep3);
621 cepMap.put(adCep1.key(), adCep1);
622 cepMap.put(adCep2.key(), adCep2);
623 cepMap.put(adCep3.key(), adCep3);
625 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
626 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
628 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, PHTNC_MEDIA);
629 putRdmCepInTopologyContext(roadm, spcRdmDEG, PHTNC_MEDIA, degCep1);
630 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, MC);
631 putRdmCepInTopologyContext(roadm, spcRdmDEG, MC, degCep2);
632 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, OTSI_MC);
633 putRdmCepInTopologyContext(roadm, spcRdmDEG, OTSI_MC, degCep3);
634 cepMap.put(degCep1.key(), degCep1);
635 cepMap.put(degCep2.key(), degCep2);
636 cepMap.put(degCep3.key(), degCep3);
638 LOG.info("Going to create cross connections for ROADM {}", roadm);
639 // Create X connections between MC and OTSi_MC for full map
640 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
641 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, MC,
642 LayerProtocolName.PHOTONICMEDIA);
643 LOG.info("Cross connection 1 created = {}", connection1);
644 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
645 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, OTSI_MC,
646 LayerProtocolName.PHOTONICMEDIA);
647 LOG.info("Cross connection 2 created = {}", connection2);
648 this.connectionFullMap.put(connection1.key(), connection1);
649 this.connectionFullMap.put(connection2.key(), connection2);
651 // Create X connections that will be added to the service object
652 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
653 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
654 connServMap.put(conn1.key(), conn1);
655 connServMap.put(conn2.key(), conn2);
657 LOG.info("Going to create top connections betwee roadms");
658 // create top connections between roadms: MC connections between AD MC CEPs of roadms
659 for (int i = 0; i < rdmNodelist.size(); i++) {
660 if (rdmNodelist.size() <= (i + 1)) {
661 LOG.info("Reached last roadm. No more MC connections");
664 // Current roadm with roadm i + 1 --> MC
665 String roadm1 = rdmNodelist.get(i);
666 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
667 String roadm2 = rdmNodelist.get(i + 1);
668 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
669 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
671 // Create top connections between MC for full map
672 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
673 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, MC, LayerProtocolName.PHOTONICMEDIA);
674 this.connectionFullMap.put(connection.key(), connection);
675 LOG.info("Top connection created = {}", connection);
677 // Create top connections that will be added to the service object
678 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
679 connServMap.put(conn.key(), conn);
682 // OTSiMC top connection between edge roadms
683 LOG.info("Going to created top connection between OTSiMC");
684 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
685 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
686 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
687 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, OTSI_MC,
688 LayerProtocolName.PHOTONICMEDIA);
689 this.connectionFullMap.put(connection.key(), connection);
690 LOG.info("Top connection created = {}", connection);
692 // OTSiMC top connections that will be added to the service object
693 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
694 connServMap.put(conn.key(), conn);
698 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
699 createTopConnection(String tp1, String tp2,
700 Map<org.opendaylight.yang.gen.v1.urn
701 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
702 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol) {
703 // find cep for each AD MC of roadm 1 and 2
704 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
705 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
706 cepMap.get(new org.opendaylight.yang.gen.v1.urn
707 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
708 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
709 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
711 LOG.info("ADCEP1 = {}", adCep1);
712 org.opendaylight.yang.gen.v1.urn
713 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
714 new org.opendaylight.yang.gen.v1.urn
715 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
716 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
717 .values().stream().findFirst().get().getNodeEdgePointUuid())
718 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
719 .values().stream().findFirst().get().getTopologyUuid())
720 .setNodeUuid(adCep1.getClientNodeEdgePoint()
721 .values().stream().findFirst().get().getNodeUuid())
722 .setConnectionEndPointUuid(adCep1.getUuid())
724 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
725 cepMap.get(new org.opendaylight.yang.gen.v1.urn
726 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
727 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
728 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
730 LOG.info("ADCEP2 = {}", adCep2);
731 org.opendaylight.yang.gen.v1.urn
732 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
733 new org.opendaylight.yang.gen.v1.urn
734 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
735 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
736 .values().stream().findFirst().get().getNodeEdgePointUuid())
737 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
738 .values().stream().findFirst().get().getTopologyUuid())
739 .setNodeUuid(adCep2.getClientNodeEdgePoint()
740 .values().stream().findFirst().get().getNodeUuid())
741 .setConnectionEndPointUuid(adCep1.getUuid())
743 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
744 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
745 ceps.put(cep1.key(), cep1);
746 ceps.put(cep2.key(), cep2);
747 Name connName = new NameBuilder()
748 .setValueName("Connection name")
749 .setValue(String.join("+", "TOP", tp1, tp2, qual))
751 // TODO: lower connection, supported link.......
752 return new org.opendaylight.yang.gen.v1.urn
753 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
754 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
755 .getBytes(Charset.forName("UTF-8"))).toString()))
756 .setName(Map.of(connName.key(), connName))
757 .setConnectionEndPoint(ceps)
758 .setOperationalState(OperationalState.ENABLED)
759 .setLayerProtocolName(topPortocol)
760 .setLifecycleState(LifecycleState.INSTALLED)
761 .setDirection(ForwardingDirection.BIDIRECTIONAL)
765 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
766 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
767 LayerProtocolName xcProtocol) {
768 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
769 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
770 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
771 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
772 org.opendaylight.yang.gen.v1.urn
773 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
774 new org.opendaylight.yang.gen.v1.urn
775 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
776 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
777 .values().stream().findFirst().get().getNodeEdgePointUuid())
778 .setTopologyUuid(cep1.getClientNodeEdgePoint()
779 .values().stream().findFirst().get().getTopologyUuid())
780 .setNodeUuid(cep1.getClientNodeEdgePoint()
781 .values().stream().findFirst().get().getNodeUuid())
782 .setConnectionEndPointUuid(cep1.getUuid())
784 org.opendaylight.yang.gen.v1.urn
785 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
786 new org.opendaylight.yang.gen.v1.urn
787 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
788 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
789 .values().stream().findFirst().get().getNodeEdgePointUuid())
790 .setTopologyUuid(cep2.getClientNodeEdgePoint()
791 .values().stream().findFirst().get().getTopologyUuid())
792 .setNodeUuid(cep2.getClientNodeEdgePoint()
793 .values().stream().findFirst().get().getNodeUuid())
794 .setConnectionEndPointUuid(cep2.getUuid())
796 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
797 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
798 ceps.put(cepServ1.key(), cepServ1);
799 ceps.put(cepServ2.key(), cepServ2);
800 Name connName = new NameBuilder()
801 .setValueName("Connection name")
802 .setValue(String.join("+", "XC", tp1, tp2, qual))
804 // TODO: lower connection, supported link.......
805 return new org.opendaylight.yang.gen.v1.urn
806 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
807 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
808 .getBytes(Charset.forName("UTF-8"))).toString()))
809 .setName(Map.of(connName.key(), connName))
810 .setConnectionEndPoint(ceps)
811 .setOperationalState(OperationalState.ENABLED)
812 .setLayerProtocolName(xcProtocol)
813 .setLifecycleState(LifecycleState.INSTALLED)
814 .setDirection(ForwardingDirection.BIDIRECTIONAL)
818 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
819 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
820 Name cepName = new NameBuilder()
821 .setValueName("ConnectionEndPoint name")
822 .setValue(String.join("+", id.split("\\+")[0], qualifier,
825 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
826 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
827 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
829 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
830 qualifier)).getBytes(Charset.forName("UTF-8")))
832 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
833 .getBytes(Charset.forName("UTF-8"))).toString()))
835 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
836 // TODO: add parent ONEP??
837 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
838 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
839 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
841 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
842 .setName(Map.of(cepName.key(), cepName))
843 .setConnectionPortRole(PortRole.SYMMETRIC)
844 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
845 .setOperationalState(OperationalState.ENABLED)
846 .setLifecycleState(LifecycleState.INSTALLED)
847 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
848 return cepBldr.build();
851 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
852 LayerProtocolName cepProtocol) {
853 Name cepName = new NameBuilder()
854 .setValueName("ConnectionEndPoint name")
855 .setValue(String.join("+", id.split("\\+")[0], qualifier,
858 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
859 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
860 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
862 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
863 nodeLayer)).getBytes(Charset.forName("UTF-8")))
865 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
866 .getBytes(Charset.forName("UTF-8"))).toString()))
868 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
869 // TODO: add parent ONEP??
870 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
871 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
872 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
874 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
875 .setName(Map.of(cepName.key(), cepName))
876 .setConnectionPortRole(PortRole.SYMMETRIC)
877 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
878 .setOperationalState(OperationalState.ENABLED)
879 .setLifecycleState(LifecycleState.INSTALLED)
880 .setLayerProtocolName(cepProtocol);
881 return cepBldr.build();
884 private EndPoint mapServiceZEndPoint(
885 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
886 serviceZEnd, PathDescription pathDescription) {
887 EndPointBuilder endPointBuilder = new EndPointBuilder();
888 // 1. Service Format: ODU, OTU, ETH
889 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
890 String serviceNodeId = serviceZEnd.getNodeId().getValue();
892 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
893 LOG.info("Uuid of z end {}", sipUuid);
894 LayerProtocolName layerProtocols = null;
895 // Layer protocol name
896 switch (serviceFormat) {
898 layerProtocols = LayerProtocolName.DSR;
902 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
905 layerProtocols = LayerProtocolName.ODU;
908 LOG.error("Service Format not supported");
910 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
911 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
912 .setValueName("OpenROADM info")
913 .setValue(String.join("-", serviceZEnd.getClli(),
914 serviceZEnd.getTxDirection().getPort().getPortDeviceName(),
915 serviceZEnd.getTxDirection().getPort().getPortName()))
917 return endPointBuilder
918 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
919 .setServiceInterfacePointUuid(sipUuid)
921 .setName(Map.of(name.key(), name))
922 .setAdministrativeState(AdministrativeState.UNLOCKED)
923 .setDirection(PortDirection.BIDIRECTIONAL)
924 .setLifecycleState(LifecycleState.INSTALLED)
925 .setOperationalState(OperationalState.ENABLED)
926 .setLayerProtocolName(layerProtocols)
927 .setCapacity(new CapacityBuilder()
928 .setTotalSize(new TotalSizeBuilder()
929 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
930 .setUnit(CapacityUnit.GBPS)
932 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
934 .setProtectionRole(ProtectionRole.WORK)
935 .setRole(PortRole.SYMMETRIC)
936 .setLocalId(serviceNodeId)
940 private EndPoint mapServiceAEndPoint(
941 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
942 serviceAEnd, PathDescription pathDescription) {
943 EndPointBuilder endPointBuilder = new EndPointBuilder();
944 // 1. Service Format: ODU, OTU, ETH
945 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
946 String serviceNodeId = serviceAEnd.getNodeId().getValue();
948 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
949 LOG.info("Uuid of a end {}", sipUuid);
950 LayerProtocolName layerProtocols = null;
951 // Layer protocol name
952 switch (serviceFormat) {
954 layerProtocols = LayerProtocolName.DSR;
958 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
961 layerProtocols = LayerProtocolName.ODU;
964 LOG.error("Service Format not supported");
966 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
967 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
968 .setValueName("OpenROADM info")
969 .setValue(String.join("-", serviceAEnd.getClli(),
970 serviceAEnd.getTxDirection().getPort().getPortDeviceName(),
971 serviceAEnd.getTxDirection().getPort().getPortName()))
973 return endPointBuilder
974 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
975 .setServiceInterfacePointUuid(sipUuid)
977 .setName(Map.of(name.key(), name))
978 .setAdministrativeState(AdministrativeState.UNLOCKED)
979 .setDirection(PortDirection.BIDIRECTIONAL)
980 .setLifecycleState(LifecycleState.INSTALLED)
981 .setOperationalState(OperationalState.ENABLED)
982 .setLayerProtocolName(layerProtocols)
983 .setCapacity(new CapacityBuilder()
984 .setTotalSize(new TotalSizeBuilder()
985 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
986 .setUnit(CapacityUnit.GBPS)
988 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
990 .setProtectionRole(ProtectionRole.WORK)
991 .setRole(PortRole.SYMMETRIC)
992 .setLocalId(serviceNodeId)
996 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
997 Uuid zendUuid = null;
998 if (serviceNodeId.contains("ROADM")) {
999 // Service from ROADM to ROADM
1000 // AddDrop-AddDrop ports --> MC layer SIPs
1001 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1002 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1003 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1004 tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1006 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId()));
1007 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1008 if (!sip.getUuid().equals(sipUuid)) {
1009 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1012 zendUuid = sip.getUuid();
1016 // Service from XPDR to XPDR
1018 TerminationPoint tp;
1020 switch (serviceFormat) {
1022 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1023 tp = (TerminationPoint) firstElement.getResource().getResource();
1024 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1025 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1026 tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1028 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId()));
1031 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1032 tp = (TerminationPoint) firstElement.getResource().getResource();
1033 // Network-Network ports --> iOTSi layer SIPs
1034 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1035 tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1037 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId()));
1040 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1041 tp = (TerminationPoint) firstElement.getResource().getResource();
1042 // Client-client ports --> DSR layer SIPs
1043 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1044 tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1046 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId()));
1050 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1052 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1053 if (!sip.getUuid().equals(sipUuid)) {
1054 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1057 zendUuid = sip.getUuid();
1064 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1065 Uuid aendUuid = null;
1066 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1067 LOG.info("Map a to z = {}", mapatoz);
1068 if (serviceNodeId.contains("ROADM")) {
1069 // Service from ROADM to ROADM
1070 // AddDrop-AddDrop ports --> MC layer SIPs
1071 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1072 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1073 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1074 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1075 tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1077 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId()));
1078 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1079 if (!sip.getUuid().equals(sipUuid)) {
1080 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1083 aendUuid = sip.getUuid();
1087 // Service from XPDR to XPDR
1089 TerminationPoint tp;
1091 switch (serviceFormat) {
1093 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1094 tp = (TerminationPoint) firstElement.getResource().getResource();
1095 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1096 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1097 tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1099 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId()));
1102 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1103 tp = (TerminationPoint) firstElement.getResource().getResource();
1104 // Network-Network ports --> iOTSi layer SIPs
1105 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1106 tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1108 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId()));
1111 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1112 tp = (TerminationPoint) firstElement.getResource().getResource();
1113 // Client-client ports --> DSR layer SIPs
1114 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1115 tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1117 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId()));
1121 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1123 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1124 if (!sip.getUuid().equals(sipUuid)) {
1125 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1128 aendUuid = sip.getUuid();
1135 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1136 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1137 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, PHTNC_MEDIA));
1138 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1139 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
1140 .getBytes(Charset.forName("UTF-8"))).toString());
1141 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, PHTNC_MEDIA)
1142 .getBytes(Charset.forName("UTF-8"))).toString());
1143 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1144 .getBytes(Charset.forName("UTF-8"))).toString());
1145 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1148 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1149 ConnectionEndPoint cep) {
1150 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1151 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
1152 .getBytes(Charset.forName("UTF-8"))).toString());
1153 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1154 .getBytes(Charset.forName("UTF-8"))).toString());
1155 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1156 .getBytes(Charset.forName("UTF-8"))).toString());
1157 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1160 public Map<org.opendaylight.yang.gen.v1.urn
1161 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1162 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1163 getConnectionFullMap() {
1164 return this.connectionFullMap;
1167 private String getIdBasedOnModelVersion(String nodeid) {
1168 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
1169 : nodeid.split("-")[0];
1172 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1173 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1174 Map<org.opendaylight.yang.gen.v1.urn
1175 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1176 org.opendaylight.yang.gen.v1.urn
1177 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1178 endPointMap = input.getEndPoint();
1179 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1180 ConnectionType connType = null;
1181 ServiceFormat serviceFormat = null;
1182 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(), DSR);
1183 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(), DSR);
1184 LOG.debug("Node a = {}", nodeAid);
1185 LOG.debug("Node z = {}", nodeZid);
1186 switch (constraint.getServiceLayer().getIntValue()) {
1189 connType = ConnectionType.Infrastructure;
1190 serviceFormat = ServiceFormat.ODU;
1194 connType = ConnectionType.Service;
1195 serviceFormat = ServiceFormat.Ethernet;
1198 LOG.info("PHOTONIC");
1199 connType = getConnectionTypePhtnc(endPointMap.values());
1200 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1201 if (serviceFormat.equals(ServiceFormat.OC)) {
1202 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1204 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1207 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(), OTSI);
1208 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1211 LOG.debug("Node a photonic = {}", nodeAid);
1212 LOG.debug("Node z photonic = {}", nodeZid);
1215 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1217 // Requested Capacity for connectivity service
1218 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1219 // map endpoints into service end points. Map the type of service from TAPI to OR
1220 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1221 serviceFormat, nodeAid, capacity);
1222 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1223 serviceFormat, nodeZid, capacity);
1224 if (serviceAEnd == null || serviceZEnd == null) {
1225 LOG.error("Couldnt map endpoints to service end");
1228 LOG.info("Service a end = {}", serviceAEnd);
1229 LOG.info("Service z end = {}", serviceZEnd);
1230 return new ServiceCreateInputBuilder()
1231 .setServiceAEnd(serviceAEnd)
1232 .setServiceZEnd(serviceZEnd)
1233 .setConnectionType(connType)
1234 .setServiceName(serviceUuid.getValue())
1235 .setCommonId("common id")
1236 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1237 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1238 .setRequestSystemId("appname")
1240 .setCustomer("customer")
1241 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1242 .setOperatorContact("pw1234")
1246 private ServiceZEnd tapiEndPointToServiceZPoint(
1247 org.opendaylight.yang.gen.v1.urn
1248 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1249 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity) {
1250 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1251 // Not the rest which is needed in the txPortDeviceName.
1252 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1253 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1254 // Todo -> need to find the NEP associated to that SIP
1255 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString());
1256 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1257 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1259 LOG.error("Node not found in datastore");
1262 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1263 // connection is between 2 CLIENT ports. Otherwise it will not work...
1264 OwnedNodeEdgePoint nep = null;
1265 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1266 if (onep.getMappedServiceInterfacePoint() == null) {
1269 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1275 LOG.error("Nep not found in datastore");
1278 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1279 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1280 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1281 String txPortDeviceName = nepName.split("\\+")[0];
1282 String txPortName = nepName.split("\\+")[2];
1283 String rxPortDeviceName = txPortDeviceName;
1284 String rxPortName = txPortName;
1285 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1286 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1287 if (serviceFormat.equals(ServiceFormat.ODU)) {
1288 // TODO --> populate network map
1289 populateNetworkMap(nodeid, txPortName);
1291 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1292 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1293 // Set boolean to true and update txportName and so on
1294 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1295 if (updTxName != null) {
1296 txPortName = updTxName;
1297 rxPortName = txPortName;
1300 // TODO --> get clli from datastore?
1301 String clli = "NodeSC";
1302 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1303 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1304 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1306 .setNodeId(new NodeIdType(nodeid))
1307 .setOpticType(OpticTypes.Gray)
1308 .setServiceFormat(serviceFormat)
1309 .setServiceRate(Uint32.valueOf(capacity))
1310 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(
1311 new org.opendaylight.yang.gen.v1.http
1312 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1313 .setCommittedBurstSize(Uint16.valueOf(64))
1314 .setCommittedInfoRate(Uint32.valueOf(100000))
1317 .setTxDirection(new TxDirectionBuilder()
1318 .setPort(new PortBuilder()
1319 .setPortDeviceName(txPortDeviceName)
1320 .setPortName(txPortName)
1321 .setPortRack(PORT_RACK_VALUE)
1323 .setPortType(PORT_TYPE)
1325 .setLgx(new LgxBuilder()
1326 .setLgxDeviceName(LGX_DEVICE_NAME)
1327 .setLgxPortName(LGX_PORT_NAME)
1328 .setLgxPortRack(PORT_RACK_VALUE)
1329 .setLgxPortShelf("00")
1332 .setRxDirection(new RxDirectionBuilder()
1333 .setPort(new PortBuilder()
1334 .setPortDeviceName(rxPortDeviceName)
1335 .setPortName(rxPortName)
1336 .setPortRack(PORT_RACK_VALUE)
1338 .setPortType(PORT_TYPE)
1340 .setLgx(new LgxBuilder()
1341 .setLgxDeviceName(LGX_DEVICE_NAME)
1342 .setLgxPortName(LGX_PORT_NAME)
1343 .setLgxPortRack(PORT_RACK_VALUE)
1344 .setLgxPortShelf("00")
1347 if (serviceFormat.equals(ServiceFormat.ODU)) {
1348 serviceZEndBuilder.setOduServiceRate(ODU4.class);
1350 if (serviceFormat.equals(ServiceFormat.OTU)) {
1351 serviceZEndBuilder.setOtuServiceRate(OTU4.class);
1353 return serviceZEndBuilder.build();
1356 private ServiceAEnd tapiEndPointToServiceAPoint(
1357 org.opendaylight.yang.gen.v1.urn
1358 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1359 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity) {
1360 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1361 // Not the rest which is needed in the txPortDeviceName.
1362 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1363 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1364 // Todo -> need to find the NEP associated to that SIP
1365 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString());
1366 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1367 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1369 LOG.error("Node not found in datastore");
1372 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1373 // connection is between 2 CLIENT ports. Otherwise it will not work...
1374 OwnedNodeEdgePoint nep = null;
1375 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1376 if (onep.getMappedServiceInterfacePoint() == null) {
1379 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1385 LOG.error("Nep not found in datastore");
1388 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1389 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1390 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1391 String txPortDeviceName = nepName.split("\\+")[0];
1392 String txPortName = nepName.split("\\+")[2];
1393 String rxPortDeviceName = txPortDeviceName;
1394 String rxPortName = txPortName;
1395 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1396 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1397 if (serviceFormat.equals(ServiceFormat.ODU)) {
1398 // TODO --> populate network map
1399 populateNetworkMap(nodeid, txPortName);
1401 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1402 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1403 // Set boolean to true and update txportName and so on
1404 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1405 if (updTxName != null) {
1406 txPortName = updTxName;
1407 rxPortName = txPortName;
1410 // TODO --> get clli from datastore?
1411 String clli = "NodeSA";
1412 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1413 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1414 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1416 .setNodeId(new NodeIdType(nodeid))
1417 .setOpticType(OpticTypes.Gray)
1418 .setServiceFormat(serviceFormat)
1419 .setServiceRate(Uint32.valueOf(capacity))
1420 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(
1421 new org.opendaylight.yang.gen.v1.http
1422 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1423 .setCommittedBurstSize(Uint16.valueOf(64))
1424 .setCommittedInfoRate(Uint32.valueOf(100000))
1427 .setTxDirection(new TxDirectionBuilder()
1428 .setPort(new PortBuilder()
1429 .setPortDeviceName(txPortDeviceName)
1430 .setPortName(txPortName)
1431 .setPortRack(PORT_RACK_VALUE)
1433 .setPortType(PORT_TYPE)
1435 .setLgx(new LgxBuilder()
1436 .setLgxDeviceName(LGX_DEVICE_NAME)
1437 .setLgxPortName(LGX_PORT_NAME)
1438 .setLgxPortRack(PORT_RACK_VALUE)
1439 .setLgxPortShelf("00")
1442 .setRxDirection(new RxDirectionBuilder()
1443 .setPort(new PortBuilder()
1444 .setPortDeviceName(rxPortDeviceName)
1445 .setPortName(rxPortName)
1446 .setPortRack(PORT_RACK_VALUE)
1448 .setPortType(PORT_TYPE)
1450 .setLgx(new LgxBuilder()
1451 .setLgxDeviceName(LGX_DEVICE_NAME)
1452 .setLgxPortName(LGX_PORT_NAME)
1453 .setLgxPortRack(PORT_RACK_VALUE)
1454 .setLgxPortShelf("00")
1457 if (serviceFormat.equals(ServiceFormat.ODU)) {
1458 serviceAEndBuilder.setOduServiceRate(ODU4.class);
1460 if (serviceFormat.equals(ServiceFormat.OTU)) {
1461 serviceAEndBuilder.setOtuServiceRate(OTU4.class);
1463 return serviceAEndBuilder.build();
1466 private String findFreeConfiguredNetworkPort(String nodeid) {
1467 if (!this.networkMap.containsKey(nodeid)) {
1470 Map<String, Boolean> netMap = this.networkMap.get(nodeid);
1471 for (Map.Entry<String, Boolean> entry : netMap.entrySet()) {
1472 if (!entry.getValue()) {
1473 this.networkMap.get(nodeid).put(entry.getKey(), true);
1474 return entry.getKey();
1480 private void populateNetworkMap(String nodeid, String txPortName) {
1481 Map<String, Boolean> netMap = new HashMap<>();
1482 netMap.put(txPortName, false);
1483 if (!this.networkMap.containsKey(nodeid)) {
1484 this.networkMap.put(nodeid, netMap);
1485 } else if (!this.networkMap.get(nodeid).containsKey(txPortName)) {
1486 this.networkMap.get(nodeid).putAll(netMap);
1490 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1491 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1492 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1493 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1494 // EndPoints are ROADMs
1495 return ConnectionType.RoadmLine;
1497 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1498 return ConnectionType.Infrastructure;
1501 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1502 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1503 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1504 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1505 // EndPoints are ROADMs
1506 return ServiceFormat.OC;
1508 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1509 return ServiceFormat.OTU;