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.TapiStringConstants;
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 final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
99 .getBytes(Charset.forName("UTF-8"))).toString());
100 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
102 private final ServiceDataStoreOperations serviceDataStoreOperations;
103 private final TapiContext tapiContext;
104 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
105 private final Map<org.opendaylight.yang.gen.v1.urn
106 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
107 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
108 connectionFullMap; // this variable is for complete connection objects
109 private Map<String, Map<String, Boolean>> networkMap = new HashMap<>();
111 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
112 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
113 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext) {
114 this.serviceDataStoreOperations = serviceDataStoreOperations;
115 this.tapiContext = tapiContext;
116 this.sipMap = sipMap;
117 this.connectionFullMap = new HashMap<>();
120 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
121 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
122 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
123 if (serviceAEnd == null || serviceZEnd == null) {
124 LOG.warn("One of the endpoints could not be identified");
127 return new ServiceCreateInputBuilder()
128 .setCommonId("commonId")
129 .setConnectionType(ConnectionType.Service)
130 .setCustomer("Customer")
131 .setServiceName("service test")
132 .setServiceAEnd(serviceAEnd)
133 .setServiceZEnd(serviceZEnd)
134 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
135 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
141 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
142 String txPortName, String rxPortDeviceName, String rxPortName) {
143 return new ServiceAEndBuilder()
145 .setNodeId(new NodeIdType(nodeid))
146 .setOpticType(OpticTypes.Gray)
147 .setServiceFormat(ServiceFormat.Ethernet)
148 .setServiceRate(Uint32.valueOf(100))
149 .setTxDirection(new TxDirectionBuilder()
150 .setPort(new PortBuilder()
151 .setPortDeviceName(txPortDeviceName)
152 .setPortName(txPortName)
153 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
155 .setPortType(TapiStringConstants.PORT_TYPE)
157 .setLgx(new LgxBuilder()
158 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
159 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
160 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
161 .setLgxPortShelf("00")
164 .setRxDirection(new RxDirectionBuilder()
165 .setPort(new PortBuilder()
166 .setPortDeviceName(rxPortDeviceName)
167 .setPortName(rxPortName)
168 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
170 .setPortType(TapiStringConstants.PORT_TYPE)
172 .setLgx(new LgxBuilder()
173 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
174 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
175 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
176 .setLgxPortShelf("00")
182 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
183 String txPortName, String rxPortDeviceName, String rxPortName) {
184 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
185 .setOpticType(OpticTypes.Gray)
186 .setServiceFormat(ServiceFormat.Ethernet)
187 .setServiceRate(Uint32.valueOf(100))
188 .setTxDirection(new TxDirectionBuilder()
189 .setPort(new PortBuilder()
190 .setPortDeviceName(txPortDeviceName)
191 .setPortName(txPortName)
192 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
194 .setPortType(TapiStringConstants.PORT_TYPE)
196 .setLgx(new LgxBuilder()
197 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
198 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
199 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
200 .setLgxPortShelf("00")
203 .setRxDirection(new RxDirectionBuilder()
204 .setPort(new PortBuilder()
205 .setPortDeviceName(rxPortDeviceName)
206 .setPortName(rxPortName)
207 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
209 .setPortType(TapiStringConstants.PORT_TYPE)
211 .setLgx(new LgxBuilder()
212 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
213 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
214 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
215 .setLgxPortShelf("00")
221 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
222 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
223 return new ServiceAEndBuilder(sepA.getValue()).build();
224 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
225 return new ServiceAEndBuilder(sepZ.getValue()).build();
231 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
232 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
233 return new ServiceZEndBuilder(sepA.getValue()).build();
234 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
235 return new ServiceZEndBuilder(sepZ.getValue()).build();
241 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
245 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
246 // Get service path with the description in OR based models.
247 LOG.info("Service = {}", service);
248 Optional<ServicePaths> optServicePaths =
249 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
250 if (!optServicePaths.isPresent()) {
251 LOG.error("No service path found for service {}", service.getServiceName());
254 ServicePaths servicePaths = optServicePaths.get();
255 PathDescription pathDescription = servicePaths.getPathDescription();
256 LOG.info("Path description of service = {}", pathDescription);
257 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd
258 = service.getServiceAEnd();
260 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
261 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd
262 = service.getServiceZEnd();
263 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
264 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
265 endPointMap.put(endPoint1.key(), endPoint1);
266 endPointMap.put(endPoint2.key(), endPoint2);
267 LOG.info("EndPoints of connectivity services = {}", endPointMap);
269 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
271 // Connection creation
272 Map<ConnectionKey, Connection> connMap =
273 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
274 // TODO: full connectivity service?? With constraints and the rest of fields...
275 return new ConnectivityServiceBuilder()
276 .setAdministrativeState(AdministrativeState.UNLOCKED)
277 .setOperationalState(OperationalState.ENABLED)
278 .setLifecycleState(LifecycleState.INSTALLED)
279 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
281 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat()))
282 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
283 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
284 .setName(Map.of(name.key(), name))
285 .setConnection(connMap)
286 .setEndPoint(endPointMap)
290 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat) {
291 switch (serviceFormat) {
294 return LayerProtocolName.PHOTONICMEDIA;
296 return LayerProtocolName.ODU;
298 return LayerProtocolName.DSR;
300 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
305 private Map<ConnectionKey, Connection> createConnectionsFromService(
306 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
308 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
310 PathDescription pathDescription) {
311 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
312 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
313 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
314 // and the connections
316 List<String> xpdrClientTplist = new ArrayList<>();
317 List<String> xpdrNetworkTplist = new ArrayList<>();
318 List<String> rdmAddDropTplist = new ArrayList<>();
319 List<String> rdmDegTplist = new ArrayList<>();
320 List<String> rdmNodelist = new ArrayList<>();
321 List<String> xpdrNodelist = new ArrayList<>();
322 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
323 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
324 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
325 switch (resourceType) {
326 case TapiStringConstants.TP:
327 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
328 String tpID = tp.getTpId();
330 if (tpID.contains("CLIENT")) {
331 tpNode = tp.getTpNodeId();
332 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
333 xpdrClientTplist.add(String.join("+", tpNode, tpID));
336 if (tpID.contains("NETWORK")) {
337 tpNode = tp.getTpNodeId();
338 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
339 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
342 if (tpID.contains("PP")) {
343 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
344 LOG.info("ROADM Node of tp = {}", tpNode);
345 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
346 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
349 if (tpID.contains("TTP")) {
350 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
351 LOG.info("ROADM Node of tp = {}", tpNode);
352 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
353 rdmDegTplist.add(String.join("+", tpNode, tpID));
357 case TapiStringConstants.NODE:
358 Node node = (Node) elem.getResource().getResource();
359 String nodeId = node.getNodeId();
360 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
361 LOG.info("Node id = {}", nodeId);
362 if (!xpdrNodelist.contains(nodeId)) {
363 xpdrNodelist.add(nodeId); // should contain only 2
366 if (nodeId.contains("ROADM")) {
367 nodeId = getIdBasedOnModelVersion(nodeId);
368 LOG.info("Node id = {}", nodeId);
369 if (!rdmNodelist.contains(nodeId)) {
370 rdmNodelist.add(nodeId);
375 LOG.warn("Resource is a {}", resourceType);
378 LOG.info("ROADM node list = {}", rdmNodelist);
379 LOG.info("ROADM degree list = {}", rdmDegTplist);
380 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
381 LOG.info("XPDR node list = {}", xpdrNodelist);
382 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
383 LOG.info("XPDR client list = {}", xpdrClientTplist);
384 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
385 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
386 // to trigger all the steps or not
387 String edgeRoadm1 = "";
388 String edgeRoadm2 = "";
389 if (!rdmNodelist.isEmpty()) {
390 edgeRoadm1 = rdmNodelist.get(0);
391 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
392 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
393 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
395 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
396 // CEPs must be included in the topology context as an augmentation for each ONEP!!
397 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
398 // TODO -> better mechanism to map services???
399 switch (serviceFormat) {
401 // Identify number of ROADMs
402 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
403 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
404 // - Top Connection MC betwwen MC CEPs of different roadms
405 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
406 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
407 edgeRoadm1, edgeRoadm2));
410 // Identify number of ROADMs between XPDRs and check if OC is created
411 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
412 // - Top Connection MC betwwen MC CEPs of different roadms
413 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
414 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
415 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
416 edgeRoadm1, edgeRoadm2));
417 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
418 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
419 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
422 // Check if OC and OTU are created
423 if (!rdmNodelist.isEmpty()) {
424 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
425 edgeRoadm1, edgeRoadm2));
426 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
428 // - XC Connection OTSi betwwen iODU and eODU of xpdr
429 // - Top connection in the ODU layer, between xpdr eODU ports (?)
430 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
433 // Check if OC, OTU and ODU are created
434 if (!rdmNodelist.isEmpty()) {
435 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
436 edgeRoadm1, edgeRoadm2));
437 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
438 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
440 // Top connection in the DSR layer, between client ports of the xpdrs
441 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNodelist));
444 LOG.error("Service type format not supported");
446 return connectionServMap;
449 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
450 List<String> xpdrNodelist) {
451 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
452 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
453 ConnectionEndPoint> cepMap = new HashMap<>();
455 // Create 1 cep per Xpdr in the CLIENT and a top connection DSR between the CLIENT xpdrs
456 for (String xpdr:xpdrNodelist) {
457 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
458 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
460 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
461 LayerProtocolName.DSR);
462 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
464 cepMap.put(netCep1.key(), netCep1);
467 // DSR top connection between edge xpdr CLIENT DSR
468 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
469 .get(0))).findFirst().get();
470 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
471 .get(xpdrNodelist.size() - 1))).findFirst().get();
472 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
473 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.DSR,
474 LayerProtocolName.DSR);
475 this.connectionFullMap.put(connection.key(), connection);
477 // ODU top connection that will be added to the service object
478 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
479 connServMap.put(conn.key(), conn);
484 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
485 List<String> xpdrNodelist) {
486 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
487 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
488 ConnectionEndPoint> cepMap = new HashMap<>();
489 // Create 1 cep per Xpdr in the I_ODU and E_ODU, X connection between iODU and eODU and a top
490 // connection iODU between the xpdrs
491 for (String xpdr:xpdrNodelist) {
492 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
493 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
495 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_ODU,
496 TapiStringConstants.DSR, LayerProtocolName.ODU);
497 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_ODU, TapiStringConstants.DSR,
499 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
500 TapiStringConstants.DSR, LayerProtocolName.ODU);
501 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
504 cepMap.put(netCep1.key(), netCep1);
505 cepMap.put(netCep2.key(), netCep2);
507 // Create x connection between I_ODU and E_ODU within xpdr
508 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
509 connection = createXCBetweenCeps(netCep1, netCep2, spcXpdrNetwork, spcXpdrNetwork,
510 TapiStringConstants.ODU, LayerProtocolName.ODU);
511 this.connectionFullMap.put(connection.key(), connection);
513 // Create X connection that will be added to the service object
514 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
515 connServMap.put(conn.key(), conn);
518 // ODU top connection between edge xpdr e_ODU
519 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
520 .get(0))).findFirst().get();
521 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
522 .get(xpdrNodelist.size() - 1))).findFirst().get();
523 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
524 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.E_ODU,
525 LayerProtocolName.ODU);
526 this.connectionFullMap.put(connection.key(), connection);
528 // ODU top connection that will be added to the service object
529 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
530 connServMap.put(conn.key(), conn);
535 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
536 List<String> xpdrNodelist) {
537 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
538 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
539 ConnectionEndPoint> cepMap = new HashMap<>();
541 // create ceps and x connections within xpdr
542 for (String xpdr:xpdrNodelist) {
543 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
544 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
545 // There should be 1 network tp per xpdr
546 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
547 // 3 different MC CEPs giving different IDs to show that they are different
548 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
549 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA,
550 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
551 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.OTSI,
553 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_OTSI,
554 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
555 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_OTSI, TapiStringConstants.OTSI,
557 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
558 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
559 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
561 cepMap.put(netCep1.key(), netCep1);
562 cepMap.put(netCep2.key(), netCep2);
563 cepMap.put(netCep3.key(), netCep3);
565 // Create x connection between I_OTSi and E_OTSi within xpdr
566 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
567 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork,
568 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
569 this.connectionFullMap.put(connection.key(), connection);
571 // Create X connection that will be added to the service object
572 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
573 connServMap.put(conn.key(), conn);
575 // OTSi top connection between edge I_OTSI Xpdr
576 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
577 .get(0))).findFirst().get();
578 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
579 .get(xpdrNodelist.size() - 1))).findFirst().get();
580 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
581 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
582 LayerProtocolName.PHOTONICMEDIA);
583 this.connectionFullMap.put(connection.key(), connection);
585 // OTSi top connection that will be added to the service object
586 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
587 connServMap.put(conn.key(), conn);
593 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
594 List<String> rdmDegTplist,
595 List<String> rdmNodelist,
596 String edgeRoadm1, String edgeRoadm2) {
597 // TODO: will need to check if things exist already or not
598 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
599 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
600 ConnectionEndPoint> cepMap = new HashMap<>();
601 // create ceps and x connections within roadm
602 for (String roadm : rdmNodelist) {
603 LOG.info("Creating ceps and xc for roadm {}", roadm);
604 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
605 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
606 // There should be only 1 AD and 1 DEG per roadm
607 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
608 // 3 different MC CEPs giving different IDs to show that they are different
609 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
610 // created in the topology creation
611 // add CEPs to the topology to the corresponding ONEP
612 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA);
613 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA, adCep1);
614 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
615 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
616 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
617 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
618 cepMap.put(adCep1.key(), adCep1);
619 cepMap.put(adCep2.key(), adCep2);
620 cepMap.put(adCep3.key(), adCep3);
622 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
623 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
625 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
626 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA, degCep1);
627 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
628 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
629 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
630 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
631 cepMap.put(degCep1.key(), degCep1);
632 cepMap.put(degCep2.key(), degCep2);
633 cepMap.put(degCep3.key(), degCep3);
635 LOG.info("Going to create cross connections for ROADM {}", roadm);
636 // Create X connections between MC and OTSi_MC for full map
637 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
638 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
639 LayerProtocolName.PHOTONICMEDIA);
640 LOG.info("Cross connection 1 created = {}", connection1);
641 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
642 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
643 LayerProtocolName.PHOTONICMEDIA);
644 LOG.info("Cross connection 2 created = {}", connection2);
645 this.connectionFullMap.put(connection1.key(), connection1);
646 this.connectionFullMap.put(connection2.key(), connection2);
648 // Create X connections that will be added to the service object
649 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
650 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
651 connServMap.put(conn1.key(), conn1);
652 connServMap.put(conn2.key(), conn2);
654 LOG.info("Going to create top connections betwee roadms");
655 // create top connections between roadms: MC connections between AD MC CEPs of roadms
656 for (int i = 0; i < rdmNodelist.size(); i++) {
657 if (rdmNodelist.size() <= (i + 1)) {
658 LOG.info("Reached last roadm. No more MC connections");
661 // Current roadm with roadm i + 1 --> MC
662 String roadm1 = rdmNodelist.get(i);
663 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
664 String roadm2 = rdmNodelist.get(i + 1);
665 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
666 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
668 // Create top connections between MC for full map
669 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
670 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
671 LayerProtocolName.PHOTONICMEDIA);
672 this.connectionFullMap.put(connection.key(), connection);
673 LOG.info("Top connection created = {}", connection);
675 // Create top connections that will be added to the service object
676 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
677 connServMap.put(conn.key(), conn);
680 // OTSiMC top connection between edge roadms
681 LOG.info("Going to created top connection between OTSiMC");
682 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
683 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
684 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
685 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
686 LayerProtocolName.PHOTONICMEDIA);
687 this.connectionFullMap.put(connection.key(), connection);
688 LOG.info("Top connection created = {}", connection);
690 // OTSiMC top connections that will be added to the service object
691 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
692 connServMap.put(conn.key(), conn);
696 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
697 createTopConnection(String tp1, String tp2,
698 Map<org.opendaylight.yang.gen.v1.urn
699 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
700 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol) {
701 // find cep for each AD MC of roadm 1 and 2
702 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
703 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
704 cepMap.get(new org.opendaylight.yang.gen.v1.urn
705 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
706 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
707 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
709 LOG.info("ADCEP1 = {}", adCep1);
710 org.opendaylight.yang.gen.v1.urn
711 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
712 new org.opendaylight.yang.gen.v1.urn
713 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
714 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
715 .values().stream().findFirst().get().getNodeEdgePointUuid())
716 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
717 .values().stream().findFirst().get().getTopologyUuid())
718 .setNodeUuid(adCep1.getClientNodeEdgePoint()
719 .values().stream().findFirst().get().getNodeUuid())
720 .setConnectionEndPointUuid(adCep1.getUuid())
722 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
723 cepMap.get(new org.opendaylight.yang.gen.v1.urn
724 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
725 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
726 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
728 LOG.info("ADCEP2 = {}", adCep2);
729 org.opendaylight.yang.gen.v1.urn
730 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
731 new org.opendaylight.yang.gen.v1.urn
732 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
733 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
734 .values().stream().findFirst().get().getNodeEdgePointUuid())
735 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
736 .values().stream().findFirst().get().getTopologyUuid())
737 .setNodeUuid(adCep2.getClientNodeEdgePoint()
738 .values().stream().findFirst().get().getNodeUuid())
739 .setConnectionEndPointUuid(adCep1.getUuid())
741 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
742 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
743 ceps.put(cep1.key(), cep1);
744 ceps.put(cep2.key(), cep2);
745 Name connName = new NameBuilder()
746 .setValueName("Connection name")
747 .setValue(String.join("+", "TOP", tp1, tp2, qual))
749 // TODO: lower connection, supported link.......
750 return new org.opendaylight.yang.gen.v1.urn
751 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
752 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
753 .getBytes(Charset.forName("UTF-8"))).toString()))
754 .setName(Map.of(connName.key(), connName))
755 .setConnectionEndPoint(ceps)
756 .setOperationalState(OperationalState.ENABLED)
757 .setLayerProtocolName(topPortocol)
758 .setLifecycleState(LifecycleState.INSTALLED)
759 .setDirection(ForwardingDirection.BIDIRECTIONAL)
763 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
764 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
765 LayerProtocolName xcProtocol) {
766 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
767 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
768 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
769 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
770 org.opendaylight.yang.gen.v1.urn
771 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
772 new org.opendaylight.yang.gen.v1.urn
773 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
774 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
775 .values().stream().findFirst().get().getNodeEdgePointUuid())
776 .setTopologyUuid(cep1.getClientNodeEdgePoint()
777 .values().stream().findFirst().get().getTopologyUuid())
778 .setNodeUuid(cep1.getClientNodeEdgePoint()
779 .values().stream().findFirst().get().getNodeUuid())
780 .setConnectionEndPointUuid(cep1.getUuid())
782 org.opendaylight.yang.gen.v1.urn
783 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
784 new org.opendaylight.yang.gen.v1.urn
785 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
786 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
787 .values().stream().findFirst().get().getNodeEdgePointUuid())
788 .setTopologyUuid(cep2.getClientNodeEdgePoint()
789 .values().stream().findFirst().get().getTopologyUuid())
790 .setNodeUuid(cep2.getClientNodeEdgePoint()
791 .values().stream().findFirst().get().getNodeUuid())
792 .setConnectionEndPointUuid(cep2.getUuid())
794 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
795 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
796 ceps.put(cepServ1.key(), cepServ1);
797 ceps.put(cepServ2.key(), cepServ2);
798 Name connName = new NameBuilder()
799 .setValueName("Connection name")
800 .setValue(String.join("+", "XC", tp1, tp2, qual))
802 // TODO: lower connection, supported link.......
803 return new org.opendaylight.yang.gen.v1.urn
804 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
805 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
806 .getBytes(Charset.forName("UTF-8"))).toString()))
807 .setName(Map.of(connName.key(), connName))
808 .setConnectionEndPoint(ceps)
809 .setOperationalState(OperationalState.ENABLED)
810 .setLayerProtocolName(xcProtocol)
811 .setLifecycleState(LifecycleState.INSTALLED)
812 .setDirection(ForwardingDirection.BIDIRECTIONAL)
816 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
817 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
818 Name cepName = new NameBuilder()
819 .setValueName("ConnectionEndPoint name")
820 .setValue(String.join("+", id.split("\\+")[0], qualifier,
823 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
824 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
825 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
827 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
828 qualifier)).getBytes(Charset.forName("UTF-8")))
830 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
831 .getBytes(Charset.forName("UTF-8"))).toString()))
833 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
834 // TODO: add parent ONEP??
835 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
836 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
837 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
839 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
840 .setName(Map.of(cepName.key(), cepName))
841 .setConnectionPortRole(PortRole.SYMMETRIC)
842 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
843 .setOperationalState(OperationalState.ENABLED)
844 .setLifecycleState(LifecycleState.INSTALLED)
845 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
846 return cepBldr.build();
849 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
850 LayerProtocolName cepProtocol) {
851 Name cepName = new NameBuilder()
852 .setValueName("ConnectionEndPoint name")
853 .setValue(String.join("+", id.split("\\+")[0], qualifier,
856 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
857 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
858 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
860 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
861 nodeLayer)).getBytes(Charset.forName("UTF-8")))
863 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
864 .getBytes(Charset.forName("UTF-8"))).toString()))
866 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
867 // TODO: add parent ONEP??
868 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
869 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
870 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
872 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
873 .setName(Map.of(cepName.key(), cepName))
874 .setConnectionPortRole(PortRole.SYMMETRIC)
875 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
876 .setOperationalState(OperationalState.ENABLED)
877 .setLifecycleState(LifecycleState.INSTALLED)
878 .setLayerProtocolName(cepProtocol);
879 return cepBldr.build();
882 private EndPoint mapServiceZEndPoint(
883 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
884 serviceZEnd, PathDescription pathDescription) {
885 EndPointBuilder endPointBuilder = new EndPointBuilder();
886 // 1. Service Format: ODU, OTU, ETH
887 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
888 String serviceNodeId = serviceZEnd.getNodeId().getValue();
890 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
891 LOG.info("Uuid of z end {}", sipUuid);
892 LayerProtocolName layerProtocols = null;
893 // Layer protocol name
894 switch (serviceFormat) {
896 layerProtocols = LayerProtocolName.DSR;
900 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
903 layerProtocols = LayerProtocolName.ODU;
906 LOG.error("Service Format not supported");
908 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
909 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
910 .setValueName("OpenROADM info")
911 .setValue(String.join("-", serviceZEnd.getClli(),
912 serviceZEnd.getTxDirection().getPort().getPortDeviceName(),
913 serviceZEnd.getTxDirection().getPort().getPortName()))
915 return endPointBuilder
916 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
917 .setServiceInterfacePointUuid(sipUuid)
919 .setName(Map.of(name.key(), name))
920 .setAdministrativeState(AdministrativeState.UNLOCKED)
921 .setDirection(PortDirection.BIDIRECTIONAL)
922 .setLifecycleState(LifecycleState.INSTALLED)
923 .setOperationalState(OperationalState.ENABLED)
924 .setLayerProtocolName(layerProtocols)
925 .setCapacity(new CapacityBuilder()
926 .setTotalSize(new TotalSizeBuilder()
927 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
928 .setUnit(CapacityUnit.GBPS)
930 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
932 .setProtectionRole(ProtectionRole.WORK)
933 .setRole(PortRole.SYMMETRIC)
934 .setLocalId(serviceNodeId)
938 private EndPoint mapServiceAEndPoint(
939 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
940 serviceAEnd, PathDescription pathDescription) {
941 EndPointBuilder endPointBuilder = new EndPointBuilder();
942 // 1. Service Format: ODU, OTU, ETH
943 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
944 String serviceNodeId = serviceAEnd.getNodeId().getValue();
946 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
947 LOG.info("Uuid of a end {}", sipUuid);
948 LayerProtocolName layerProtocols = null;
949 // Layer protocol name
950 switch (serviceFormat) {
952 layerProtocols = LayerProtocolName.DSR;
956 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
959 layerProtocols = LayerProtocolName.ODU;
962 LOG.error("Service Format not supported");
964 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
965 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
966 .setValueName("OpenROADM info")
967 .setValue(String.join("-", serviceAEnd.getClli(),
968 serviceAEnd.getTxDirection().getPort().getPortDeviceName(),
969 serviceAEnd.getTxDirection().getPort().getPortName()))
971 return endPointBuilder
972 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
973 .setServiceInterfacePointUuid(sipUuid)
975 .setName(Map.of(name.key(), name))
976 .setAdministrativeState(AdministrativeState.UNLOCKED)
977 .setDirection(PortDirection.BIDIRECTIONAL)
978 .setLifecycleState(LifecycleState.INSTALLED)
979 .setOperationalState(OperationalState.ENABLED)
980 .setLayerProtocolName(layerProtocols)
981 .setCapacity(new CapacityBuilder()
982 .setTotalSize(new TotalSizeBuilder()
983 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
984 .setUnit(CapacityUnit.GBPS)
986 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
988 .setProtectionRole(ProtectionRole.WORK)
989 .setRole(PortRole.SYMMETRIC)
990 .setLocalId(serviceNodeId)
994 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
995 Uuid zendUuid = null;
996 if (serviceNodeId.contains("ROADM")) {
997 // Service from ROADM to ROADM
998 // AddDrop-AddDrop ports --> MC layer SIPs
999 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1000 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1001 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1002 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1004 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1005 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1006 if (!sip.getUuid().equals(sipUuid)) {
1007 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1010 zendUuid = sip.getUuid();
1014 // Service from XPDR to XPDR
1016 TerminationPoint tp;
1018 switch (serviceFormat) {
1020 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1021 tp = (TerminationPoint) firstElement.getResource().getResource();
1022 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1023 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1024 tp.getTpNodeId(), TapiStringConstants.E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1026 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.E_ODU,
1030 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1031 tp = (TerminationPoint) firstElement.getResource().getResource();
1032 // Network-Network ports --> iOTSi layer SIPs
1033 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1034 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1036 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
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(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1046 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1051 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1053 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1054 if (!sip.getUuid().equals(sipUuid)) {
1055 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1058 zendUuid = sip.getUuid();
1065 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1066 Uuid aendUuid = null;
1067 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1068 LOG.info("Map a to z = {}", mapatoz);
1069 if (serviceNodeId.contains("ROADM")) {
1070 // Service from ROADM to ROADM
1071 // AddDrop-AddDrop ports --> MC layer SIPs
1072 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1073 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1074 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1075 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1076 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1078 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1080 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1081 if (!sip.getUuid().equals(sipUuid)) {
1082 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1085 aendUuid = sip.getUuid();
1089 // Service from XPDR to XPDR
1091 TerminationPoint tp;
1093 switch (serviceFormat) {
1095 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1096 tp = (TerminationPoint) firstElement.getResource().getResource();
1097 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1098 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1099 tp.getTpNodeId(), TapiStringConstants.E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1101 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1102 TapiStringConstants.E_ODU, tp.getTpId()));
1105 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1106 tp = (TerminationPoint) firstElement.getResource().getResource();
1107 // Network-Network ports --> iOTSi layer SIPs
1108 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1109 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1111 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1112 TapiStringConstants.I_OTSI, tp.getTpId()));
1115 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1116 tp = (TerminationPoint) firstElement.getResource().getResource();
1117 // Client-client ports --> DSR layer SIPs
1118 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1119 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1121 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1122 TapiStringConstants.DSR, tp.getTpId()));
1126 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1128 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1129 if (!sip.getUuid().equals(sipUuid)) {
1130 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1133 aendUuid = sip.getUuid();
1140 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1141 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1142 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1143 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1144 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1145 .getBytes(Charset.forName("UTF-8"))).toString());
1146 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1147 .getBytes(Charset.forName("UTF-8"))).toString());
1148 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1149 .getBytes(Charset.forName("UTF-8"))).toString());
1150 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1153 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1154 ConnectionEndPoint cep) {
1155 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1156 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1157 .getBytes(Charset.forName("UTF-8"))).toString());
1158 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1159 .getBytes(Charset.forName("UTF-8"))).toString());
1160 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1161 .getBytes(Charset.forName("UTF-8"))).toString());
1162 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1165 public Map<org.opendaylight.yang.gen.v1.urn
1166 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1167 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1168 getConnectionFullMap() {
1169 return this.connectionFullMap;
1172 private String getIdBasedOnModelVersion(String nodeid) {
1173 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
1174 : nodeid.split("-")[0];
1177 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1178 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1179 Map<org.opendaylight.yang.gen.v1.urn
1180 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1181 org.opendaylight.yang.gen.v1.urn
1182 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1183 endPointMap = input.getEndPoint();
1184 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1185 ConnectionType connType = null;
1186 ServiceFormat serviceFormat = null;
1187 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1188 TapiStringConstants.DSR);
1189 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1190 TapiStringConstants.DSR);
1191 LOG.debug("Node a = {}", nodeAid);
1192 LOG.debug("Node z = {}", nodeZid);
1193 switch (constraint.getServiceLayer().getIntValue()) {
1196 connType = ConnectionType.Infrastructure;
1197 serviceFormat = ServiceFormat.ODU;
1201 connType = ConnectionType.Service;
1202 serviceFormat = ServiceFormat.Ethernet;
1205 LOG.info("PHOTONIC");
1206 connType = getConnectionTypePhtnc(endPointMap.values());
1207 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1208 if (serviceFormat.equals(ServiceFormat.OC)) {
1209 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1210 TapiStringConstants.PHTNC_MEDIA);
1211 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1212 TapiStringConstants.PHTNC_MEDIA);
1214 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1215 TapiStringConstants.OTSI);
1216 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1217 TapiStringConstants.OTSI);
1219 LOG.debug("Node a photonic = {}", nodeAid);
1220 LOG.debug("Node z photonic = {}", nodeZid);
1223 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1225 // Requested Capacity for connectivity service
1226 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1227 // map endpoints into service end points. Map the type of service from TAPI to OR
1228 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1229 serviceFormat, nodeAid, capacity);
1230 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1231 serviceFormat, nodeZid, capacity);
1232 if (serviceAEnd == null || serviceZEnd == null) {
1233 LOG.error("Couldnt map endpoints to service end");
1236 LOG.info("Service a end = {}", serviceAEnd);
1237 LOG.info("Service z end = {}", serviceZEnd);
1238 return new ServiceCreateInputBuilder()
1239 .setServiceAEnd(serviceAEnd)
1240 .setServiceZEnd(serviceZEnd)
1241 .setConnectionType(connType)
1242 .setServiceName(serviceUuid.getValue())
1243 .setCommonId("common id")
1244 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1245 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1246 .setRequestSystemId("appname")
1248 .setCustomer("customer")
1249 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1250 .setOperatorContact("pw1234")
1254 private ServiceZEnd tapiEndPointToServiceZPoint(
1255 org.opendaylight.yang.gen.v1.urn
1256 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1257 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity) {
1258 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1259 // Not the rest which is needed in the txPortDeviceName.
1260 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1261 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1262 // Todo -> need to find the NEP associated to that SIP
1263 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString());
1264 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1265 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1267 LOG.error("Node not found in datastore");
1270 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1271 // connection is between 2 CLIENT ports. Otherwise it will not work...
1272 OwnedNodeEdgePoint nep = null;
1273 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1274 if (onep.getMappedServiceInterfacePoint() == null) {
1277 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1283 LOG.error("Nep not found in datastore");
1286 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1287 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1288 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1289 String txPortDeviceName = nepName.split("\\+")[0];
1290 String txPortName = nepName.split("\\+")[2];
1291 String rxPortDeviceName = txPortDeviceName;
1292 String rxPortName = txPortName;
1293 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1294 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1295 if (serviceFormat.equals(ServiceFormat.ODU)) {
1296 // TODO --> populate network map
1297 populateNetworkMap(nodeid, txPortName);
1299 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1300 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1301 // Set boolean to true and update txportName and so on
1302 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1303 if (updTxName != null) {
1304 txPortName = updTxName;
1305 rxPortName = txPortName;
1308 // TODO --> get clli from datastore?
1309 String clli = "NodeSC";
1310 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1311 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1312 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1314 .setNodeId(new NodeIdType(nodeid))
1315 .setOpticType(OpticTypes.Gray)
1316 .setServiceFormat(serviceFormat)
1317 .setServiceRate(Uint32.valueOf(capacity))
1318 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(
1319 new org.opendaylight.yang.gen.v1.http
1320 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1321 .setCommittedBurstSize(Uint16.valueOf(64))
1322 .setCommittedInfoRate(Uint32.valueOf(100000))
1325 .setTxDirection(new TxDirectionBuilder()
1326 .setPort(new PortBuilder()
1327 .setPortDeviceName(txPortDeviceName)
1328 .setPortName(txPortName)
1329 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1331 .setPortType(TapiStringConstants.PORT_TYPE)
1333 .setLgx(new LgxBuilder()
1334 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1335 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1336 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1337 .setLgxPortShelf("00")
1340 .setRxDirection(new RxDirectionBuilder()
1341 .setPort(new PortBuilder()
1342 .setPortDeviceName(rxPortDeviceName)
1343 .setPortName(rxPortName)
1344 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1346 .setPortType(TapiStringConstants.PORT_TYPE)
1348 .setLgx(new LgxBuilder()
1349 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1350 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1351 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1352 .setLgxPortShelf("00")
1355 if (serviceFormat.equals(ServiceFormat.ODU)) {
1356 serviceZEndBuilder.setOduServiceRate(ODU4.class);
1358 if (serviceFormat.equals(ServiceFormat.OTU)) {
1359 serviceZEndBuilder.setOtuServiceRate(OTU4.class);
1361 return serviceZEndBuilder.build();
1364 private ServiceAEnd tapiEndPointToServiceAPoint(
1365 org.opendaylight.yang.gen.v1.urn
1366 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1367 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity) {
1368 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1369 // Not the rest which is needed in the txPortDeviceName.
1370 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1371 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1372 // Todo -> need to find the NEP associated to that SIP
1373 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString());
1374 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1375 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1377 LOG.error("Node not found in datastore");
1380 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1381 // connection is between 2 CLIENT ports. Otherwise it will not work...
1382 OwnedNodeEdgePoint nep = null;
1383 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1384 if (onep.getMappedServiceInterfacePoint() == null) {
1387 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1393 LOG.error("Nep not found in datastore");
1396 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1397 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1398 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1399 String txPortDeviceName = nepName.split("\\+")[0];
1400 String txPortName = nepName.split("\\+")[2];
1401 String rxPortDeviceName = txPortDeviceName;
1402 String rxPortName = txPortName;
1403 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1404 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1405 if (serviceFormat.equals(ServiceFormat.ODU)) {
1406 // TODO --> populate network map
1407 populateNetworkMap(nodeid, txPortName);
1409 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1410 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1411 // Set boolean to true and update txportName and so on
1412 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1413 if (updTxName != null) {
1414 txPortName = updTxName;
1415 rxPortName = txPortName;
1418 // TODO --> get clli from datastore?
1419 String clli = "NodeSA";
1420 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1421 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1422 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1424 .setNodeId(new NodeIdType(nodeid))
1425 .setOpticType(OpticTypes.Gray)
1426 .setServiceFormat(serviceFormat)
1427 .setServiceRate(Uint32.valueOf(capacity))
1428 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(
1429 new org.opendaylight.yang.gen.v1.http
1430 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1431 .setCommittedBurstSize(Uint16.valueOf(64))
1432 .setCommittedInfoRate(Uint32.valueOf(100000))
1435 .setTxDirection(new TxDirectionBuilder()
1436 .setPort(new PortBuilder()
1437 .setPortDeviceName(txPortDeviceName)
1438 .setPortName(txPortName)
1439 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1441 .setPortType(TapiStringConstants.PORT_TYPE)
1443 .setLgx(new LgxBuilder()
1444 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1445 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1446 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1447 .setLgxPortShelf("00")
1450 .setRxDirection(new RxDirectionBuilder()
1451 .setPort(new PortBuilder()
1452 .setPortDeviceName(rxPortDeviceName)
1453 .setPortName(rxPortName)
1454 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1456 .setPortType(TapiStringConstants.PORT_TYPE)
1458 .setLgx(new LgxBuilder()
1459 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1460 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1461 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1462 .setLgxPortShelf("00")
1465 if (serviceFormat.equals(ServiceFormat.ODU)) {
1466 serviceAEndBuilder.setOduServiceRate(ODU4.class);
1468 if (serviceFormat.equals(ServiceFormat.OTU)) {
1469 serviceAEndBuilder.setOtuServiceRate(OTU4.class);
1471 return serviceAEndBuilder.build();
1474 private String findFreeConfiguredNetworkPort(String nodeid) {
1475 if (!this.networkMap.containsKey(nodeid)) {
1478 Map<String, Boolean> netMap = this.networkMap.get(nodeid);
1479 for (Map.Entry<String, Boolean> entry : netMap.entrySet()) {
1480 if (!entry.getValue()) {
1481 this.networkMap.get(nodeid).put(entry.getKey(), true);
1482 return entry.getKey();
1488 private void populateNetworkMap(String nodeid, String txPortName) {
1489 Map<String, Boolean> netMap = new HashMap<>();
1490 netMap.put(txPortName, false);
1491 if (!this.networkMap.containsKey(nodeid)) {
1492 this.networkMap.put(nodeid, netMap);
1493 } else if (!this.networkMap.get(nodeid).containsKey(txPortName)) {
1494 this.networkMap.get(nodeid).putAll(netMap);
1498 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1499 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1500 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1501 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1502 // EndPoints are ROADMs
1503 return ConnectionType.RoadmLine;
1505 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1506 return ConnectionType.Infrastructure;
1509 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1510 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1511 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1512 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1513 // EndPoints are ROADMs
1514 return ServiceFormat.OC;
1516 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1517 return ServiceFormat.OTU;