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.math.BigDecimal;
11 import java.nio.charset.Charset;
12 import java.nio.charset.StandardCharsets;
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.Comparator;
16 import java.util.HashMap;
17 import java.util.List;
19 import java.util.Optional;
20 import java.util.UUID;
21 import java.util.concurrent.ExecutionException;
22 import java.util.stream.Collectors;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
25 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
26 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
27 import org.opendaylight.transportpce.tapi.TapiStringConstants;
28 import org.opendaylight.transportpce.tapi.topology.ConvertORToTapiTopology;
29 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
30 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
31 import org.opendaylight.transportpce.tapi.utils.TapiContext;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingKey;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes;
36 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.NodesKey;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev191129.OpticTypes;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.Service;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ethernet.subrate.attributes.grp.EthernetAttributesBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionKey;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.lgx.LgxBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth.sla.SubrateEthSlaBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OTU4;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEnd;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEndBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEnd;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEndBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription;
62 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToAKey;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node;
67 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint;
68 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.TotalSizeBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ProtectionRole;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.Connection;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionKey;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.CapacityBuilder;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.ServiceInterfacePointBuilder;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
120 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
121 import org.opendaylight.yangtools.yang.common.Decimal64;
122 import org.opendaylight.yangtools.yang.common.Uint16;
123 import org.opendaylight.yangtools.yang.common.Uint32;
124 import org.opendaylight.yangtools.yang.common.Uint64;
125 import org.opendaylight.yangtools.yang.common.Uint8;
126 import org.slf4j.Logger;
127 import org.slf4j.LoggerFactory;
129 public final class ConnectivityUtils {
131 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
132 private final Uuid tapiTopoUuid;
134 private final ServiceDataStoreOperations serviceDataStoreOperations;
135 private final TapiContext tapiContext;
136 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
137 // this variable is for complete connection objects
139 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
140 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
142 private final NetworkTransactionService networkTransactionService;
143 private Connection topConnRdmRdm;
144 private Connection topConnXpdrXpdrPhtn;
145 private Connection topConnXpdrXpdrOdu;
146 private ConvertORToTapiTopology tapiFactory;
148 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
149 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
150 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
151 NetworkTransactionService networkTransactionService, Uuid tapiTopoUuid) {
152 this.serviceDataStoreOperations = serviceDataStoreOperations;
153 this.tapiContext = tapiContext;
154 this.sipMap = sipMap;
155 this.connectionFullMap = new HashMap<>();
156 this.networkTransactionService = networkTransactionService;
157 this.topConnRdmRdm = null;
158 this.topConnXpdrXpdrPhtn = null;
159 this.topConnXpdrXpdrOdu = null;
160 this.tapiTopoUuid = tapiTopoUuid;
161 this.tapiFactory = new ConvertORToTapiTopology(tapiTopoUuid);
164 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
165 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
166 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
167 if (serviceAEnd == null || serviceZEnd == null) {
168 LOG.warn("One of the endpoints could not be identified");
171 return new ServiceCreateInputBuilder()
172 .setCommonId("commonId")
173 .setConnectionType(ConnectionType.Service)
174 .setCustomer("Customer")
175 .setServiceName("service test")
176 .setServiceAEnd(serviceAEnd)
177 .setServiceZEnd(serviceZEnd)
178 .setSdncRequestHeader(
179 new SdncRequestHeaderBuilder()
180 .setRequestId("request-1")
181 .setRpcAction(RpcActions.ServiceCreate)
182 .setNotificationUrl("notification url")
183 .setRequestSystemId("appname")
188 public static ServiceAEnd buildServiceAEnd(
189 String nodeid, String clli, String txPortDeviceName,
190 String txPortName, String rxPortDeviceName, String rxPortName) {
191 return new ServiceAEndBuilder()
193 .setNodeId(new NodeIdType(nodeid))
194 .setOpticType(OpticTypes.Gray)
195 .setServiceFormat(ServiceFormat.Ethernet)
196 .setServiceRate(Uint32.valueOf(100))
197 .setTxDirection(Map.of(
198 new TxDirectionKey(Uint8.ZERO),
199 new TxDirectionBuilder()
200 .setPort(new PortBuilder()
201 .setPortDeviceName(txPortDeviceName)
202 .setPortName(txPortName)
203 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
205 .setPortType(TapiStringConstants.PORT_TYPE)
207 .setLgx(new LgxBuilder()
208 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
209 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
210 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
211 .setLgxPortShelf("00")
214 .setRxDirection(Map.of(
215 new RxDirectionKey(Uint8.ZERO),
216 new RxDirectionBuilder()
217 .setPort(new PortBuilder()
218 .setPortDeviceName(rxPortDeviceName)
219 .setPortName(rxPortName)
220 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
222 .setPortType(TapiStringConstants.PORT_TYPE)
224 .setLgx(new LgxBuilder()
225 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
226 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
227 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
228 .setLgxPortShelf("00")
234 public static ServiceZEnd buildServiceZEnd(
235 String nodeid, String clli, String txPortDeviceName,
236 String txPortName, String rxPortDeviceName, String rxPortName) {
237 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
238 .setOpticType(OpticTypes.Gray)
239 .setServiceFormat(ServiceFormat.Ethernet)
240 .setServiceRate(Uint32.valueOf(100))
241 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
242 .setPort(new PortBuilder()
243 .setPortDeviceName(txPortDeviceName)
244 .setPortName(txPortName)
245 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
247 .setPortType(TapiStringConstants.PORT_TYPE)
249 .setLgx(new LgxBuilder()
250 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
251 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
252 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
253 .setLgxPortShelf("00")
256 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
257 .setPort(new PortBuilder()
258 .setPortDeviceName(rxPortDeviceName)
259 .setPortName(rxPortName)
260 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
262 .setPortType(TapiStringConstants.PORT_TYPE)
264 .setLgx(new LgxBuilder()
265 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
266 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
267 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
268 .setLgxPortShelf("00")
274 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
278 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
279 // Get service path with the description in OR based models.
280 LOG.info("Service = {}", service);
281 Optional<ServicePaths> optServicePaths =
282 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
283 if (optServicePaths.isEmpty()) {
284 LOG.error("No service path found for service {}", service.getServiceName());
287 PathDescription pathDescription = optServicePaths.orElseThrow().getPathDescription();
288 LOG.info("Path description of service = {}", pathDescription);
289 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd =
290 service.getServiceAEnd();
292 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
293 EndPoint endPoint2 = mapServiceZEndPoint(service.getServiceZEnd(), pathDescription);
294 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>(Map.of(
295 endPoint1.key(), endPoint1,
296 endPoint2.key(), endPoint2));
297 LOG.info("EndPoints of connectivity services = {}", endPointMap);
300 new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName()).build();
301 // Connection creation
302 Map<ConnectionKey, Connection> connMap =
303 createConnectionsFromService(pathDescription, mapServiceLayerToAend(serviceAEnd));
304 LOG.debug("connectionMap for service {} = {} ", name, connMap);
305 ConnectivityConstraint conConstr =
306 new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build();
307 return new ConnectivityServiceBuilder()
308 .setAdministrativeState(AdministrativeState.UNLOCKED)
309 .setOperationalState(OperationalState.ENABLED)
310 .setLifecycleState(LifecycleState.INSTALLED)
312 UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8)).toString()))
313 .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
314 .setConnectivityConstraint(conConstr)
315 .setDirection(ForwardingDirection.BIDIRECTIONAL)
316 .setName(Map.of(name.key(), name))
317 .setConnection(connMap)
318 .setEndPoint(endPointMap)
322 public Map<ConnectionKey, Connection> createConnectionsFromService(
323 PathDescription pathDescription, LayerProtocolName lpn) {
324 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
325 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
326 // and the connections
328 List<String> xpdrClientTplist = new ArrayList<>();
329 List<String> xpdrNetworkTplist = new ArrayList<>();
330 List<String> rdmAddDropTplist = new ArrayList<>();
331 List<String> rdmDegTplist = new ArrayList<>();
332 List<String> rdmNodelist = new ArrayList<>();
333 List<String> xpdrNodelist = new ArrayList<>();
334 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
335 .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
336 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
337 switch (resourceType) {
338 case TapiStringConstants.TP:
339 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
340 String tpID = tp.getTpId();
342 if (tpID.contains("CLIENT")) {
343 tpNode = tp.getTpNodeId();
344 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
345 xpdrClientTplist.add(String.join("+", tpNode, tpID));
348 if (tpID.contains("NETWORK")) {
349 tpNode = tp.getTpNodeId();
350 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
351 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
354 if (tpID.contains("PP")) {
355 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
356 LOG.info("ROADM Node of tp = {}", tpNode);
357 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
358 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
361 if (tpID.contains("TTP")) {
362 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
363 LOG.info("ROADM Node of tp = {}", tpNode);
364 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
365 rdmDegTplist.add(String.join("+", tpNode, tpID));
369 case TapiStringConstants.NODE:
370 Node node = (Node) elem.getResource().getResource();
371 String nodeId = node.getNodeId();
372 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
373 LOG.info("Node id = {}", nodeId);
374 if (!xpdrNodelist.contains(nodeId)) {
375 xpdrNodelist.add(nodeId); // should contain only 2
378 if (nodeId.contains("ROADM")) {
379 nodeId = getIdBasedOnModelVersion(nodeId);
380 LOG.info("Node id = {}", nodeId);
381 if (!rdmNodelist.contains(nodeId)) {
382 rdmNodelist.add(nodeId);
387 LOG.warn("Resource is a {}", resourceType);
390 LOG.info("ROADM node list = {}", rdmNodelist);
391 LOG.info("ROADM degree list = {}", rdmDegTplist);
392 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
393 LOG.info("XPDR node list = {}", xpdrNodelist);
394 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
395 LOG.info("XPDR client list = {}", xpdrClientTplist);
396 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
397 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
398 // to trigger all the steps or not
399 String edgeRoadm1 = "";
400 String edgeRoadm2 = "";
401 if (!rdmNodelist.isEmpty()) {
402 edgeRoadm1 = rdmNodelist.get(0);
403 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
404 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
405 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
407 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
408 // CEPs must be included in the topology context as an augmentation for each ONEP!!
409 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
410 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
411 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
412 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
415 // Identify number of ROADMs
416 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
417 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
418 // - In Roadms, only one NEP modeled for both OTSi_MC and MC on both TTP and PPs.
419 // - Changed naming convention of CEPs and connections, to include the frequency and allow several
420 // - OTSiMC and MC Ceps to be attached to the same NEP and support all related connections (1/Lambda)
421 // - Top Connection MC between MC CEPs of different roadms
422 // - Top Connection OTSiMC between OTSiMC CEPs of extreme roadms
423 LOG.debug("CONNECTIVITYUTILS 422 SpectralIndexLow = {}, High = {}",
424 GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection()
425 .getAToZMinFrequency().getValue()),
426 GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection()
427 .getAToZMinFrequency().getValue()));
428 connectionServMap.putAll(
429 createRoadmCepsAndConnections(
430 GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection()
431 .getAToZMinFrequency().getValue()),
432 GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection()
433 .getAToZMaxFrequency().getValue()),
434 rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
435 LOG.debug("CONNECTIVITYUTILS 434 Connservmap = {}", connectionServMap);
436 if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
437 .contains("ROADM")) {
438 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
439 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
440 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(
441 GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection()
442 .getAToZMinFrequency().getValue()),
443 GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection()
444 .getAToZMaxFrequency().getValue()),
445 xpdrNetworkTplist, xpdrNodelist));
446 LOG.debug("CONNECTIVITYUTILS 445 Connservmap = {}", connectionServMap);
448 this.topConnRdmRdm = null;
451 // TODO: verify if this is correct
452 // - XC Connection OTSi between iODU and eODU of xpdr
453 // - Top connection in the ODU layer, between xpdr eODU ports (?)
454 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
455 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
456 this.topConnXpdrXpdrPhtn = null;
460 // Check if OC, OTU and ODU are created
461 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
462 LOG.info("WDM ETH service");
463 connectionServMap.putAll(
464 createRoadmCepsAndConnections(
465 GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection()
466 .getAToZMinFrequency().getValue()),
467 GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection()
468 .getAToZMaxFrequency().getValue()),
469 rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1,
471 connectionServMap.putAll(
472 createXpdrCepsAndConnectionsPht(
473 GridUtils.getLowerSpectralIndexFromFrequency(pathDescription.getAToZDirection()
474 .getAToZMinFrequency().getValue()),
475 GridUtils.getHigherSpectralIndexFromFrequency(pathDescription.getAToZDirection()
476 .getAToZMaxFrequency().getValue()),
477 xpdrNetworkTplist, xpdrNodelist));
478 this.topConnRdmRdm = null;
479 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
480 LOG.info("Associated client ports = {}", xpdrClientTplist);
481 connectionServMap.putAll(
482 createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist, connectionServMap));
483 this.topConnXpdrXpdrPhtn = null;
487 LOG.info("OTN XGE/ODUe service");
488 // - XC connection between iODU and eODU
489 // - Top connection between eODU ports
490 // - Top connection between DSR ports
491 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
492 // - XC Connection OTSi between iODU and eODU of xpdr
493 // - Top connection in the ODU layer, between xpdr eODU ports (?)
494 connectionServMap.putAll(
495 createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
496 this.topConnXpdrXpdrPhtn = null;
498 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
499 connectionServMap.putAll(
500 createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
501 this.topConnXpdrXpdrOdu = null;
505 LOG.error("Service type format not supported");
507 LOG.debug("CONNSERVERMAP 508 = {}", connectionServMap);
508 return connectionServMap;
511 private void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) {
512 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
513 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
514 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class)
515 .child(Topology.class, new TopologyKey(topoUuid))
516 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
517 new NodeKey(nodeUuid))
518 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
521 Optional<OwnedNodeEdgePoint> optionalOnep =
522 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
523 if (optionalOnep.isPresent()) {
524 LOG.error("ONEP is already present in datastore");
527 // merge in datastore
528 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onep);
529 this.networkTransactionService.commit().get();
530 LOG.info("NEP {} added successfully.", onep.getName());
531 } catch (InterruptedException | ExecutionException e) {
532 LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName(), e);
536 public Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
537 .connectivity.context.ConnectionKey,
538 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
539 .connectivity.context.Connection> getConnectionFullMap() {
540 return this.connectionFullMap;
543 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
544 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
545 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
546 .create.connectivity.service.input.EndPointKey,
547 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
548 .create.connectivity.service.input.EndPoint> endPointMap = input.getEndPoint();
549 ConnectionType connType = null;
550 ServiceFormat serviceFormat = null;
551 String nodeAid = String.join("+",
552 endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
553 TapiStringConstants.XPDR);
554 String nodeZid = String.join("+",
555 endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
556 TapiStringConstants.XPDR);
557 LOG.info("NodeAid = {}", nodeAid);
558 LOG.info("NodeZid = {}", nodeZid);
559 //switch (constraint.getServiceLayer().getIntValue()) {
560 switch (input.getLayerProtocolName().getIntValue()) {
563 connType = ConnectionType.Infrastructure;
564 serviceFormat = ServiceFormat.ODU;
567 LOG.info("ETH, no need to create OTU and ODU");
568 connType = ConnectionType.Service;
569 serviceFormat = ServiceFormat.Ethernet;
572 LOG.info("DSR, need to create OTU and ODU");
573 connType = ConnectionType.Service;
574 serviceFormat = ServiceFormat.Ethernet;
577 LOG.info("PHOTONIC");
578 connType = getConnectionTypePhtnc(endPointMap.values());
579 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
580 LOG.debug("Node a photonic = {}", nodeAid);
581 LOG.debug("Node z photonic = {}", nodeZid);
584 LOG.info("Service type {} not supported", input.getLayerProtocolName().getName());
586 // Requested Capacity for connectivity service
587 Uint64 capacity = Uint64.valueOf(Math.abs(
588 input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
589 // map endpoints into service end points. Map the type of service from TAPI to OR
590 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(
591 endPointMap.values().stream().findFirst().orElseThrow(),
592 serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
593 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(
594 endPointMap.values().stream().skip(1).findFirst().orElseThrow(),
595 serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
596 if (serviceAEnd == null || serviceZEnd == null) {
597 LOG.error("Couldnt map endpoints to service end");
600 LOG.info("Service a end = {}", serviceAEnd);
601 LOG.info("Service z end = {}", serviceZEnd);
602 return new ServiceCreateInputBuilder()
603 .setServiceAEnd(serviceAEnd)
604 .setServiceZEnd(serviceZEnd)
605 .setConnectionType(connType)
606 .setServiceName(serviceUuid.getValue())
607 .setCommonId("common id")
608 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
609 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
610 .setRequestSystemId("appname")
612 .setCustomer("customer")
613 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
614 .setOperatorContact("pw1234")
618 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
619 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
620 return new ServiceAEndBuilder(sepA.getValue()).build();
622 if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
623 return new ServiceAEndBuilder(sepZ.getValue()).build();
628 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
629 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
630 return new ServiceZEndBuilder(sepA.getValue()).build();
632 if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
633 return new ServiceZEndBuilder(sepZ.getValue()).build();
638 private LayerProtocolName mapServiceLayerToAend(
639 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
640 .service.ServiceAEnd serviceAEnd) {
641 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
642 switch (serviceFormat) {
645 return LayerProtocolName.PHOTONICMEDIA;
647 return LayerProtocolName.ODU;
649 if (getOpenroadmType(
650 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()
651 .getPort().getPortDeviceName())
652 .equals(OpenroadmNodeType.TPDR)) {
653 return LayerProtocolName.ETH;
655 return LayerProtocolName.DSR;
657 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
662 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
663 switch (serviceFormat) {
666 return LayerProtocolName.PHOTONICMEDIA;
668 return LayerProtocolName.ODU;
670 String node1 = endPoint1.getLocalId();
671 String node2 = endPoint2.getLocalId();
672 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
673 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
674 return LayerProtocolName.ETH;
676 return LayerProtocolName.DSR;
678 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
683 private OpenroadmNodeType getOpenroadmType(String nodeName) {
684 LOG.info("Node name = {}", nodeName);
685 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode =
686 this.tapiContext.getTapiNode(
688 new Uuid(UUID.nameUUIDFromBytes(
689 (String.join("+",nodeName, TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
691 return tapiNode == null
693 : OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type")).getValue());
696 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(
697 List<String> xpdrClientTplist, List<String> xpdrNodelist, Map<ConnectionKey, Connection> lowerConn) {
698 // TODO: do we need to create cross connection between iODU and eODU??
699 // add the lower connections of the previous steps for this kind of service
700 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
701 for (Connection lowConn: lowerConn.values()) {
702 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
703 xcMap.put(conn.key(), conn);
705 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
706 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
707 // Create 1 cep per Xpdr in the CLIENT
708 // 1 top connection DSR between the CLIENT xpdrs
709 for (String xpdr:xpdrNodelist) {
710 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
711 String spcXpdrClient =
712 xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
713 ConnectionEndPoint netCep1 =
714 createCepXpdr(0, 0, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
715 LayerProtocolName.DSR);
716 putXpdrCepInTopologyContext(
717 xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, netCep1);
718 cepMapDsr.put(netCep1.key(), netCep1);
720 // DSR top connection between edge xpdr CLIENT DSR
721 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
722 .connectivity.context.Connection connectionDsr =
725 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
726 .findFirst().orElseThrow(),
728 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
729 .findFirst().orElseThrow(),
730 cepMapDsr, TapiStringConstants.DSR, LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
731 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
732 // DSR top connection that will be added to the service object
733 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
734 return new HashMap<>(Map.of(conn1.key(), conn1));
737 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(
738 List<String> xpdrClientTplist, List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
739 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
740 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
741 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
742 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
743 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapOdu = new HashMap<>();
744 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
745 // be added to the lower connection of a top connection
746 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
748 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
749 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
750 for (String xpdr:xpdrNodelist) {
751 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
752 String spcXpdrClient =
753 xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
754 ConnectionEndPoint clientCep1 =
756 spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
757 putXpdrCepInTopologyContext(
758 xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, clientCep1);
759 ConnectionEndPoint clientCep2 = createCepXpdr(0, 0, spcXpdrClient, TapiStringConstants.E_ODU,
760 TapiStringConstants.XPDR, LayerProtocolName.ODU);
761 putXpdrCepInTopologyContext(
762 xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, clientCep2);
763 cepMapDsr.put(clientCep1.key(), clientCep1);
764 cepMapOdu.put(clientCep2.key(), clientCep2);
766 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
767 // Create x connection between I_ODU and E_ODU within xpdr
768 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
769 .connectivity.context.Connection connection =
771 clientCep2, getAssociatediODUCep(spcXpdrNetwork),
772 spcXpdrClient, spcXpdrNetwork, TapiStringConstants.ODU, LayerProtocolName.ODU);
773 this.connectionFullMap.put(connection.key(), connection);
775 // Create X connection that will be added to the service object
776 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
777 xcMap.put(conn.key(), conn);
780 // DSR top connection between edge xpdr CLIENT DSR
782 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
783 .findFirst().orElseThrow();
785 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
786 .findFirst().orElseThrow();
788 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
789 .connectivity.context.Connection connectionOdu =
791 spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
792 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
793 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
795 // ODU top connection that will be added to the service object
796 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
797 connServMap.put(conn.key(), conn);
798 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
799 xcMap.put(lowerConn.key(), lowerConn);
801 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
802 .connectivity.context.Connection connectionDsr =
804 spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
805 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
806 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
807 // DSR top connection that will be added to the service object
808 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
809 connServMap.put(conn1.key(), conn1);
813 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(
814 List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
815 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
816 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
817 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
818 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
819 // be added to the lower connection of a top connection
820 // Create 1 cep per Xpdr in the I_ODU and a top
821 // connection iODU between the xpdrs
822 for (String xpdr:xpdrNodelist) {
823 LOG.info("Creating iODU ceps and xc for xpdr {}", xpdr);
824 String spcXpdrNetwork =
825 xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
826 ConnectionEndPoint netCep1 =
828 spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
829 putXpdrCepInTopologyContext(
830 xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, netCep1);
831 cepMap.put(netCep1.key(), netCep1);
833 // ODU top connection between edge xpdr i_ODU
834 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
835 .connectivity.context.Connection connection =
838 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
839 .findFirst().orElseThrow(),
841 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
842 .findFirst().orElseThrow(),
843 cepMap, TapiStringConstants.I_ODU,
844 LayerProtocolName.ODU, new HashMap<>(), this.topConnXpdrXpdrPhtn);
845 this.connectionFullMap.put(connection.key(), connection);
846 // ODU top connection that will be added to the service object
847 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
848 connServMap.put(conn.key(), conn);
849 this.topConnXpdrXpdrOdu = conn;
853 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(int lowerFreqIndex, int higherFreqIndex,
854 List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
855 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
856 // be added to the lower connection of a top connection
857 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
858 ConnectionEndPoint> cepMap = new HashMap<>();
859 // create ceps and x connections within xpdr
860 LOG.debug("CONNECTIVITYUTILS 866 CreateXpdrCep1ConnPht");
861 String slotFreqExtension = "";
862 for (String xpdr:xpdrNodelist) {
863 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
864 String spcXpdrNetwork =
865 xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
866 // There should be 1 network tp per xpdr
867 // Just create 2 different CEPs (1 OTS + 1 OTSI_MC)
868 ConnectionEndPoint netCep1 = createCepXpdr(0, 0,
869 spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
870 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
871 putXpdrCepInTopologyContext(
872 xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, netCep1);
873 ConnectionEndPoint netCep2 = createCepXpdr(lowerFreqIndex, higherFreqIndex,
874 spcXpdrNetwork, TapiStringConstants.OTSI_MC,
875 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
876 putXpdrCepInTopologyContext(
877 xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, netCep2);
878 cepMap.put(netCep1.key(), netCep1);
879 cepMap.put(netCep2.key(), netCep2);
880 slotFreqExtension = "[" + netCep2.getName().entrySet().iterator().next().getValue().getValue()
884 LOG.debug("CONNECTIVITYUTILS 894 CreateXpdrCep1ConnPht");
885 // OTSi top connection between edge OTSI_MC Xpdr
886 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
887 .connectivity.context.Connection connection =
889 String.join("-", xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
890 .findFirst().orElseThrow(), slotFreqExtension),
891 String.join("-", xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
892 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow(), slotFreqExtension),
893 cepMap, TapiStringConstants.OTSI_MC,
894 LayerProtocolName.PHOTONICMEDIA, new HashMap<>(), this.topConnRdmRdm);
895 this.connectionFullMap.put(connection.key(), connection);
896 // OTSi top connection that will be added to the service object
897 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
898 this.topConnXpdrXpdrPhtn = conn;
899 LOG.info("ReturnedMap904 {}", new HashMap<>(Map.of(conn.key(), conn)));
900 return new HashMap<>(Map.of(conn.key(), conn));
903 private Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
904 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> createRoadmCepsAndClientNeps(String roadm,
905 int lowerFreqIndex, int higherFreqIndex, String rdmTp, boolean withOMS) {
906 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
907 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
908 String clientQualifier = "";
909 // Create 3 CEPs (OTS, MC, OTSi_MC) for ADD and (OMS, MC, OTSi_MC) for DEG and add them to CepMap
912 // WithOMS is true for degree for which OTS Cep is created during link discovery/update
913 clientQualifier = TapiStringConstants.MC;
914 OwnedNodeEdgePoint onepMC = tapiFactory.createRoadmNep(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1],
915 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
916 putRdmNepInTopologyContext(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1], TapiStringConstants.MC, onepMC);
918 // WithOMS is false for Add/drop ports for which no OTS was created during initial mapping
919 ConnectionEndPoint rdmCep0 = tapiFactory.createCepRoadm(0, 0, rdmTp,
920 TapiStringConstants.PHTNC_MEDIA_OTS, null);
921 putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.PHTNC_MEDIA_OTS, rdmCep0);
922 cepMap.put(rdmCep0.key(), rdmCep0);
925 clientQualifier = TapiStringConstants.OTSI_MC;
926 OwnedNodeEdgePoint onepOTSiMC = tapiFactory.createRoadmNep(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1],
927 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
928 putRdmNepInTopologyContext(rdmTp.split("\\+")[0], rdmTp.split("\\+")[1],
929 TapiStringConstants.OTSI_MC, onepOTSiMC);
930 ConnectionEndPoint rdmCep2 = tapiFactory.createCepRoadm(lowerFreqIndex, higherFreqIndex, rdmTp,
931 TapiStringConstants.MC, null);
932 putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.MC, rdmCep2);
933 cepMap.put(rdmCep2.key(), rdmCep2);
935 ConnectionEndPoint rdmCep3 = tapiFactory.createCepRoadm(lowerFreqIndex, higherFreqIndex, rdmTp,
936 TapiStringConstants.OTSI_MC, null);
937 putRdmCepInTopologyContext(roadm, rdmTp, TapiStringConstants.OTSI_MC, rdmCep3);
938 cepMap.put(rdmCep3.key(), rdmCep3);
942 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(int lowerFreqIndex, int higherFreqIndex,
943 List<String> rdmAddDropTplist, List<String> rdmDegTplist, List<String> rdmNodelist,
944 String edgeRoadm1, String edgeRoadm2) {
946 Map<ConnectionEndPointKey, ConnectionEndPoint> intermediateCepMap = new HashMap<>();
947 LOG.debug("IntermediateCepMap {}", intermediateCepMap);
948 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
949 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
950 // create ceps and x connections within roadm
951 Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
952 String slotFreqExtension = "[" + lowerFreqIndex + "-" + higherFreqIndex + "]";
953 LOG.debug("slotFreqExtension in createRoadmCepsAndConnections is {}", slotFreqExtension);
954 for (String roadm : rdmNodelist) {
955 LOG.info("Creating ceps and xc for roadm {}", roadm);
956 if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
957 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
958 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm))
959 .findFirst().orElseThrow();
960 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
961 // Create CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
962 // created in the topology creation
963 // add CEPs to the topology to the corresponding ONEP
964 intermediateCepMap = createRoadmCepsAndClientNeps(
965 roadm, lowerFreqIndex, higherFreqIndex, spcRdmAD, false);
966 ConnectionEndPoint adCepMC = intermediateCepMap.entrySet().stream().filter(
967 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE))
968 .findFirst().orElseThrow().getValue();
969 LOG.debug("adCepMC is {}", adCepMC);
970 ConnectionEndPoint adCepOTSiMC = intermediateCepMap.entrySet().stream().filter(
971 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE))
972 .findFirst().orElseThrow().getValue();
973 LOG.debug("adCepOTSiMC is {}", adCepOTSiMC);
974 cepMap.putAll(intermediateCepMap);
975 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
976 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
977 intermediateCepMap = createRoadmCepsAndClientNeps(
978 roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG, true);
979 ConnectionEndPoint degCepMC = intermediateCepMap.entrySet().stream().filter(
980 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE))
981 .findFirst().orElseThrow().getValue();
982 LOG.debug("degCepMC is {}", degCepMC);
983 ConnectionEndPoint degCepOTSiMC = intermediateCepMap.entrySet().stream().filter(
984 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE))
985 .findFirst().orElseThrow().getValue();
986 LOG.debug("degCepOTSiMC is {}", degCepOTSiMC);
987 cepMap.putAll(intermediateCepMap);
988 LOG.info("Going to create cross connections for ROADM {}", roadm);
989 // Create X connections between MC and OTSi_MC for full map
990 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
991 .connectivity.context.Connection connection1 =
993 adCepMC, degCepMC, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
994 LayerProtocolName.PHOTONICMEDIA);
995 LOG.info("Cross connection 1 created = {}", connection1);
996 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
997 .connectivity.context.Connection connection2 =
999 adCepOTSiMC, degCepOTSiMC, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
1000 LayerProtocolName.PHOTONICMEDIA);
1001 LOG.info("Cross connection 2 created = {}", connection2);
1002 this.connectionFullMap.put(connection1.key(), connection1);
1003 this.connectionFullMap.put(connection2.key(), connection2);
1005 // Create X connections that will be added to the service object
1006 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1007 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
1009 xcLowerMap.put(conn1.key(), conn1);
1010 xcLowerMap.put(conn2.key(), conn2);
1012 LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
1013 String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
1014 LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
1015 intermediateCepMap = createRoadmCepsAndClientNeps(
1016 roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG1, true);
1017 ConnectionEndPoint deg1CepMC = intermediateCepMap.entrySet().stream().filter(
1018 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE))
1019 .findFirst().orElseThrow().getValue();
1020 LOG.debug("deg1CepMC is {}", deg1CepMC);
1021 ConnectionEndPoint deg1CepOTSiMC = intermediateCepMap.entrySet().stream().filter(
1022 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE))
1023 .findFirst().orElseThrow().getValue();
1024 LOG.debug("deg1CepOTSiMC is {}", deg1CepOTSiMC);
1025 cepMap.putAll(intermediateCepMap);
1028 rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().orElseThrow();
1029 LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
1030 intermediateCepMap = createRoadmCepsAndClientNeps(
1031 roadm, lowerFreqIndex, higherFreqIndex, spcRdmDEG2, true);
1032 ConnectionEndPoint deg2CepMC = intermediateCepMap.entrySet().stream().filter(
1033 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIERMC.VALUE))
1034 .findFirst().orElseThrow().getValue();
1035 LOG.debug("deg2CepMC is {}", deg2CepMC);
1036 ConnectionEndPoint deg2CepOTSiMC = intermediateCepMap.entrySet().stream().filter(
1037 cep -> cep.getValue().getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTSiMC.VALUE))
1038 .findFirst().orElseThrow().getValue();
1039 LOG.debug("deg2CepOTSiMC is {}", deg2CepOTSiMC);
1040 cepMap.putAll(intermediateCepMap);
1042 LOG.info("Going to create cross connections for ROADM {}", roadm);
1043 // Create X connections between MC and OTSi_MC for full map
1044 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1045 .connectivity.context.Connection connection1 =
1046 createXCBetweenCeps(
1047 deg1CepMC, deg2CepMC, spcRdmDEG1, spcRdmDEG2,
1048 TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
1049 LOG.info("Cross connection 1 created = {}", connection1);
1050 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1051 .connectivity.context.Connection connection2 =
1052 createXCBetweenCeps(
1053 deg1CepOTSiMC, deg2CepOTSiMC, spcRdmDEG1, spcRdmDEG2,
1054 TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
1055 LOG.info("Cross connection 2 created = {}", connection2.toString());
1056 this.connectionFullMap.put(connection1.key(), connection1);
1057 this.connectionFullMap.put(connection2.key(), connection2);
1059 // Create X connections that will be added to the service object
1060 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1061 xcLowerMap.put(conn1.key(), conn1);
1062 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
1063 xcLowerMap.put(conn2.key(), conn2);
1066 LOG.info("Going to create top connections between roadms");
1067 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
1068 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
1069 // MC top connection between edge roadms
1070 LOG.info("Going to created top connection between MC");
1071 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1072 .connectivity.context.Connection connection =
1073 createTopConnection(String.join("-", spcRdmAD1, slotFreqExtension),
1074 String.join("-", spcRdmAD2, slotFreqExtension), cepMap, TapiStringConstants.MC,
1075 LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
1076 this.connectionFullMap.put(connection.key(), connection);
1077 LOG.info("Top connection created = {}", connection);
1079 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1080 // OTSiMC top connection between edge roadms
1081 LOG.debug("Going to created top connection between OTSiMC");
1082 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1083 .connectivity.context.Connection connection1 =
1084 createTopConnection(String.join("-", spcRdmAD1, slotFreqExtension),
1085 String.join("-", spcRdmAD2, slotFreqExtension), cepMap, TapiStringConstants.OTSI_MC,
1086 LayerProtocolName.PHOTONICMEDIA,
1088 new HashMap<>(Map.of(conn1.key(), conn1)),
1090 this.connectionFullMap.put(connection1.key(), connection1);
1091 LOG.info("Top connection OTSiMC created = {}", connection1);
1092 LOG.debug("Map of All connections = {}", this.connectionFullMap);
1094 // OTSiMC top connections that will be added to the service object
1095 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1096 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1097 this.topConnRdmRdm = conn2;
1098 LOG.debug("ReturnedMap1102 {}", new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2)));
1099 return new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2));
1102 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1103 .connectivity.context.Connection createTopConnection(
1106 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1107 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap,
1108 String qual, LayerProtocolName topPortocol,
1109 Map<LowerConnectionKey, LowerConnection> xcMap,
1110 Connection additionalLowerConn) {
1111 // find cep for each AD MC of roadm 1 and 2
1112 String topConnName = String.join("+", "TOP", tp1, tp2, qual);
1113 LOG.info("Creation of Top connection, name = {}", topConnName);
1114 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 =
1116 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1117 .cep.list.ConnectionEndPointKey(new Uuid(UUID.nameUUIDFromBytes(
1118 (String.join("+", "CEP", tp1.split("\\+")[0], qual, tp1.split("\\+")[1]))
1119 .getBytes(StandardCharsets.UTF_8)).toString())));
1120 LOG.debug("ADCEP1 = {}", adCep1);
1121 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1122 .connection.ConnectionEndPoint cep1 =
1123 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1124 .connection.ConnectionEndPointBuilder()
1125 .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1126 .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
1127 .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
1128 .setConnectionEndPointUuid(adCep1.getUuid())
1130 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
1132 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1133 .cep.list.ConnectionEndPointKey(
1134 new Uuid(UUID.nameUUIDFromBytes(
1135 (String.join("+", "CEP", tp2.split("\\+")[0], qual, tp2.split("\\+")[1]))
1136 .getBytes(StandardCharsets.UTF_8)).toString())));
1137 LOG.debug("ADCEP2 = {}", adCep2);
1138 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1139 .connection.ConnectionEndPoint cep2 =
1140 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1141 .connection.ConnectionEndPointBuilder()
1142 .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1143 .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
1144 .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
1145 .setConnectionEndPointUuid(adCep1.getUuid())
1147 Name connName = new NameBuilder()
1148 .setValueName("Connection name")
1149 .setValue(topConnName)
1151 // TODO: lower connection, supported link.......
1152 if (additionalLowerConn != null) {
1153 xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
1154 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
1156 return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1157 .connectivity.context.ConnectionBuilder()
1158 .setUuid(new Uuid(UUID.nameUUIDFromBytes(topConnName.getBytes(StandardCharsets.UTF_8)).toString()))
1159 .setName(Map.of(connName.key(), connName))
1160 .setConnectionEndPoint(new HashMap<>(Map.of(cep1.key(), cep1, cep2.key(), cep2)))
1161 .setOperationalState(OperationalState.ENABLED)
1162 .setLayerProtocolName(topPortocol)
1163 .setLifecycleState(LifecycleState.INSTALLED)
1164 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1165 .setLowerConnection(xcMap)
1169 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1170 .connectivity.context.Connection createXCBetweenCeps(
1171 ConnectionEndPoint cep1, ConnectionEndPoint cep2,
1172 String tp1, String tp2, String qual, LayerProtocolName xcProtocol) {
1173 String crossConnName = String.join("+", "XC", cep1.getName().entrySet().iterator().next().getValue().getValue(),
1174 cep2.getName().entrySet().iterator().next().getValue().getValue());
1175 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
1176 LOG.info("CONNECTIVITYUTILS 1145 : Cross connection name = {}", crossConnName);
1177 LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint());
1178 LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint());
1179 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1180 .connection.ConnectionEndPoint cepServ1 =
1181 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1182 .connection.ConnectionEndPointBuilder()
1183 .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1184 .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
1185 .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
1186 .setConnectionEndPointUuid(cep1.getUuid())
1188 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1189 .connection.ConnectionEndPoint cepServ2 =
1190 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1191 .connection.ConnectionEndPointBuilder()
1192 .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1193 .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
1194 .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
1195 .setConnectionEndPointUuid(cep2.getUuid())
1197 Name connName = new NameBuilder()
1198 .setValueName("Connection name")
1199 .setValue(crossConnName)
1201 // TODO: lower connection, supported link.......
1202 return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1203 .connectivity.context.ConnectionBuilder()
1204 .setUuid(new Uuid(UUID.nameUUIDFromBytes(crossConnName.getBytes(StandardCharsets.UTF_8)).toString()))
1205 .setName(Map.of(connName.key(), connName))
1206 .setConnectionEndPoint(new HashMap<>(Map.of(cepServ1.key(), cepServ1, cepServ2.key(), cepServ2)))
1207 .setOperationalState(OperationalState.ENABLED)
1208 .setLayerProtocolName(xcProtocol)
1209 .setLifecycleState(LifecycleState.INSTALLED)
1210 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1214 private ConnectionEndPoint createCepXpdr(int lowerFreqIndex, int higherFreqIndex,
1215 String id, String qualifier, String nodeLayer, LayerProtocolName cepProtocol) {
1216 String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]);
1217 String nepNodeId = String.join("+",id.split("\\+")[0], TapiStringConstants.XPDR);
1218 String extendedNepId = (lowerFreqIndex == 0 && higherFreqIndex == 0)
1220 : String.join("-",nepId, ("[" + lowerFreqIndex + "-" + higherFreqIndex + "]"));
1221 LOG.debug("CONNECTIVITYUTILS 1307 CreateCepXpdr {}", extendedNepId);
1222 Name cepName = new NameBuilder()
1223 .setValueName("ConnectionEndPoint name")
1224 .setValue(extendedNepId)
1226 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1227 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1228 nepId.getBytes(StandardCharsets.UTF_8)).toString()))
1229 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1230 nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
1231 .setTopologyUuid(this.tapiTopoUuid)
1233 String clientQualifier = "";
1234 switch (qualifier) {
1235 case TapiStringConstants.PHTNC_MEDIA_OTS:
1236 clientQualifier = TapiStringConstants.OTSI_MC;
1238 case TapiStringConstants.OTSI_MC:
1239 clientQualifier = TapiStringConstants.E_ODU;
1241 case TapiStringConstants.E_ODU:
1242 clientQualifier = TapiStringConstants.DSR;
1245 LOG.debug("no client CEP for DSR NEP {}", nepId);
1248 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1249 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1250 (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
1251 .getBytes(StandardCharsets.UTF_8)).toString()))
1252 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1253 nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
1254 .setTopologyUuid(this.tapiTopoUuid)
1256 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1257 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1258 .setUuid(new Uuid(UUID.nameUUIDFromBytes(
1259 (String.join("+", "CEP", extendedNepId))
1260 .getBytes(StandardCharsets.UTF_8)).toString()))
1261 .setParentNodeEdgePoint(pnep)
1262 .setName(Map.of(cepName.key(), cepName))
1263 .setConnectionPortRole(PortRole.SYMMETRIC)
1264 .setDirection(Direction.BIDIRECTIONAL)
1265 .setOperationalState(OperationalState.ENABLED)
1266 .setLifecycleState(LifecycleState.INSTALLED)
1267 .setLayerProtocolName(cepProtocol);
1268 return TapiStringConstants.DSR.equals(qualifier)
1270 : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
1273 private EndPoint mapServiceZEndPoint(
1274 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
1275 .service.ServiceZEnd serviceZEnd, PathDescription pathDescription) {
1276 EndPointBuilder endPointBuilder = new EndPointBuilder();
1277 // 1. Service Format: ODU, OTU, ETH
1278 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1279 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1280 // Identify SIP name
1281 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1282 LOG.info("Uuid of z end {}", sipUuid);
1283 LayerProtocolName layerProtocols = null;
1284 // Layer protocol name
1285 switch (serviceFormat) {
1287 layerProtocols = LayerProtocolName.DSR;
1291 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1294 layerProtocols = LayerProtocolName.ODU;
1297 LOG.error("Service Format not supported");
1299 var portZEnd = serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
1300 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1301 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1302 .setValueName("OpenROADM info")
1303 .setValue(String.join("-", serviceZEnd.getClli(), portZEnd.getPortDeviceName(), portZEnd.getPortName()))
1305 return endPointBuilder
1306 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1307 .setServiceInterfacePointUuid(sipUuid)
1309 .setName(Map.of(name.key(), name))
1310 .setAdministrativeState(AdministrativeState.UNLOCKED)
1311 .setDirection(Direction.BIDIRECTIONAL)
1312 .setLifecycleState(LifecycleState.INSTALLED)
1313 .setOperationalState(OperationalState.ENABLED)
1314 .setLayerProtocolName(layerProtocols)
1315 .setCapacity(new CapacityBuilder()
1316 .setTotalSize(new TotalSizeBuilder()
1317 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
1318 .setUnit(CAPACITYUNITGBPS.VALUE)
1320 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1322 .setProtectionRole(ProtectionRole.WORK)
1323 .setRole(PortRole.SYMMETRIC)
1324 .setLocalId(portZEnd.getPortDeviceName())
1328 private EndPoint mapServiceAEndPoint(
1329 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
1330 serviceAEnd, PathDescription pathDescription) {
1331 EndPointBuilder endPointBuilder = new EndPointBuilder();
1332 // 1. Service Format: ODU, OTU, ETH
1333 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1334 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1335 // Identify SIP name
1336 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1337 LOG.info("Uuid of a end {}", sipUuid);
1338 LayerProtocolName layerProtocols = null;
1339 // Layer protocol name
1340 switch (serviceFormat) {
1342 layerProtocols = LayerProtocolName.DSR;
1346 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1349 layerProtocols = LayerProtocolName.ODU;
1352 LOG.error("Service Format not supported");
1354 var portAEnd = serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
1355 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1356 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1357 .setValueName("OpenROADM info")
1358 .setValue(String.join("-", serviceAEnd.getClli(), portAEnd.getPortDeviceName(), portAEnd.getPortName()))
1360 return endPointBuilder
1361 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1362 .setServiceInterfacePointUuid(sipUuid)
1364 .setName(Map.of(name.key(), name))
1365 .setAdministrativeState(AdministrativeState.UNLOCKED)
1366 .setDirection(Direction.BIDIRECTIONAL)
1367 .setLifecycleState(LifecycleState.INSTALLED)
1368 .setOperationalState(OperationalState.ENABLED)
1369 .setLayerProtocolName(layerProtocols)
1370 .setCapacity(new CapacityBuilder()
1371 .setTotalSize(new TotalSizeBuilder()
1372 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceAEnd.getServiceRate().doubleValue())))
1373 .setUnit(CAPACITYUNITGBPS.VALUE)
1375 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1377 .setProtectionRole(ProtectionRole.WORK)
1378 .setRole(PortRole.SYMMETRIC)
1379 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1380 .getPortDeviceName())
1384 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1385 if (serviceNodeId.contains("ROADM")) {
1386 // Service from ROADM to ROADM
1387 // AddDrop-AddDrop ports --> MC layer SIPs
1389 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
1390 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1391 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1392 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
1393 .getBytes(StandardCharsets.UTF_8)).toString());
1394 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1395 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1396 if (sip.getUuid().equals(sipUuid)) {
1397 return sip.getUuid();
1399 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1403 // Service from XPDR to XPDR
1405 TerminationPoint tp;
1407 switch (serviceFormat) {
1410 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
1411 tp = (TerminationPoint) firstElement.getResource().getResource();
1412 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1413 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1414 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
1415 .getBytes(StandardCharsets.UTF_8)).toString());
1416 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
1420 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
1421 tp = (TerminationPoint) firstElement.getResource().getResource();
1422 // Network-Network ports --> iOTSi layer SIPs
1423 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1424 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
1425 .getBytes(StandardCharsets.UTF_8)).toString());
1426 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
1429 LOG.info("Elements ZA = {}", mapztoa.values());
1431 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
1432 tp = (TerminationPoint) firstElement.getResource().getResource();
1433 // Client-client ports --> DSR layer SIPs
1434 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1435 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
1436 .getBytes(StandardCharsets.UTF_8)).toString());
1437 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
1441 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1443 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1444 if (sip.getUuid().equals(sipUuid)) {
1445 return sip.getUuid();
1447 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1452 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1453 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1454 LOG.info("Map a to z = {}", mapatoz);
1455 if (serviceNodeId.contains("ROADM")) {
1456 // Service from ROADM to ROADM
1457 // AddDrop-AddDrop ports --> MC layer SIPs
1459 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
1460 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1461 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1462 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1463 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
1464 .getBytes(StandardCharsets.UTF_8)).toString());
1465 LOG.info("ROADM SIP name = {}",
1466 String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1467 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1468 if (sip.getUuid().equals(sipUuid)) {
1469 return sip.getUuid();
1471 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1475 // Service from XPDR to XPDR
1477 TerminationPoint tp;
1479 switch (serviceFormat) {
1482 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
1483 tp = (TerminationPoint) firstElement.getResource().getResource();
1484 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1485 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1486 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
1487 .getBytes(StandardCharsets.UTF_8)).toString());
1488 LOG.info("ODU XPDR SIP name = {}",
1489 String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
1493 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
1494 tp = (TerminationPoint) firstElement.getResource().getResource();
1495 // Network-Network ports --> iOTSi layer SIPs
1496 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1497 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
1498 .getBytes(StandardCharsets.UTF_8)).toString());
1499 LOG.info("OTU XPDR SIP name = {}",
1500 String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
1503 LOG.info("Elements AZ = {}", mapatoz.values());
1505 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
1506 tp = (TerminationPoint) firstElement.getResource().getResource();
1507 // Client-client ports --> DSR layer SIPs
1508 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1509 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
1510 .getBytes(StandardCharsets.UTF_8)).toString());
1511 LOG.info("DSR XPDR SIP name = {}",
1512 String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
1516 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1518 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1519 if (sip.getUuid().equals(sipUuid)) {
1520 return sip.getUuid();
1522 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1527 public void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1528 String nepId = String.join("+", node, qual, spcRdmAD.split("\\+")[1]);
1529 String nodeNepId = String.join("+", node, TapiStringConstants.PHTNC_MEDIA);
1530 LOG.info("NEP id before Merge = {}", nepId);
1531 LOG.info("Node of NEP id before Merge = {}", nodeNepId);
1532 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1533 this.tapiContext.updateTopologyWithCep(
1537 new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()),
1539 new Uuid(UUID.nameUUIDFromBytes(nepId.getBytes(StandardCharsets.UTF_8)).toString()),
1543 private void putXpdrCepInTopologyContext(
1544 String node, String spcXpdrNet, String qual, String nodeLayer, ConnectionEndPoint cep) {
1545 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1546 this.tapiContext.updateTopologyWithCep(
1550 new Uuid(UUID.nameUUIDFromBytes(
1551 String.join("+", node, nodeLayer).getBytes(StandardCharsets.UTF_8))
1554 new Uuid(UUID.nameUUIDFromBytes(
1555 String.join("+", node, qual, spcXpdrNet.split("\\+")[1]).getBytes(StandardCharsets.UTF_8))
1560 public void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
1561 String nepId = String.join("+", orNodeId, qual, orTpId);
1562 String nepNodeId = String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA);
1563 LOG.info("NEP id before Merge = {}", nepId);
1564 LOG.info("Node of NEP id before Merge = {}", nepNodeId);
1565 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1566 updateTopologyWithNep(
1570 new Uuid(UUID.nameUUIDFromBytes(
1571 nepNodeId.getBytes(Charset.forName("UTF-8")))
1574 new Uuid(UUID.nameUUIDFromBytes(
1575 nepId.getBytes(Charset.forName("UTF-8")))
1580 private String getIdBasedOnModelVersion(String nodeid) {
1581 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")
1582 ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
1583 : nodeid.split("-")[0];
1586 private ServiceZEnd tapiEndPointToServiceZPoint(
1587 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1588 .create.connectivity.service.input.EndPoint endPoint,
1589 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1590 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1591 // Not the rest which is needed in the txPortDeviceName.
1592 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1593 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1594 // Todo -> need to find the NEP associated to that SIP
1595 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString());
1596 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1597 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1599 LOG.error("Node not found in datastore");
1602 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1603 // connection is between 2 CLIENT ports. Otherwise it will not work...
1604 OwnedNodeEdgePoint nep = null;
1605 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1606 if (onep.getMappedServiceInterfacePoint() != null
1607 && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1613 LOG.error("Nep not found in datastore");
1616 String nodeName = "";
1618 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1619 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1620 endPoint.getName().entrySet()) {
1621 if (!("Node Type").equals(entry.getValue().getValueName())) {
1622 nodeName = entry.getValue().getValue();
1625 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1626 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1627 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1628 String txPortDeviceName = nepName.split("\\+")[0];
1629 String txPortName = nepName.split("\\+")[2];
1630 String rxPortDeviceName = txPortDeviceName;
1631 String rxPortName = txPortName;
1632 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1633 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1634 // TODO --> get clli from datastore?
1635 String clli = "NodeSC";
1636 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1637 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1638 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1640 .setNodeId(new NodeIdType(nodeid))
1641 .setOpticType(OpticTypes.Gray)
1642 .setServiceFormat(serviceFormat)
1643 .setServiceRate(Uint32.valueOf(capacity))
1644 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1645 .setCommittedBurstSize(Uint16.valueOf(64))
1646 .setCommittedInfoRate(Uint32.valueOf(100000))
1649 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1650 .setPort(new PortBuilder()
1651 .setPortDeviceName(txPortDeviceName)
1652 .setPortName(txPortName)
1653 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1655 .setPortType(TapiStringConstants.PORT_TYPE)
1657 .setLgx(new LgxBuilder()
1658 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1659 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1660 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1661 .setLgxPortShelf("00")
1663 .setIndex(Uint8.ZERO)
1665 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1666 .setPort(new PortBuilder()
1667 .setPortDeviceName(rxPortDeviceName)
1668 .setPortName(rxPortName)
1669 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1671 .setPortType(TapiStringConstants.PORT_TYPE)
1673 .setLgx(new LgxBuilder()
1674 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1675 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1676 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1677 .setLgxPortShelf("00")
1679 .setIndex(Uint8.ZERO)
1681 if (serviceFormat.equals(ServiceFormat.ODU)) {
1682 serviceZEndBuilder.setOduServiceRate(ODU4.VALUE);
1684 if (serviceFormat.equals(ServiceFormat.OTU)) {
1685 serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
1687 return serviceLayer.equals(LayerProtocolName.ETH)
1688 ? serviceZEndBuilder.build()
1689 : serviceZEndBuilder
1690 .setEthernetAttributes(new EthernetAttributesBuilder()
1691 .setSubrateEthSla(new SubrateEthSlaBuilder()
1692 .setCommittedBurstSize(Uint16.valueOf(64))
1693 .setCommittedInfoRate(Uint32.valueOf(100000))
1699 private ServiceAEnd tapiEndPointToServiceAPoint(
1700 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1701 .create.connectivity.service.input.EndPoint endPoint,
1702 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1703 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1704 // Not the rest which is needed in the txPortDeviceName.
1705 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1706 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1707 // Todo -> need to find the NEP associated to that SIP
1708 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString());
1709 LOG.info("NodeA {} Uuid is {}", nodeAid, nodeUuid);
1710 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1711 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1713 LOG.error("Node not found in datastore");
1716 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1717 // connection is between 2 CLIENT ports. Otherwise it will not work...
1718 OwnedNodeEdgePoint nep = null;
1719 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1720 if (onep.getMappedServiceInterfacePoint() != null
1721 && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1727 LOG.error("Nep not found in datastore");
1730 String nodeName = "";
1732 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1733 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1734 endPoint.getName().entrySet()) {
1735 if (!("Node Type").equals(entry.getValue().getValueName())) {
1736 nodeName = entry.getValue().getValue();
1739 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1740 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1741 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1742 String txPortDeviceName = nepName.split("\\+")[0];
1743 String txPortName = nepName.split("\\+")[2];
1744 String rxPortDeviceName = txPortDeviceName;
1745 String rxPortName = txPortName;
1746 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1747 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1748 // TODO --> get clli from datastore?
1749 String clli = "NodeSA";
1750 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1752 .setNodeId(new NodeIdType(nodeid))
1753 .setOpticType(OpticTypes.Gray)
1754 .setServiceFormat(serviceFormat)
1755 .setServiceRate(Uint32.valueOf(capacity))
1756 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1757 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
1758 .subrate.eth.sla.SubrateEthSlaBuilder()
1759 .setCommittedBurstSize(Uint16.valueOf(64))
1760 .setCommittedInfoRate(Uint32.valueOf(100000))
1763 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1764 .setPort(new PortBuilder()
1765 .setPortDeviceName(txPortDeviceName)
1766 .setPortName(txPortName)
1767 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1769 .setPortType(TapiStringConstants.PORT_TYPE)
1771 .setLgx(new LgxBuilder()
1772 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1773 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1774 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1775 .setLgxPortShelf("00")
1777 .setIndex(Uint8.ZERO)
1779 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1780 .setPort(new PortBuilder()
1781 .setPortDeviceName(rxPortDeviceName)
1782 .setPortName(rxPortName)
1783 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1785 .setPortType(TapiStringConstants.PORT_TYPE)
1787 .setLgx(new LgxBuilder()
1788 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1789 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1790 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1791 .setLgxPortShelf("00")
1793 .setIndex(Uint8.ZERO)
1795 if (serviceFormat.equals(ServiceFormat.ODU)) {
1796 serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
1797 } else if (serviceFormat.equals(ServiceFormat.OTU)) {
1798 serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
1800 return serviceLayer.equals(LayerProtocolName.ETH)
1801 ? serviceAEndBuilder.build()
1802 : serviceAEndBuilder
1803 .setEthernetAttributes(new EthernetAttributesBuilder()
1804 .setSubrateEthSla(new SubrateEthSlaBuilder()
1805 .setCommittedBurstSize(Uint16.valueOf(64))
1806 .setCommittedInfoRate(Uint32.valueOf(100000))
1812 private ConnectionType getConnectionTypePhtnc(
1813 Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1814 .create.connectivity.service.input.EndPoint> endPoints) {
1815 return endPoints.stream()
1816 .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
1817 // EndPoints are ROADMs
1818 ? ConnectionType.RoadmLine
1819 // EndPoints are not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1820 : ConnectionType.Infrastructure;
1823 private ServiceFormat getServiceFormatPhtnc(
1824 Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1825 .create.connectivity.service.input.EndPoint> endPoints) {
1826 return endPoints.stream()
1827 .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
1828 // EndPoints are ROADMs
1830 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1831 : ServiceFormat.OTU;
1834 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1835 return this.tapiContext.getTapiCEP(
1838 new Uuid(UUID.nameUUIDFromBytes(
1840 spcXpdrNetwork.split("\\+")[0],
1841 TapiStringConstants.XPDR)
1842 .getBytes(StandardCharsets.UTF_8))).toString()),
1844 new Uuid(UUID.nameUUIDFromBytes(
1846 spcXpdrNetwork.split("\\+")[0],
1847 TapiStringConstants.I_ODU,
1848 spcXpdrNetwork.split("\\+")[1])
1849 .getBytes(StandardCharsets.UTF_8))).toString()),
1851 new Uuid(UUID.nameUUIDFromBytes(
1854 spcXpdrNetwork.split("\\+")[0],
1855 TapiStringConstants.I_ODU,
1856 spcXpdrNetwork.split("\\+")[1]))
1857 .getBytes(StandardCharsets.UTF_8)).toString()));
1860 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1861 for (String networkPort:xpdrNetworkTplist) {
1862 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1869 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1870 List<String> clientPortList = new ArrayList<>();
1871 for (String networkPort:xpdrNetworkTplist) {
1872 String nodeId = String.join("-",
1873 networkPort.split("\\+")[0].split("-")[0],
1874 networkPort.split("\\+")[0].split("-")[1]);
1875 String tpId = networkPort.split("\\+")[1];
1876 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1877 .child(Nodes.class, new NodesKey(nodeId))
1878 .child(Mapping.class, new MappingKey(tpId)).build();
1880 Optional<Mapping> optMapping =
1881 this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, mapIID).get();
1882 if (optMapping.isEmpty()) {
1883 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1885 Mapping mapping = optMapping.orElseThrow();
1886 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1887 String key = String.join("+",
1888 String.join("-", nodeId, tpId.split("\\-")[0]),
1889 mapping.getConnectionMapLcp());
1890 LOG.info("Key to be added to list = {}", key);
1891 if (!clientPortList.contains(key)) {
1892 clientPortList.add(key);
1894 } catch (InterruptedException | ExecutionException e) {
1895 LOG.error("Couldnt read mapping from datastore", e);
1900 return clientPortList;
1903 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1904 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1905 for (String xpdrNode:xpdrNodelist) {
1906 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1907 .topology.Node> nodeIID =
1908 InstanceIdentifier.builder(Context.class)
1909 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
1910 .child(TopologyContext.class)
1911 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1913 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
1916 new Uuid(UUID.nameUUIDFromBytes(
1917 (String.join("+",xpdrNode, TapiStringConstants.XPDR))
1918 .getBytes(StandardCharsets.UTF_8)).toString())))
1921 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode =
1922 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1923 if (optNode.isEmpty()) {
1926 OpenroadmNodeType openroadmNodeType =
1927 OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(new NameKey("Node Type")).getValue());
1928 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1929 openroadmNodeTypeList.add(openroadmNodeType);
1931 } catch (InterruptedException | ExecutionException e) {
1932 LOG.error("Couldnt read node in topology", e);
1936 // TODO for now check that there is only one type, otherwise error
1937 if (openroadmNodeTypeList.size() == 1) {
1938 return openroadmNodeTypeList.get(0);
1940 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);