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.Comparator;
13 import java.util.HashMap;
14 import java.util.List;
16 import java.util.Optional;
17 import java.util.UUID;
18 import java.util.stream.Collectors;
19 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
20 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
21 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
22 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
23 import org.opendaylight.transportpce.tapi.utils.TapiContext;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev181130.OpticTypes;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.Service;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEnd;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEndBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEnd;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEndBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.PathDescription;
42 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZ;
43 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZKey;
44 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToA;
45 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToAKey;
46 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.Node;
47 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.TerminationPoint;
48 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.BandwidthProfileBuilder;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ProtectionRole;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointKey;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePoint;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePointBuilder;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.CapacityBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder;
80 import org.opendaylight.yangtools.yang.common.Uint32;
81 import org.opendaylight.yangtools.yang.common.Uint64;
82 import org.slf4j.Logger;
83 import org.slf4j.LoggerFactory;
85 public final class ConnectivityUtils {
87 private static final String LGX_PORT_NAME = "Some lgx-port-name";
88 private static final String PORT_TYPE = "some port type";
89 private static final String LGX_DEVICE_NAME = "Some lgx-device-name";
90 private static final String PORT_RACK_VALUE = "000000.00";
91 private static final String DSR = "DSR";
92 private static final String ODU = "ODU";
93 private static final String E_ODU = "eODU";
94 private static final String I_ODU = "iODU";
95 private static final String OTSI = "OTSi";
96 private static final String E_OTSI = "eOTSi";
97 private static final String I_OTSI = "iOTSi";
98 private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA";
99 private static final String MC = "MEDIA_CHANNEL";
100 private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL";
101 private static final String TP = "TerminationPoint";
102 private static final String NODE = "Node";
103 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
105 private final ServiceDataStoreOperations serviceDataStoreOperations;
106 private final TapiContext tapiContext;
107 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
108 private final Map<org.opendaylight.yang.gen.v1.urn
109 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
110 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
111 connectionFullMap; // this variable is for complete connection objects
113 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
114 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
115 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext) {
116 this.serviceDataStoreOperations = serviceDataStoreOperations;
117 this.tapiContext = tapiContext;
118 this.sipMap = sipMap;
119 this.connectionFullMap = new HashMap<>();
122 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
123 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
124 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
125 if (serviceAEnd == null || serviceZEnd == null) {
126 LOG.warn("One of the endpoints could not be identified");
129 return new ServiceCreateInputBuilder()
130 .setCommonId("commonId")
131 .setConnectionType(ConnectionType.Service)
132 .setCustomer("Customer")
133 .setServiceName("service test")
134 .setServiceAEnd(serviceAEnd)
135 .setServiceZEnd(serviceZEnd)
136 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
137 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
143 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
144 String txPortName, String rxPortDeviceName, String rxPortName) {
145 return new ServiceAEndBuilder()
147 .setNodeId(new NodeIdType(nodeid))
148 .setOpticType(OpticTypes.Gray)
149 .setServiceFormat(ServiceFormat.Ethernet)
150 .setServiceRate(Uint32.valueOf(100))
151 .setTxDirection(new TxDirectionBuilder()
152 .setPort(new PortBuilder()
153 .setPortDeviceName(txPortDeviceName)
154 .setPortName(txPortName)
155 .setPortRack(PORT_RACK_VALUE)
157 .setPortType(PORT_TYPE)
159 .setLgx(new LgxBuilder()
160 .setLgxDeviceName(LGX_DEVICE_NAME)
161 .setLgxPortName(LGX_PORT_NAME)
162 .setLgxPortRack(PORT_RACK_VALUE)
163 .setLgxPortShelf("00")
166 .setRxDirection(new RxDirectionBuilder()
167 .setPort(new PortBuilder()
168 .setPortDeviceName(rxPortDeviceName)
169 .setPortName(rxPortName)
170 .setPortRack(PORT_RACK_VALUE)
172 .setPortType(PORT_TYPE)
174 .setLgx(new LgxBuilder()
175 .setLgxDeviceName(LGX_DEVICE_NAME)
176 .setLgxPortName(LGX_PORT_NAME)
177 .setLgxPortRack(PORT_RACK_VALUE)
178 .setLgxPortShelf("00")
184 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
185 String txPortName, String rxPortDeviceName, String rxPortName) {
186 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
187 .setOpticType(OpticTypes.Gray)
188 .setServiceFormat(ServiceFormat.Ethernet)
189 .setServiceRate(Uint32.valueOf(100))
190 .setTxDirection(new TxDirectionBuilder()
191 .setPort(new PortBuilder()
192 .setPortDeviceName(txPortDeviceName)
193 .setPortName(txPortName)
194 .setPortRack(PORT_RACK_VALUE)
196 .setPortType(PORT_TYPE)
198 .setLgx(new LgxBuilder()
199 .setLgxDeviceName(LGX_DEVICE_NAME)
200 .setLgxPortName(LGX_PORT_NAME)
201 .setLgxPortRack(PORT_RACK_VALUE)
202 .setLgxPortShelf("00")
205 .setRxDirection(new RxDirectionBuilder()
206 .setPort(new PortBuilder()
207 .setPortDeviceName(rxPortDeviceName)
208 .setPortName(rxPortName)
209 .setPortRack(PORT_RACK_VALUE)
211 .setPortType(PORT_TYPE)
213 .setLgx(new LgxBuilder()
214 .setLgxDeviceName(LGX_DEVICE_NAME)
215 .setLgxPortName(LGX_PORT_NAME)
216 .setLgxPortRack(PORT_RACK_VALUE)
217 .setLgxPortShelf("00")
223 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
224 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
225 return new ServiceAEndBuilder(sepA.getValue()).build();
226 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
227 return new ServiceAEndBuilder(sepZ.getValue()).build();
233 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
234 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
235 return new ServiceZEndBuilder(sepA.getValue()).build();
236 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
237 return new ServiceZEndBuilder(sepZ.getValue()).build();
243 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
247 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
248 // Get service path with the description in OR based models.
249 LOG.info("Service = {}", service);
250 Optional<ServicePaths> optServicePaths =
251 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
252 if (!optServicePaths.isPresent()) {
253 LOG.error("No service path found for service {}", service.getServiceName());
256 ServicePaths servicePaths = optServicePaths.get();
257 PathDescription pathDescription = servicePaths.getPathDescription();
258 LOG.info("Path description of service = {}", pathDescription);
259 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd
260 = service.getServiceAEnd();
262 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
263 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd
264 = service.getServiceZEnd();
265 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
266 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
267 endPointMap.put(endPoint1.key(), endPoint1);
268 endPointMap.put(endPoint2.key(), endPoint2);
269 LOG.info("EndPoints of connectivity services = {}", endPointMap);
271 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
273 // Connection creation
274 Map<ConnectionKey, Connection> connMap =
275 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
276 // TODO: full connectivity service?? With constraints and the rest of fields...
277 return new ConnectivityServiceBuilder()
278 .setAdministrativeState(AdministrativeState.UNLOCKED)
279 .setOperationalState(OperationalState.ENABLED)
280 .setLifecycleState(LifecycleState.INSTALLED)
281 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
283 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
284 .setName(Map.of(name.key(), name))
285 .setConnection(connMap)
286 .setEndPoint(endPointMap)
290 private Map<ConnectionKey, Connection> createConnectionsFromService(
291 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
293 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
295 PathDescription pathDescription) {
296 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
297 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
298 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
299 // and the connections
301 List<String> xpdrClientTplist = new ArrayList<>();
302 List<String> xpdrNetworkTplist = new ArrayList<>();
303 List<String> rdmAddDropTplist = new ArrayList<>();
304 List<String> rdmDegTplist = new ArrayList<>();
305 List<String> rdmNodelist = new ArrayList<>();
306 List<String> xpdrNodelist = new ArrayList<>();
307 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
308 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
309 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
310 switch (resourceType) {
312 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
313 String tpID = tp.getTpId();
315 if (tpID.contains("CLIENT")) {
316 tpNode = tp.getTpNodeId();
317 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
318 xpdrClientTplist.add(String.join("+", tpNode, tpID));
321 if (tpID.contains("NETWORK")) {
322 tpNode = tp.getTpNodeId();
323 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
324 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
327 if (tpID.contains("PP")) {
328 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
329 LOG.info("ROADM Node of tp = {}", tpNode);
330 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
331 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
334 if (tpID.contains("TTP")) {
335 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
336 LOG.info("ROADM Node of tp = {}", tpNode);
337 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
338 rdmDegTplist.add(String.join("+", tpNode, tpID));
343 Node node = (Node) elem.getResource().getResource();
344 String nodeId = node.getNodeId();
345 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
346 LOG.info("Node id = {}", nodeId);
347 if (!xpdrNodelist.contains(nodeId)) {
348 xpdrNodelist.add(nodeId); // should contain only 2
351 if (nodeId.contains("ROADM")) {
352 nodeId = getIdBasedOnModelVersion(nodeId);
353 LOG.info("Node id = {}", nodeId);
354 if (!rdmNodelist.contains(nodeId)) {
355 rdmNodelist.add(nodeId);
360 LOG.warn("Resource is a {}", resourceType);
363 LOG.info("ROADM node list = {}", rdmNodelist);
364 LOG.info("ROADM degree list = {}", rdmDegTplist);
365 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
366 LOG.info("XPDR node list = {}", xpdrNodelist);
367 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
368 LOG.info("XPDR client list = {}", xpdrClientTplist);
369 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
370 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
371 // to trigger all the steps or not
372 String edgeRoadm1 = "";
373 String edgeRoadm2 = "";
374 if (!rdmNodelist.isEmpty()) {
375 edgeRoadm1 = rdmNodelist.get(0);
376 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
377 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
378 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
380 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
381 // CEPs must be included in the topology context as an augmentation for each ONEP!!
382 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
383 // TODO -> better mechanism to map services???
384 switch (serviceFormat) {
386 // Identify number of ROADMs
387 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
388 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
389 // - Top Connection MC betwwen MC CEPs of different roadms
390 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
391 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
392 edgeRoadm1, edgeRoadm2));
395 // Identify number of ROADMs between XPDRs and check if OC is created
396 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
397 // - Top Connection MC betwwen MC CEPs of different roadms
398 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
399 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
400 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
401 edgeRoadm1, edgeRoadm2));
402 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
403 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
404 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
407 // Check if OC and OTU are created
408 if (!rdmNodelist.isEmpty()) {
409 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
410 edgeRoadm1, edgeRoadm2));
411 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
413 // - XC Connection OTSi betwwen iODU and eODU of xpdr
414 // - Top connection in the ODU layer, between xpdr eODU ports (?)
415 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
418 // Check if OC, OTU and ODU are created
419 if (!rdmNodelist.isEmpty()) {
420 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
421 edgeRoadm1, edgeRoadm2));
422 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
423 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
425 // Top connection in the DSR layer, between client ports of the xpdrs
426 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNodelist));
429 LOG.error("Service type format not supported");
431 return connectionServMap;
434 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
435 List<String> xpdrNodelist) {
436 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
437 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
438 ConnectionEndPoint> cepMap = new HashMap<>();
440 // Create 1 cep per Xpdr in the CLIENT and a top connection DSR between the CLIENT xpdrs
441 for (String xpdr:xpdrNodelist) {
442 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
443 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
445 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, DSR, DSR, LayerProtocolName.DSR);
446 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, DSR, DSR, netCep1);
448 cepMap.put(netCep1.key(), netCep1);
451 // DSR top connection between edge xpdr CLIENT DSR
452 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
453 .get(0))).findFirst().get();
454 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
455 .get(xpdrNodelist.size() - 1))).findFirst().get();
456 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
457 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, DSR, LayerProtocolName.DSR);
458 this.connectionFullMap.put(connection.key(), connection);
460 // ODU top connection that will be added to the service object
461 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
462 connServMap.put(conn.key(), conn);
467 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
468 List<String> xpdrNodelist) {
469 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
470 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
471 ConnectionEndPoint> cepMap = new HashMap<>();
472 // Create 1 cep per Xpdr in the I_ODU and E_ODU, X connection between iODU and eODU and a top
473 // connection iODU between the xpdrs
474 for (String xpdr:xpdrNodelist) {
475 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
476 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
478 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, E_ODU, DSR, LayerProtocolName.ODU);
479 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_ODU, DSR, netCep1);
480 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, I_ODU, DSR, LayerProtocolName.ODU);
481 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_ODU, DSR, netCep2);
483 cepMap.put(netCep1.key(), netCep1);
484 cepMap.put(netCep2.key(), netCep2);
486 // Create x connection between I_ODU and E_ODU within xpdr
487 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
488 connection = createXCBetweenCeps(netCep1, netCep2, spcXpdrNetwork, spcXpdrNetwork, ODU,
489 LayerProtocolName.ODU);
490 this.connectionFullMap.put(connection.key(), connection);
492 // Create X connection that will be added to the service object
493 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
494 connServMap.put(conn.key(), conn);
497 // ODU top connection between edge xpdr e_ODU
498 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
499 .get(0))).findFirst().get();
500 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
501 .get(xpdrNodelist.size() - 1))).findFirst().get();
502 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
503 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, E_ODU, LayerProtocolName.ODU);
504 this.connectionFullMap.put(connection.key(), connection);
506 // ODU top connection that will be added to the service object
507 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
508 connServMap.put(conn.key(), conn);
513 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
514 List<String> xpdrNodelist) {
515 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
516 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
517 ConnectionEndPoint> cepMap = new HashMap<>();
519 // create ceps and x connections within xpdr
520 for (String xpdr:xpdrNodelist) {
521 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
522 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
523 // There should be 1 network tp per xpdr
524 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
525 // 3 different MC CEPs giving different IDs to show that they are different
526 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
527 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, PHTNC_MEDIA, OTSI,
528 LayerProtocolName.PHOTONICMEDIA);
529 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, PHTNC_MEDIA, OTSI, netCep1);
530 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, E_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA);
531 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_OTSI, OTSI, netCep2);
532 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, I_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA);
533 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_OTSI, OTSI, netCep3);
534 cepMap.put(netCep1.key(), netCep1);
535 cepMap.put(netCep2.key(), netCep2);
536 cepMap.put(netCep3.key(), netCep3);
538 // Create x connection between I_OTSi and E_OTSi within xpdr
539 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
540 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork, OTSI,
541 LayerProtocolName.PHOTONICMEDIA);
542 this.connectionFullMap.put(connection.key(), connection);
544 // Create X connection that will be added to the service object
545 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
546 connServMap.put(conn.key(), conn);
548 // OTSi top connection between edge I_OTSI Xpdr
549 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
550 .get(0))).findFirst().get();
551 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
552 .get(xpdrNodelist.size() - 1))).findFirst().get();
553 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
554 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, I_OTSI, LayerProtocolName.PHOTONICMEDIA);
555 this.connectionFullMap.put(connection.key(), connection);
557 // OTSi top connection that will be added to the service object
558 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
559 connServMap.put(conn.key(), conn);
565 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
566 List<String> rdmDegTplist,
567 List<String> rdmNodelist,
568 String edgeRoadm1, String edgeRoadm2) {
569 // TODO: will need to check if things exist already or not
570 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
571 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
572 ConnectionEndPoint> cepMap = new HashMap<>();
573 // create ceps and x connections within roadm
574 for (String roadm : rdmNodelist) {
575 LOG.info("Creating ceps and xc for roadm {}", roadm);
576 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
577 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
578 // There should be only 1 AD and 1 DEG per roadm
579 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
580 // 3 different MC CEPs giving different IDs to show that they are different
581 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
582 // created in the topology creation
583 // add CEPs to the topology to the corresponding ONEP
584 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, PHTNC_MEDIA);
585 putRdmCepInTopologyContext(roadm, spcRdmAD, PHTNC_MEDIA, adCep1);
586 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, MC);
587 putRdmCepInTopologyContext(roadm, spcRdmAD, MC, adCep2);
588 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, OTSI_MC);
589 putRdmCepInTopologyContext(roadm, spcRdmAD, OTSI_MC, adCep3);
590 cepMap.put(adCep1.key(), adCep1);
591 cepMap.put(adCep2.key(), adCep2);
592 cepMap.put(adCep3.key(), adCep3);
594 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
595 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
597 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, PHTNC_MEDIA);
598 putRdmCepInTopologyContext(roadm, spcRdmDEG, PHTNC_MEDIA, degCep1);
599 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, MC);
600 putRdmCepInTopologyContext(roadm, spcRdmDEG, MC, degCep2);
601 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, OTSI_MC);
602 putRdmCepInTopologyContext(roadm, spcRdmDEG, OTSI_MC, degCep3);
603 cepMap.put(degCep1.key(), degCep1);
604 cepMap.put(degCep2.key(), degCep2);
605 cepMap.put(degCep3.key(), degCep3);
607 LOG.info("Going to create cross connections for ROADM {}", roadm);
608 // Create X connections between MC and OTSi_MC for full map
609 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
610 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, MC,
611 LayerProtocolName.PHOTONICMEDIA);
612 LOG.info("Cross connection 1 created = {}", connection1);
613 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
614 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, OTSI_MC,
615 LayerProtocolName.PHOTONICMEDIA);
616 LOG.info("Cross connection 2 created = {}", connection2);
617 this.connectionFullMap.put(connection1.key(), connection1);
618 this.connectionFullMap.put(connection2.key(), connection2);
620 // Create X connections that will be added to the service object
621 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
622 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
623 connServMap.put(conn1.key(), conn1);
624 connServMap.put(conn2.key(), conn2);
626 LOG.info("Going to create top connections betwee roadms");
627 // create top connections between roadms: MC connections between AD MC CEPs of roadms
628 for (int i = 0; i < rdmNodelist.size(); i++) {
629 if (rdmNodelist.size() <= (i + 1)) {
630 LOG.info("Reached last roadm. No more MC connections");
633 // Current roadm with roadm i + 1 --> MC
634 String roadm1 = rdmNodelist.get(i);
635 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
636 String roadm2 = rdmNodelist.get(i + 1);
637 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
638 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
640 // Create top connections between MC for full map
641 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
642 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, MC, LayerProtocolName.PHOTONICMEDIA);
643 this.connectionFullMap.put(connection.key(), connection);
644 LOG.info("Top connection created = {}", connection);
646 // Create top connections that will be added to the service object
647 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
648 connServMap.put(conn.key(), conn);
651 // OTSiMC top connection between edge roadms
652 LOG.info("Going to created top connection between OTSiMC");
653 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
654 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
655 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
656 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, OTSI_MC,
657 LayerProtocolName.PHOTONICMEDIA);
658 this.connectionFullMap.put(connection.key(), connection);
659 LOG.info("Top connection created = {}", connection);
661 // OTSiMC top connections that will be added to the service object
662 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
663 connServMap.put(conn.key(), conn);
667 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
668 createTopConnection(String tp1, String tp2,
669 Map<org.opendaylight.yang.gen.v1.urn
670 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
671 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol) {
672 // find cep for each AD MC of roadm 1 and 2
673 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
674 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
675 cepMap.get(new org.opendaylight.yang.gen.v1.urn
676 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
677 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
678 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
680 LOG.info("ADCEP1 = {}", adCep1);
681 org.opendaylight.yang.gen.v1.urn
682 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
683 new org.opendaylight.yang.gen.v1.urn
684 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
685 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
686 .values().stream().findFirst().get().getNodeEdgePointUuid())
687 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
688 .values().stream().findFirst().get().getTopologyUuid())
689 .setNodeUuid(adCep1.getClientNodeEdgePoint()
690 .values().stream().findFirst().get().getNodeUuid())
691 .setConnectionEndPointUuid(adCep1.getUuid())
693 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
694 cepMap.get(new org.opendaylight.yang.gen.v1.urn
695 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
696 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
697 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
699 LOG.info("ADCEP2 = {}", adCep2);
700 org.opendaylight.yang.gen.v1.urn
701 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
702 new org.opendaylight.yang.gen.v1.urn
703 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
704 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
705 .values().stream().findFirst().get().getNodeEdgePointUuid())
706 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
707 .values().stream().findFirst().get().getTopologyUuid())
708 .setNodeUuid(adCep2.getClientNodeEdgePoint()
709 .values().stream().findFirst().get().getNodeUuid())
710 .setConnectionEndPointUuid(adCep1.getUuid())
712 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
713 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
714 ceps.put(cep1.key(), cep1);
715 ceps.put(cep2.key(), cep2);
716 Name connName = new NameBuilder()
717 .setValueName("Connection name")
718 .setValue(String.join("+", "TOP", tp1, tp2, qual))
720 // TODO: lower connection, supported link.......
721 return new org.opendaylight.yang.gen.v1.urn
722 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
723 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
724 .getBytes(Charset.forName("UTF-8"))).toString()))
725 .setName(Map.of(connName.key(), connName))
726 .setConnectionEndPoint(ceps)
727 .setOperationalState(OperationalState.ENABLED)
728 .setLayerProtocolName(topPortocol)
729 .setLifecycleState(LifecycleState.INSTALLED)
730 .setDirection(ForwardingDirection.BIDIRECTIONAL)
734 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
735 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
736 LayerProtocolName xcProtocol) {
737 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
738 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
739 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
740 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
741 org.opendaylight.yang.gen.v1.urn
742 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
743 new org.opendaylight.yang.gen.v1.urn
744 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
745 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
746 .values().stream().findFirst().get().getNodeEdgePointUuid())
747 .setTopologyUuid(cep1.getClientNodeEdgePoint()
748 .values().stream().findFirst().get().getTopologyUuid())
749 .setNodeUuid(cep1.getClientNodeEdgePoint()
750 .values().stream().findFirst().get().getNodeUuid())
751 .setConnectionEndPointUuid(cep1.getUuid())
753 org.opendaylight.yang.gen.v1.urn
754 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
755 new org.opendaylight.yang.gen.v1.urn
756 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
757 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
758 .values().stream().findFirst().get().getNodeEdgePointUuid())
759 .setTopologyUuid(cep2.getClientNodeEdgePoint()
760 .values().stream().findFirst().get().getTopologyUuid())
761 .setNodeUuid(cep2.getClientNodeEdgePoint()
762 .values().stream().findFirst().get().getNodeUuid())
763 .setConnectionEndPointUuid(cep2.getUuid())
765 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
766 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
767 ceps.put(cepServ1.key(), cepServ1);
768 ceps.put(cepServ2.key(), cepServ2);
769 Name connName = new NameBuilder()
770 .setValueName("Connection name")
771 .setValue(String.join("+", "XC", tp1, tp2, qual))
773 // TODO: lower connection, supported link.......
774 return new org.opendaylight.yang.gen.v1.urn
775 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
776 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
777 .getBytes(Charset.forName("UTF-8"))).toString()))
778 .setName(Map.of(connName.key(), connName))
779 .setConnectionEndPoint(ceps)
780 .setOperationalState(OperationalState.ENABLED)
781 .setLayerProtocolName(xcProtocol)
782 .setLifecycleState(LifecycleState.INSTALLED)
783 .setDirection(ForwardingDirection.BIDIRECTIONAL)
787 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
788 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
789 Name cepName = new NameBuilder()
790 .setValueName("ConnectionEndPoint name")
791 .setValue(String.join("+", id.split("\\+")[0], qualifier,
794 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
795 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
796 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
798 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
799 qualifier)).getBytes(Charset.forName("UTF-8")))
801 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
802 .getBytes(Charset.forName("UTF-8"))).toString()))
804 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
805 // TODO: add parent ONEP??
806 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
807 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
808 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
810 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
811 .setName(Map.of(cepName.key(), cepName))
812 .setConnectionPortRole(PortRole.SYMMETRIC)
813 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
814 .setOperationalState(OperationalState.ENABLED)
815 .setLifecycleState(LifecycleState.INSTALLED)
816 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
817 return cepBldr.build();
820 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
821 LayerProtocolName cepProtocol) {
822 Name cepName = new NameBuilder()
823 .setValueName("ConnectionEndPoint name")
824 .setValue(String.join("+", id.split("\\+")[0], qualifier,
827 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
828 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
829 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
831 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
832 nodeLayer)).getBytes(Charset.forName("UTF-8")))
834 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
835 .getBytes(Charset.forName("UTF-8"))).toString()))
837 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
838 // TODO: add parent ONEP??
839 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
840 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
841 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
843 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
844 .setName(Map.of(cepName.key(), cepName))
845 .setConnectionPortRole(PortRole.SYMMETRIC)
846 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
847 .setOperationalState(OperationalState.ENABLED)
848 .setLifecycleState(LifecycleState.INSTALLED)
849 .setLayerProtocolName(cepProtocol);
850 return cepBldr.build();
853 private EndPoint mapServiceZEndPoint(
854 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
855 serviceZEnd, PathDescription pathDescription) {
856 EndPointBuilder endPointBuilder = new EndPointBuilder();
857 // 1. Service Format: ODU, OTU, ETH
858 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
859 String serviceNodeId = serviceZEnd.getNodeId().getValue();
861 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
862 LOG.info("Uuid of z end {}", sipUuid);
863 LayerProtocolName layerProtocols = null;
864 // Layer protocol name
865 switch (serviceFormat) {
867 layerProtocols = LayerProtocolName.DSR;
871 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
874 layerProtocols = LayerProtocolName.ODU;
877 LOG.error("Service Format not supported");
879 return endPointBuilder
880 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
881 .setServiceInterfacePointUuid(sipUuid)
883 .setAdministrativeState(AdministrativeState.UNLOCKED)
884 .setDirection(PortDirection.BIDIRECTIONAL)
885 .setLifecycleState(LifecycleState.INSTALLED)
886 .setOperationalState(OperationalState.ENABLED)
887 .setLayerProtocolName(layerProtocols)
888 .setCapacity(new CapacityBuilder()
889 .setTotalSize(new TotalSizeBuilder()
890 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
891 .setUnit(CapacityUnit.GBPS)
893 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
895 .setProtectionRole(ProtectionRole.WORK)
896 .setRole(PortRole.SYMMETRIC)
897 .setLocalId(serviceNodeId)
901 private EndPoint mapServiceAEndPoint(
902 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
903 serviceAEnd, PathDescription pathDescription) {
904 EndPointBuilder endPointBuilder = new EndPointBuilder();
905 // 1. Service Format: ODU, OTU, ETH
906 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
907 String serviceNodeId = serviceAEnd.getNodeId().getValue();
909 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
910 LOG.info("Uuid of a end {}", sipUuid);
911 LayerProtocolName layerProtocols = null;
912 // Layer protocol name
913 switch (serviceFormat) {
915 layerProtocols = LayerProtocolName.DSR;
919 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
922 layerProtocols = LayerProtocolName.ODU;
925 LOG.error("Service Format not supported");
927 return endPointBuilder
928 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
929 .setServiceInterfacePointUuid(sipUuid)
931 .setAdministrativeState(AdministrativeState.UNLOCKED)
932 .setDirection(PortDirection.BIDIRECTIONAL)
933 .setLifecycleState(LifecycleState.INSTALLED)
934 .setOperationalState(OperationalState.ENABLED)
935 .setLayerProtocolName(layerProtocols)
936 .setCapacity(new CapacityBuilder()
937 .setTotalSize(new TotalSizeBuilder()
938 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
939 .setUnit(CapacityUnit.GBPS)
941 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
943 .setProtectionRole(ProtectionRole.WORK)
944 .setRole(PortRole.SYMMETRIC)
945 .setLocalId(serviceNodeId)
949 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
950 Uuid zendUuid = null;
951 if (serviceNodeId.contains("ROADM")) {
952 // Service from ROADM to ROADM
953 // AddDrop-AddDrop ports --> MC layer SIPs
954 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
955 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
956 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
957 tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
959 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId()));
960 for (ServiceInterfacePoint sip:this.sipMap.values()) {
961 if (!sip.getUuid().equals(sipUuid)) {
962 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
965 zendUuid = sip.getUuid();
969 // Service from XPDR to XPDR
973 switch (serviceFormat) {
975 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
976 tp = (TerminationPoint) firstElement.getResource().getResource();
977 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
978 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
979 tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
981 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId()));
984 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
985 tp = (TerminationPoint) firstElement.getResource().getResource();
986 // Network-Network ports --> iOTSi layer SIPs
987 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
988 tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
990 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId()));
993 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
994 tp = (TerminationPoint) firstElement.getResource().getResource();
995 // Client-client ports --> DSR layer SIPs
996 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
997 tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
999 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId()));
1003 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
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();
1017 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1018 Uuid aendUuid = null;
1019 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1020 LOG.info("Map a to z = {}", mapatoz);
1021 if (serviceNodeId.contains("ROADM")) {
1022 // Service from ROADM to ROADM
1023 // AddDrop-AddDrop ports --> MC layer SIPs
1024 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1025 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1026 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1027 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1028 tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1030 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId()));
1031 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1032 if (!sip.getUuid().equals(sipUuid)) {
1033 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1036 aendUuid = sip.getUuid();
1040 // Service from XPDR to XPDR
1042 TerminationPoint tp;
1044 switch (serviceFormat) {
1046 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1047 tp = (TerminationPoint) firstElement.getResource().getResource();
1048 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1049 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1050 tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1052 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId()));
1055 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1056 tp = (TerminationPoint) firstElement.getResource().getResource();
1057 // Network-Network ports --> iOTSi layer SIPs
1058 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1059 tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1061 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId()));
1064 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1065 tp = (TerminationPoint) firstElement.getResource().getResource();
1066 // Client-client ports --> DSR layer SIPs
1067 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1068 tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1070 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId()));
1074 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1076 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1077 if (!sip.getUuid().equals(sipUuid)) {
1078 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1081 aendUuid = sip.getUuid();
1088 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1089 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1090 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, PHTNC_MEDIA));
1091 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1092 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
1093 .getBytes(Charset.forName("UTF-8"))).toString());
1094 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, PHTNC_MEDIA)
1095 .getBytes(Charset.forName("UTF-8"))).toString());
1096 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1097 .getBytes(Charset.forName("UTF-8"))).toString());
1098 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1101 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1102 ConnectionEndPoint cep) {
1103 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1104 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
1105 .getBytes(Charset.forName("UTF-8"))).toString());
1106 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1107 .getBytes(Charset.forName("UTF-8"))).toString());
1108 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1109 .getBytes(Charset.forName("UTF-8"))).toString());
1110 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1113 public Map<org.opendaylight.yang.gen.v1.urn
1114 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1115 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1116 getConnectionFullMap() {
1117 return this.connectionFullMap;
1120 private String getIdBasedOnModelVersion(String nodeid) {
1121 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
1122 : nodeid.split("-")[0];