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.network.NetworkTransactionService;
25 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
26 import org.opendaylight.transportpce.tapi.TapiStringConstants;
27 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
28 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
29 import org.opendaylight.transportpce.tapi.utils.TapiContext;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingKey;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesKey;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev191129.OpticTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.Service;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ethernet.subrate.attributes.grp.EthernetAttributesBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionKey;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.lgx.LgxBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth.sla.SubrateEthSlaBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OTU4;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEnd;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEndBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEnd;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEndBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
62 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToAKey;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.TotalSizeBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ProtectionRole;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointKey;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.Connection;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionKey;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.CapacityBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.ServiceInterfacePointBuilder;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
121 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
122 import org.opendaylight.yangtools.yang.common.Decimal64;
123 import org.opendaylight.yangtools.yang.common.Uint16;
124 import org.opendaylight.yangtools.yang.common.Uint32;
125 import org.opendaylight.yangtools.yang.common.Uint64;
126 import org.opendaylight.yangtools.yang.common.Uint8;
127 import org.slf4j.Logger;
128 import org.slf4j.LoggerFactory;
130 public final class ConnectivityUtils {
132 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
133 .getBytes(StandardCharsets.UTF_8)).toString());
134 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
136 private final ServiceDataStoreOperations serviceDataStoreOperations;
137 private final TapiContext tapiContext;
138 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
140 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
141 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
142 connectionFullMap; // this variable is for complete connection objects
143 private final NetworkTransactionService networkTransactionService;
144 private Connection topConnRdmRdm;
145 private Connection topConnXpdrXpdrPhtn;
146 private Connection topConnXpdrXpdrOdu;
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) {
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;
162 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
163 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
164 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
165 if (serviceAEnd == null || serviceZEnd == null) {
166 LOG.warn("One of the endpoints could not be identified");
169 return new ServiceCreateInputBuilder()
170 .setCommonId("commonId")
171 .setConnectionType(ConnectionType.Service)
172 .setCustomer("Customer")
173 .setServiceName("service test")
174 .setServiceAEnd(serviceAEnd)
175 .setServiceZEnd(serviceZEnd)
176 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
177 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
183 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
184 String txPortName, String rxPortDeviceName, String rxPortName) {
185 return new ServiceAEndBuilder()
187 .setNodeId(new NodeIdType(nodeid))
188 .setOpticType(OpticTypes.Gray)
189 .setServiceFormat(ServiceFormat.Ethernet)
190 .setServiceRate(Uint32.valueOf(100))
191 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
192 .setPort(new PortBuilder()
193 .setPortDeviceName(txPortDeviceName)
194 .setPortName(txPortName)
195 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
197 .setPortType(TapiStringConstants.PORT_TYPE)
199 .setLgx(new LgxBuilder()
200 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
201 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
202 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
203 .setLgxPortShelf("00")
206 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
207 .setPort(new PortBuilder()
208 .setPortDeviceName(rxPortDeviceName)
209 .setPortName(rxPortName)
210 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
212 .setPortType(TapiStringConstants.PORT_TYPE)
214 .setLgx(new LgxBuilder()
215 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
216 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
217 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
218 .setLgxPortShelf("00")
224 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
225 String txPortName, String rxPortDeviceName, String rxPortName) {
226 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
227 .setOpticType(OpticTypes.Gray)
228 .setServiceFormat(ServiceFormat.Ethernet)
229 .setServiceRate(Uint32.valueOf(100))
230 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
231 .setPort(new PortBuilder()
232 .setPortDeviceName(txPortDeviceName)
233 .setPortName(txPortName)
234 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
236 .setPortType(TapiStringConstants.PORT_TYPE)
238 .setLgx(new LgxBuilder()
239 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
240 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
241 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
242 .setLgxPortShelf("00")
245 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
246 .setPort(new PortBuilder()
247 .setPortDeviceName(rxPortDeviceName)
248 .setPortName(rxPortName)
249 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
251 .setPortType(TapiStringConstants.PORT_TYPE)
253 .setLgx(new LgxBuilder()
254 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
255 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
256 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
257 .setLgxPortShelf("00")
263 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
264 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
265 return new ServiceAEndBuilder(sepA.getValue()).build();
266 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
267 return new ServiceAEndBuilder(sepZ.getValue()).build();
273 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
274 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
275 return new ServiceZEndBuilder(sepA.getValue()).build();
276 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
277 return new ServiceZEndBuilder(sepZ.getValue()).build();
283 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
287 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
288 // Get service path with the description in OR based models.
289 LOG.info("Service = {}", service);
290 Optional<ServicePaths> optServicePaths =
291 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
292 if (!optServicePaths.isPresent()) {
293 LOG.error("No service path found for service {}", service.getServiceName());
296 ServicePaths servicePaths = optServicePaths.orElseThrow();
297 PathDescription pathDescription = servicePaths.getPathDescription();
298 LOG.info("Path description of service = {}", pathDescription);
299 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd
300 = service.getServiceAEnd();
302 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
303 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd serviceZEnd
304 = service.getServiceZEnd();
305 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
306 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
307 endPointMap.put(endPoint1.key(), endPoint1);
308 endPointMap.put(endPoint2.key(), endPoint2);
309 LOG.info("EndPoints of connectivity services = {}", endPointMap);
311 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
313 // Connection creation
314 Map<ConnectionKey, Connection> connMap =
315 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
316 LOG.debug("connectionMap for service {} = {} ", name.toString(), connMap.toString());
317 ConnectivityConstraint conConstr =
318 new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build();
319 // TODO: full connectivity service?? With constraints and the rest of fields...
320 return new ConnectivityServiceBuilder()
321 .setAdministrativeState(AdministrativeState.UNLOCKED)
322 .setOperationalState(OperationalState.ENABLED)
323 .setLifecycleState(LifecycleState.INSTALLED)
324 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8))
326 .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
327 .setConnectivityConstraint(conConstr)
328 .setDirection(ForwardingDirection.BIDIRECTIONAL)
329 .setName(Map.of(name.key(), name))
330 .setConnection(connMap)
331 .setEndPoint(endPointMap)
335 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
336 switch (serviceFormat) {
339 return LayerProtocolName.PHOTONICMEDIA;
341 return LayerProtocolName.ODU;
343 String node1 = endPoint1.getLocalId();
344 String node2 = endPoint2.getLocalId();
345 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
346 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
347 return LayerProtocolName.ETH;
349 return LayerProtocolName.DSR;
351 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
356 private OpenroadmNodeType getOpenroadmType(String nodeName) {
357 LOG.info("Node name = {}", nodeName);
358 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.XPDR))
359 .getBytes(StandardCharsets.UTF_8)).toString());
360 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode
361 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
362 if (tapiNode != null) {
363 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
369 private Map<ConnectionKey, Connection> createConnectionsFromService(
370 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
372 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd
374 PathDescription pathDescription) {
375 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
376 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
377 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
378 // and the connections
380 List<String> xpdrClientTplist = new ArrayList<>();
381 List<String> xpdrNetworkTplist = new ArrayList<>();
382 List<String> rdmAddDropTplist = new ArrayList<>();
383 List<String> rdmDegTplist = new ArrayList<>();
384 List<String> rdmNodelist = new ArrayList<>();
385 List<String> xpdrNodelist = new ArrayList<>();
386 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
387 .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
388 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
389 switch (resourceType) {
390 case TapiStringConstants.TP:
391 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
392 String tpID = tp.getTpId();
394 if (tpID.contains("CLIENT")) {
395 tpNode = tp.getTpNodeId();
396 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
397 xpdrClientTplist.add(String.join("+", tpNode, tpID));
400 if (tpID.contains("NETWORK")) {
401 tpNode = tp.getTpNodeId();
402 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
403 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
406 if (tpID.contains("PP")) {
407 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
408 LOG.info("ROADM Node of tp = {}", tpNode);
409 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
410 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
413 if (tpID.contains("TTP")) {
414 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
415 LOG.info("ROADM Node of tp = {}", tpNode);
416 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
417 rdmDegTplist.add(String.join("+", tpNode, tpID));
421 case TapiStringConstants.NODE:
422 Node node = (Node) elem.getResource().getResource();
423 String nodeId = node.getNodeId();
424 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
425 LOG.info("Node id = {}", nodeId);
426 if (!xpdrNodelist.contains(nodeId)) {
427 xpdrNodelist.add(nodeId); // should contain only 2
430 if (nodeId.contains("ROADM")) {
431 nodeId = getIdBasedOnModelVersion(nodeId);
432 LOG.info("Node id = {}", nodeId);
433 if (!rdmNodelist.contains(nodeId)) {
434 rdmNodelist.add(nodeId);
439 LOG.warn("Resource is a {}", resourceType);
442 LOG.info("ROADM node list = {}", rdmNodelist);
443 LOG.info("ROADM degree list = {}", rdmDegTplist);
444 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
445 LOG.info("XPDR node list = {}", xpdrNodelist);
446 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
447 LOG.info("XPDR client list = {}", xpdrClientTplist);
448 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
449 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
450 // to trigger all the steps or not
451 String edgeRoadm1 = "";
452 String edgeRoadm2 = "";
453 if (!rdmNodelist.isEmpty()) {
454 edgeRoadm1 = rdmNodelist.get(0);
455 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
456 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
457 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
459 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
460 // CEPs must be included in the topology context as an augmentation for each ONEP!!
461 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
462 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
463 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
464 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
465 // this needs to be changed
466 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
467 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
468 switch (serviceFormat) {
470 // Identify number of ROADMs
471 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
472 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
473 // - Top Connection MC betwwen MC CEPs of different roadms
474 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
475 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
476 edgeRoadm1, edgeRoadm2));
479 // Identify number of ROADMs between XPDRs and check if OC is created
480 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
481 // - Top Connection MC betwwen MC CEPs of different roadms
482 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
483 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
484 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
485 edgeRoadm1, edgeRoadm2));
486 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
487 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
488 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
489 this.topConnRdmRdm = null;
492 // TODO: verify if this is correct
493 // - XC Connection OTSi betwwen iODU and eODU of xpdr
494 // - Top connection in the ODU layer, between xpdr eODU ports (?)
495 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
496 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
497 this.topConnXpdrXpdrPhtn = null;
501 // Check if OC, OTU and ODU are created
502 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
503 LOG.info("WDM ETH service");
504 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
505 edgeRoadm1, edgeRoadm2));
506 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
507 this.topConnRdmRdm = null;
508 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
509 LOG.info("Associated client ports = {}", xpdrClientTplist);
510 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
512 this.topConnXpdrXpdrPhtn = null;
514 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
515 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
516 // - XC Connection OTSi between iODU and eODU of xpdr
517 // - Top connection in the ODU layer, between xpdr eODU ports (?)
518 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
520 this.topConnXpdrXpdrPhtn = null;
522 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
523 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
524 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
526 this.topConnXpdrXpdrOdu = null;
530 LOG.error("Service type format not supported");
532 LOG.debug("CONNSERVERMAP = {}", connectionServMap.toString());
533 return connectionServMap;
536 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
537 List<String> xpdrNodelist,
538 Map<ConnectionKey, Connection> lowerConn) {
539 // TODO: do we need to create cross connection between iODU and eODU??
540 // add the lower connections of the previous steps for this kind of service
541 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
542 for (Connection lowConn: lowerConn.values()) {
543 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
544 xcMap.put(conn.key(), conn);
546 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
547 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
548 ConnectionEndPoint> cepMapDsr = new HashMap<>();
549 // Create 1 cep per Xpdr in the CLIENT
550 // 1 top connection DSR between the CLIENT xpdrs
551 for (String xpdr:xpdrNodelist) {
552 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
553 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
555 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
556 LayerProtocolName.DSR);
557 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR,
558 TapiStringConstants.XPDR, netCep1);
560 cepMapDsr.put(netCep1.key(), netCep1);
562 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
563 .get(0))).findFirst().orElseThrow();
564 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
565 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
567 // DSR top connection between edge xpdr CLIENT DSR
568 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
569 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
570 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
571 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
573 // DSR top connection that will be added to the service object
574 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
575 connServMap.put(conn1.key(), conn1);
580 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
581 List<String> xpdrNetworkTplist,
582 List<String> xpdrNodelist) {
583 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
584 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
585 ConnectionEndPoint> cepMapDsr = new HashMap<>();
586 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
587 ConnectionEndPoint> cepMapOdu = new HashMap<>();
588 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
589 // be added to the lower connection of a top connection
590 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
592 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
593 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
594 for (String xpdr:xpdrNodelist) {
595 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
596 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
598 ConnectionEndPoint clientCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR,
599 TapiStringConstants.XPDR, LayerProtocolName.DSR);
600 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
603 ConnectionEndPoint clientCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
604 TapiStringConstants.XPDR, LayerProtocolName.ODU);
605 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR,
608 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
609 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
611 cepMapDsr.put(clientCep1.key(), clientCep1);
612 cepMapOdu.put(clientCep2.key(), clientCep2);
613 // Create x connection between I_ODU and E_ODU within xpdr
614 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
615 connection = createXCBetweenCeps(clientCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
616 TapiStringConstants.ODU, LayerProtocolName.ODU);
617 this.connectionFullMap.put(connection.key(), connection);
619 // Create X connection that will be added to the service object
620 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
621 xcMap.put(conn.key(), conn);
624 // DSR top connection between edge xpdr CLIENT DSR
625 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
626 .get(0))).findFirst().orElseThrow();
627 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
628 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
630 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
631 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
632 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
633 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
635 // ODU top connection that will be added to the service object
636 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
637 connServMap.put(conn.key(), conn);
638 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
639 xcMap.put(lowerConn.key(), lowerConn);
641 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
642 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
643 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
644 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
646 // DSR top connection that will be added to the service object
647 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
648 connServMap.put(conn1.key(), conn1);
653 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
654 List<String> xpdrNodelist) {
655 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
656 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
657 ConnectionEndPoint> cepMap = new HashMap<>();
658 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
659 // be added to the lower connection of a top connection
660 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
662 // Create 1 cep per Xpdr in the I_ODU and a top
663 // connection iODU between the xpdrs
664 for (String xpdr:xpdrNodelist) {
665 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
666 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
668 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
669 TapiStringConstants.XPDR, LayerProtocolName.ODU);
670 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR,
673 cepMap.put(netCep1.key(), netCep1);
676 // ODU top connection between edge xpdr i_ODU
677 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
678 .get(0))).findFirst().orElseThrow();
679 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
680 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
681 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
682 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
683 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
684 this.connectionFullMap.put(connection.key(), connection);
686 // ODU top connection that will be added to the service object
687 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
688 connServMap.put(conn.key(), conn);
689 this.topConnXpdrXpdrOdu = conn;
694 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
695 List<String> xpdrNodelist) {
697 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
698 // be added to the lower connection of a top connection
699 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
700 ConnectionEndPoint> cepMap = new HashMap<>();
701 // create ceps and x connections within xpdr
702 for (String xpdr:xpdrNodelist) {
703 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
704 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
706 // There should be 1 network tp per xpdr
707 // Just create 2 different CEPs (1 OTS + 1 OTSI_MC)
708 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
709 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
710 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
711 TapiStringConstants.XPDR, netCep1);
712 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.OTSI_MC,
713 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
714 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR,
716 // ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
717 // TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
718 // putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
721 cepMap.put(netCep1.key(), netCep1);
722 cepMap.put(netCep2.key(), netCep2);
723 // cepMap.put(netCep3.key(), netCep3);
727 // OTSi top connection between edge OTSI_MC Xpdr
728 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
729 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
730 .get(0))).findFirst().orElseThrow();
731 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
732 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
733 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
734 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.OTSI_MC,
735 LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
736 this.connectionFullMap.put(connection.key(), connection);
738 // OTSi top connection that will be added to the service object
739 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
740 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
741 connServMap.put(conn.key(), conn);
742 this.topConnXpdrXpdrPhtn = conn;
747 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
748 List<String> rdmDegTplist,
749 List<String> rdmNodelist,
750 String edgeRoadm1, String edgeRoadm2) {
751 // TODO: will need to check if things exist already or not
752 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
753 ConnectionEndPoint> cepMap = new HashMap<>();
754 // create ceps and x connections within roadm
755 Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
756 for (String roadm : rdmNodelist) {
757 LOG.info("Creating ceps and xc for roadm {}", roadm);
758 if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
759 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
760 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
762 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
763 // There should be only 1 AD and 1 DEG per roadm
764 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
765 // 3 different MC CEPs giving different IDs to show that they are different
766 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
767 // created in the topology creation
768 // add CEPs to the topology to the corresponding ONEP
769 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS);
770 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS, adCep1);
771 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
772 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
773 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
774 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
775 cepMap.put(adCep1.key(), adCep1);
776 cepMap.put(adCep2.key(), adCep2);
777 cepMap.put(adCep3.key(), adCep3);
779 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
780 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
782 ConnectionEndPoint degCep0 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS);
783 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS, degCep0);
784 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS);
785 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS, degCep1);
786 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
787 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
788 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
789 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
790 cepMap.put(degCep0.key(), degCep0);
791 cepMap.put(degCep1.key(), degCep1);
792 cepMap.put(degCep2.key(), degCep2);
793 cepMap.put(degCep3.key(), degCep3);
795 LOG.info("Going to create cross connections for ROADM {}", roadm);
796 // Create X connections between MC and OTSi_MC for full map
797 org.opendaylight.yang.gen.v1.urn
798 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
799 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
800 LayerProtocolName.PHOTONICMEDIA);
801 LOG.info("Cross connection 1 created = {}", connection1.toString());
802 org.opendaylight.yang.gen.v1.urn
803 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
804 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
805 LayerProtocolName.PHOTONICMEDIA);
806 LOG.info("Cross connection 2 created = {}", connection2.toString());
807 this.connectionFullMap.put(connection1.key(), connection1);
808 this.connectionFullMap.put(connection2.key(), connection2);
810 // Create X connections that will be added to the service object
811 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
812 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
814 xcLowerMap.put(conn1.key(), conn1);
815 xcLowerMap.put(conn2.key(), conn2);
817 LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
818 String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
819 LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
821 ConnectionEndPoint deg1Cep0 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS);
822 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS, deg1Cep0);
823 ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS);
824 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS, deg1Cep1);
825 ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC);
826 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2);
827 ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC);
828 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3);
829 cepMap.put(deg1Cep0.key(), deg1Cep0);
830 cepMap.put(deg1Cep1.key(), deg1Cep1);
831 cepMap.put(deg1Cep2.key(), deg1Cep2);
832 cepMap.put(deg1Cep3.key(), deg1Cep3);
834 String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
836 LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
838 ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS);
839 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS, deg2Cep0);
840 ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS);
841 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS, deg2Cep1);
842 ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC);
843 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2);
844 ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC);
845 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3);
846 cepMap.put(deg2Cep0.key(), deg2Cep0);
847 cepMap.put(deg2Cep1.key(), deg2Cep1);
848 cepMap.put(deg2Cep2.key(), deg2Cep2);
849 cepMap.put(deg2Cep3.key(), deg2Cep3);
851 LOG.info("Going to create cross connections for ROADM {}", roadm);
852 // Create X connections between MC and OTSi_MC for full map
853 org.opendaylight.yang.gen.v1.urn
854 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
855 = createXCBetweenCeps(deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
856 TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
857 LOG.info("Cross connection 1 created = {}", connection1.toString());
858 org.opendaylight.yang.gen.v1.urn
859 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
860 = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
861 TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
862 LOG.info("Cross connection 2 created = {}", connection2.toString());
863 this.connectionFullMap.put(connection1.key(), connection1);
864 this.connectionFullMap.put(connection2.key(), connection2);
866 // Create X connections that will be added to the service object
867 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
868 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
870 xcLowerMap.put(conn1.key(), conn1);
871 xcLowerMap.put(conn2.key(), conn2);
874 LOG.info("Going to create top connections between roadms");
875 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
876 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
877 // MC top connection between edge roadms
878 LOG.info("Going to created top connection between MC");
879 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
880 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
881 LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
882 this.connectionFullMap.put(connection.key(), connection);
883 LOG.info("Top connection created = {}", connection.toString());
885 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
886 // OTSiMC top connections that will be added to the service object
887 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
888 connServMap.put(conn.key(), conn);
889 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
890 Map<LowerConnectionKey, LowerConnection> topLowerMap = new HashMap<>();
891 topLowerMap.put(conn1.key(), conn1);
893 // OTSiMC top connection between edge roadms
894 LOG.info("Going to created top connection between OTSiMC");
895 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
896 connection1 = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
897 LayerProtocolName.PHOTONICMEDIA, topLowerMap, null);
898 this.connectionFullMap.put(connection1.key(), connection1);
899 LOG.info("Top connection created = {}", connection1.toString());
901 // OTSiMC top connections that will be added to the service object
902 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
903 connServMap.put(conn2.key(), conn2);
904 this.topConnRdmRdm = conn2;
908 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
909 createTopConnection(String tp1, String tp2,
910 Map<org.opendaylight.yang.gen.v1.urn
911 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
912 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
913 Map<LowerConnectionKey, LowerConnection> xcMap, Connection additionalLowerConn) {
914 // find cep for each AD MC of roadm 1 and 2
915 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
916 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 =
917 cepMap.get(new org.opendaylight.yang.gen.v1.urn
918 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
919 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
920 qual, tp1.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
922 LOG.info("ADCEP1 = {}", adCep1);
923 org.opendaylight.yang.gen.v1.urn
924 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep1 =
925 new org.opendaylight.yang.gen.v1.urn
926 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
927 .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
928 .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
929 .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
930 .setConnectionEndPointUuid(adCep1.getUuid())
932 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
933 cepMap.get(new org.opendaylight.yang.gen.v1.urn
934 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
935 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
936 qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
938 LOG.info("ADCEP2 = {}", adCep2);
939 org.opendaylight.yang.gen.v1.urn
940 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep2 =
941 new org.opendaylight.yang.gen.v1.urn
942 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
943 .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
944 .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
945 .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
946 .setConnectionEndPointUuid(adCep1.getUuid())
948 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
949 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
950 ceps.put(cep1.key(), cep1);
951 ceps.put(cep2.key(), cep2);
952 Name connName = new NameBuilder()
953 .setValueName("Connection name")
954 .setValue(String.join("+", "TOP", tp1, tp2, qual))
956 // TODO: lower connection, supported link.......
957 if (additionalLowerConn != null) {
958 xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
959 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
961 return new org.opendaylight.yang.gen.v1.urn
962 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
963 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
964 .getBytes(StandardCharsets.UTF_8)).toString()))
965 .setName(Map.of(connName.key(), connName))
966 .setConnectionEndPoint(ceps)
967 .setOperationalState(OperationalState.ENABLED)
968 .setLayerProtocolName(topPortocol)
969 .setLifecycleState(LifecycleState.INSTALLED)
970 .setDirection(ForwardingDirection.BIDIRECTIONAL)
971 .setLowerConnection(xcMap)
975 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
976 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
977 LayerProtocolName xcProtocol) {
978 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
979 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
980 LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint().toString());
981 LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint().toString());
982 org.opendaylight.yang.gen.v1.urn
983 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ1 =
984 new org.opendaylight.yang.gen.v1.urn
985 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
986 .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
987 .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
988 .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
989 .setConnectionEndPointUuid(cep1.getUuid())
991 org.opendaylight.yang.gen.v1.urn
992 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ2 =
993 new org.opendaylight.yang.gen.v1.urn
994 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
995 .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
996 .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
997 .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
998 .setConnectionEndPointUuid(cep2.getUuid())
1000 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
1001 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
1002 ceps.put(cepServ1.key(), cepServ1);
1003 ceps.put(cepServ2.key(), cepServ2);
1004 Name connName = new NameBuilder()
1005 .setValueName("Connection name")
1006 .setValue(String.join("+", "XC", tp1, tp2, qual))
1008 // TODO: lower connection, supported link.......
1009 return new org.opendaylight.yang.gen.v1.urn
1010 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
1011 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
1012 .getBytes(StandardCharsets.UTF_8)).toString()))
1013 .setName(Map.of(connName.key(), connName))
1014 .setConnectionEndPoint(ceps)
1015 .setOperationalState(OperationalState.ENABLED)
1016 .setLayerProtocolName(xcProtocol)
1017 .setLifecycleState(LifecycleState.INSTALLED)
1018 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1022 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
1023 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1024 Name cepName = new NameBuilder()
1025 .setValueName("ConnectionEndPoint name")
1026 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1027 id.split("\\+")[1]))
1029 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1030 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1031 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1033 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1034 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
1036 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1037 .getBytes(StandardCharsets.UTF_8)).toString()))
1039 String clientQualifier = "";
1040 switch (qualifier) {
1041 case TapiStringConstants.PHTNC_MEDIA_OTS:
1042 clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS;
1044 case TapiStringConstants.PHTNC_MEDIA_OMS:
1045 clientQualifier = TapiStringConstants.MC;
1046 OwnedNodeEdgePoint onepMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1047 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1048 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], TapiStringConstants.MC, onepMC);
1050 case TapiStringConstants.MC:
1051 clientQualifier = TapiStringConstants.OTSI_MC;
1052 OwnedNodeEdgePoint onepOTSiMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1053 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1054 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1],
1055 TapiStringConstants.OTSI_MC, onepOTSiMC);
1058 LOG.debug("not currently handling client NEP for OTSiMC CEP {}",
1059 String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1062 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1063 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1064 clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1066 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1067 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
1069 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1070 .getBytes(StandardCharsets.UTF_8)).toString()))
1072 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1073 // TODO: add parent ONEP??
1074 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1075 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1076 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1078 .setParentNodeEdgePoint(pnep)
1079 .setName(Map.of(cepName.key(), cepName))
1080 .setConnectionPortRole(PortRole.SYMMETRIC)
1081 .setDirection(Direction.BIDIRECTIONAL)
1082 .setOperationalState(OperationalState.ENABLED)
1083 .setLifecycleState(LifecycleState.INSTALLED)
1084 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
1085 if (!(TapiStringConstants.OTSI_MC.equals(qualifier))) {
1086 cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
1088 return cepBldr.build();
1091 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
1092 LayerProtocolName cepProtocol) {
1093 Name cepName = new NameBuilder()
1094 .setValueName("ConnectionEndPoint name")
1095 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1096 id.split("\\+")[1]))
1098 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1099 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1100 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1102 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1103 TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
1105 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1106 .getBytes(StandardCharsets.UTF_8)).toString()))
1108 String clientQualifier = "";
1109 String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA;
1110 switch (qualifier) {
1111 case TapiStringConstants.PHTNC_MEDIA_OTS:
1112 clientQualifier = TapiStringConstants.OTSI_MC;
1114 case TapiStringConstants.OTSI_MC:
1115 clientQualifier = TapiStringConstants.E_ODU;
1116 clientNodeLayer = TapiStringConstants.ODU;
1118 case TapiStringConstants.E_ODU:
1119 clientQualifier = TapiStringConstants.DSR;
1120 clientNodeLayer = TapiStringConstants.DSR;
1123 LOG.debug("no client CEP for DSR NEP {}",
1124 String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1127 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1128 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1129 clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1131 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1132 TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
1134 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1135 .getBytes(StandardCharsets.UTF_8)).toString()))
1137 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1138 // TODO: add parent ONEP??
1139 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1140 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1141 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1143 .setParentNodeEdgePoint(pnep)
1144 .setName(Map.of(cepName.key(), cepName))
1145 .setConnectionPortRole(PortRole.SYMMETRIC)
1146 .setDirection(Direction.BIDIRECTIONAL)
1147 .setOperationalState(OperationalState.ENABLED)
1148 .setLifecycleState(LifecycleState.INSTALLED)
1149 .setLayerProtocolName(cepProtocol);
1150 if (!(TapiStringConstants.DSR.equals(qualifier))) {
1151 cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
1153 return cepBldr.build();
1156 private EndPoint mapServiceZEndPoint(
1157 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd
1158 serviceZEnd, PathDescription pathDescription) {
1159 EndPointBuilder endPointBuilder = new EndPointBuilder();
1160 // 1. Service Format: ODU, OTU, ETH
1161 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1162 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1163 // Identify SIP name
1164 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1165 LOG.info("Uuid of z end {}", sipUuid);
1166 LayerProtocolName layerProtocols = null;
1167 // Layer protocol name
1168 switch (serviceFormat) {
1170 layerProtocols = LayerProtocolName.DSR;
1174 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1177 layerProtocols = LayerProtocolName.ODU;
1180 LOG.error("Service Format not supported");
1182 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1183 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1184 .setValueName("OpenROADM info")
1185 .setValue(String.join("-", serviceZEnd.getClli(),
1186 serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1187 .getPortDeviceName(),
1188 serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
1190 return endPointBuilder
1191 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1192 .setServiceInterfacePointUuid(sipUuid)
1194 .setName(Map.of(name.key(), name))
1195 .setAdministrativeState(AdministrativeState.UNLOCKED)
1196 .setDirection(Direction.BIDIRECTIONAL)
1197 .setLifecycleState(LifecycleState.INSTALLED)
1198 .setOperationalState(OperationalState.ENABLED)
1199 .setLayerProtocolName(layerProtocols)
1200 .setCapacity(new CapacityBuilder()
1201 .setTotalSize(new TotalSizeBuilder()
1202 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
1203 .setUnit(CAPACITYUNITGBPS.VALUE)
1205 // .setBandwidthProfile(new BandwidthProfileBuilder().build())
1207 .setProtectionRole(ProtectionRole.WORK)
1208 .setRole(PortRole.SYMMETRIC)
1209 .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()
1210 .getPort().getPortDeviceName())
1214 private EndPoint mapServiceAEndPoint(
1215 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
1216 serviceAEnd, PathDescription pathDescription) {
1217 EndPointBuilder endPointBuilder = new EndPointBuilder();
1218 // 1. Service Format: ODU, OTU, ETH
1219 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1220 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1221 // Identify SIP name
1222 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1223 LOG.info("Uuid of a end {}", sipUuid);
1224 LayerProtocolName layerProtocols = null;
1225 // Layer protocol name
1226 switch (serviceFormat) {
1228 layerProtocols = LayerProtocolName.DSR;
1232 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1235 layerProtocols = LayerProtocolName.ODU;
1238 LOG.error("Service Format not supported");
1240 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1241 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1242 .setValueName("OpenROADM info")
1243 .setValue(String.join("-", serviceAEnd.getClli(),
1244 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1245 .getPortDeviceName(),
1246 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
1248 return endPointBuilder
1249 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1250 .setServiceInterfacePointUuid(sipUuid)
1252 .setName(Map.of(name.key(), name))
1253 .setAdministrativeState(AdministrativeState.UNLOCKED)
1254 .setDirection(Direction.BIDIRECTIONAL)
1255 .setLifecycleState(LifecycleState.INSTALLED)
1256 .setOperationalState(OperationalState.ENABLED)
1257 .setLayerProtocolName(layerProtocols)
1258 .setCapacity(new CapacityBuilder()
1259 .setTotalSize(new TotalSizeBuilder()
1260 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceAEnd.getServiceRate().doubleValue())))
1261 .setUnit(CAPACITYUNITGBPS.VALUE)
1263 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1265 .setProtectionRole(ProtectionRole.WORK)
1266 .setRole(PortRole.SYMMETRIC)
1267 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1268 .getPortDeviceName())
1272 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1273 Uuid zendUuid = null;
1274 if (serviceNodeId.contains("ROADM")) {
1275 // Service from ROADM to ROADM
1276 // AddDrop-AddDrop ports --> MC layer SIPs
1277 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
1279 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1280 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1281 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1283 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1284 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1285 if (!sip.getUuid().equals(sipUuid)) {
1286 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1289 zendUuid = sip.getUuid();
1293 // Service from XPDR to XPDR
1295 TerminationPoint tp;
1297 switch (serviceFormat) {
1299 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
1301 tp = (TerminationPoint) firstElement.getResource().getResource();
1302 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1303 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1304 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1305 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1309 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
1311 tp = (TerminationPoint) firstElement.getResource().getResource();
1312 // Network-Network ports --> iOTSi layer SIPs
1313 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1314 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1315 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1319 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1320 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
1322 tp = (TerminationPoint) firstElement.getResource().getResource();
1323 // Client-client ports --> DSR layer SIPs
1324 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1325 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1326 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1331 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1333 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1334 if (!sip.getUuid().equals(sipUuid)) {
1335 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1338 zendUuid = sip.getUuid();
1345 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1346 Uuid aendUuid = null;
1347 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1348 LOG.info("Map a to z = {}", mapatoz);
1349 if (serviceNodeId.contains("ROADM")) {
1350 // Service from ROADM to ROADM
1351 // AddDrop-AddDrop ports --> MC layer SIPs
1352 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
1354 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1355 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1356 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1357 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1359 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1361 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1362 if (!sip.getUuid().equals(sipUuid)) {
1363 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1366 aendUuid = sip.getUuid();
1370 // Service from XPDR to XPDR
1372 TerminationPoint tp;
1374 switch (serviceFormat) {
1376 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
1378 tp = (TerminationPoint) firstElement.getResource().getResource();
1379 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1380 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1381 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1382 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1383 TapiStringConstants.I_ODU, tp.getTpId()));
1386 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
1388 tp = (TerminationPoint) firstElement.getResource().getResource();
1389 // Network-Network ports --> iOTSi layer SIPs
1390 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1391 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1392 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1393 TapiStringConstants.I_OTSI, tp.getTpId()));
1396 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1397 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
1399 tp = (TerminationPoint) firstElement.getResource().getResource();
1400 // Client-client ports --> DSR layer SIPs
1401 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1402 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1403 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1404 TapiStringConstants.DSR, tp.getTpId()));
1408 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1410 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1411 if (!sip.getUuid().equals(sipUuid)) {
1412 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1415 aendUuid = sip.getUuid();
1422 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1423 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1424 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1425 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1426 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1427 .getBytes(StandardCharsets.UTF_8)).toString());
1428 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1429 .getBytes(StandardCharsets.UTF_8)).toString());
1430 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1431 .getBytes(StandardCharsets.UTF_8)).toString());
1432 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1435 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1436 ConnectionEndPoint cep) {
1437 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1438 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1439 .getBytes(StandardCharsets.UTF_8)).toString());
1440 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1441 .getBytes(StandardCharsets.UTF_8)).toString());
1442 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1443 .getBytes(StandardCharsets.UTF_8)).toString());
1444 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1448 private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
1449 LOG.info("NEP id before Merge = {}", String.join("+", orNodeId, qual, orTpId));
1450 LOG.info("Node of NEP id before Merge = {}", String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA));
1451 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1452 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1453 .getBytes(Charset.forName("UTF-8"))).toString());
1454 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)
1455 .getBytes(Charset.forName("UTF-8"))).toString());
1456 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, qual, orTpId)
1457 .getBytes(Charset.forName("UTF-8"))).toString());
1458 updateTopologyWithNep(topoUuid, nodeUuid, nepUuid, onep);
1461 public void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) {
1462 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1463 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
1464 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
1465 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class)
1466 .child(Topology.class, new TopologyKey(topoUuid))
1467 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
1468 new NodeKey(nodeUuid))
1469 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
1472 Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
1473 LogicalDatastoreType.OPERATIONAL, onepIID).get();
1474 if (optionalOnep.isPresent()) {
1475 LOG.error("ONEP is already present in datastore");
1478 // merge in datastore
1479 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
1481 this.networkTransactionService.commit().get();
1482 LOG.info("NEP {} added successfully.", onep.getName().toString());
1483 } catch (InterruptedException | ExecutionException e) {
1484 LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName().toString(), e);
1488 public Map<org.opendaylight.yang.gen.v1.urn
1489 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
1490 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
1491 getConnectionFullMap() {
1492 return this.connectionFullMap;
1495 private String getIdBasedOnModelVersion(String nodeid) {
1496 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1497 nodeid.split("-")[1]) : nodeid.split("-")[0];
1500 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1501 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1502 Map<org.opendaylight.yang.gen.v1.urn
1503 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
1504 org.opendaylight.yang.gen.v1.urn
1505 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint>
1506 endPointMap = input.getEndPoint();
1507 ConnectionType connType = null;
1508 ServiceFormat serviceFormat = null;
1509 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
1510 TapiStringConstants.XPDR);
1511 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
1512 TapiStringConstants.XPDR);
1513 LOG.info("NodeAid = {}", nodeAid);
1514 LOG.info("NodeZid = {}", nodeZid);
1515 //switch (constraint.getServiceLayer().getIntValue()) {
1516 switch (input.getLayerProtocolName().getIntValue()) {
1519 connType = ConnectionType.Infrastructure;
1520 serviceFormat = ServiceFormat.ODU;
1523 LOG.info("ETH, no need to create OTU and ODU");
1524 connType = ConnectionType.Service;
1525 serviceFormat = ServiceFormat.Ethernet;
1528 LOG.info("DSR, need to create OTU and ODU");
1529 connType = ConnectionType.Service;
1530 serviceFormat = ServiceFormat.Ethernet;
1533 LOG.info("PHOTONIC");
1534 connType = getConnectionTypePhtnc(endPointMap.values());
1535 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1536 LOG.debug("Node a photonic = {}", nodeAid);
1537 LOG.debug("Node z photonic = {}", nodeZid);
1540 LOG.info("Service type {} not supported", input.getLayerProtocolName().getName());
1542 // Requested Capacity for connectivity service
1543 Uint64 capacity = Uint64.valueOf(Math.abs(
1544 input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
1545 // map endpoints into service end points. Map the type of service from TAPI to OR
1546 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
1547 serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
1548 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
1549 .orElseThrow(), serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
1550 if (serviceAEnd == null || serviceZEnd == null) {
1551 LOG.error("Couldnt map endpoints to service end");
1554 LOG.info("Service a end = {}", serviceAEnd);
1555 LOG.info("Service z end = {}", serviceZEnd);
1556 return new ServiceCreateInputBuilder()
1557 .setServiceAEnd(serviceAEnd)
1558 .setServiceZEnd(serviceZEnd)
1559 .setConnectionType(connType)
1560 .setServiceName(serviceUuid.getValue())
1561 .setCommonId("common id")
1562 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1563 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1564 .setRequestSystemId("appname")
1566 .setCustomer("customer")
1567 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1568 .setOperatorContact("pw1234")
1572 private ServiceZEnd tapiEndPointToServiceZPoint(
1573 org.opendaylight.yang.gen.v1.urn
1574 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
1575 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1576 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1577 // Not the rest which is needed in the txPortDeviceName.
1578 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1579 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1580 // Todo -> need to find the NEP associated to that SIP
1581 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString());
1582 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1583 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1585 LOG.error("Node not found in datastore");
1588 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1589 // connection is between 2 CLIENT ports. Otherwise it will not work...
1590 OwnedNodeEdgePoint nep = null;
1591 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1592 if (onep.getMappedServiceInterfacePoint() == null) {
1595 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1601 LOG.error("Nep not found in datastore");
1604 String nodeName = "";
1605 for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1606 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1607 endPoint.getName().entrySet()) {
1608 if (!("Node Type").equals(entry.getValue().getValueName())) {
1609 nodeName = entry.getValue().getValue();
1612 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1613 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1614 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1615 String txPortDeviceName = nepName.split("\\+")[0];
1616 String txPortName = nepName.split("\\+")[2];
1617 String rxPortDeviceName = txPortDeviceName;
1618 String rxPortName = txPortName;
1619 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1620 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1621 // TODO --> get clli from datastore?
1622 String clli = "NodeSC";
1623 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1624 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1625 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1627 .setNodeId(new NodeIdType(nodeid))
1628 .setOpticType(OpticTypes.Gray)
1629 .setServiceFormat(serviceFormat)
1630 .setServiceRate(Uint32.valueOf(capacity))
1631 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1632 .setCommittedBurstSize(Uint16.valueOf(64))
1633 .setCommittedInfoRate(Uint32.valueOf(100000))
1636 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1637 .setPort(new PortBuilder()
1638 .setPortDeviceName(txPortDeviceName)
1639 .setPortName(txPortName)
1640 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1642 .setPortType(TapiStringConstants.PORT_TYPE)
1644 .setLgx(new LgxBuilder()
1645 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1646 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1647 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1648 .setLgxPortShelf("00")
1650 .setIndex(Uint8.ZERO)
1652 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1653 .setPort(new PortBuilder()
1654 .setPortDeviceName(rxPortDeviceName)
1655 .setPortName(rxPortName)
1656 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1658 .setPortType(TapiStringConstants.PORT_TYPE)
1660 .setLgx(new LgxBuilder()
1661 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1662 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1663 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1664 .setLgxPortShelf("00")
1666 .setIndex(Uint8.ZERO)
1668 if (serviceFormat.equals(ServiceFormat.ODU)) {
1669 serviceZEndBuilder.setOduServiceRate(ODU4.VALUE);
1671 if (serviceFormat.equals(ServiceFormat.OTU)) {
1672 serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
1674 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1676 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1677 .setCommittedBurstSize(Uint16.valueOf(64))
1678 .setCommittedInfoRate(Uint32.valueOf(100000))
1682 return serviceZEndBuilder.build();
1685 private ServiceAEnd tapiEndPointToServiceAPoint(
1686 org.opendaylight.yang.gen.v1.urn
1687 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
1688 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1689 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1690 // Not the rest which is needed in the txPortDeviceName.
1691 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1692 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1693 // Todo -> need to find the NEP associated to that SIP
1694 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString());
1695 LOG.info("NodeA {} Uuid is {}", nodeAid, nodeUuid);
1696 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1697 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1699 LOG.error("Node not found in datastore");
1702 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1703 // connection is between 2 CLIENT ports. Otherwise it will not work...
1704 OwnedNodeEdgePoint nep = null;
1705 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1706 if (onep.getMappedServiceInterfacePoint() == null) {
1709 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1715 LOG.error("Nep not found in datastore");
1718 String nodeName = "";
1719 for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1720 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1721 endPoint.getName().entrySet()) {
1722 if (!("Node Type").equals(entry.getValue().getValueName())) {
1723 nodeName = entry.getValue().getValue();
1726 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1727 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1728 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1729 String txPortDeviceName = nepName.split("\\+")[0];
1730 String txPortName = nepName.split("\\+")[2];
1731 String rxPortDeviceName = txPortDeviceName;
1732 String rxPortName = txPortName;
1733 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1734 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1735 // TODO --> get clli from datastore?
1736 String clli = "NodeSA";
1737 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1738 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1739 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1741 .setNodeId(new NodeIdType(nodeid))
1742 .setOpticType(OpticTypes.Gray)
1743 .setServiceFormat(serviceFormat)
1744 .setServiceRate(Uint32.valueOf(capacity))
1745 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1746 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth
1747 .sla.SubrateEthSlaBuilder()
1748 .setCommittedBurstSize(Uint16.valueOf(64))
1749 .setCommittedInfoRate(Uint32.valueOf(100000))
1752 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1753 .setPort(new PortBuilder()
1754 .setPortDeviceName(txPortDeviceName)
1755 .setPortName(txPortName)
1756 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1758 .setPortType(TapiStringConstants.PORT_TYPE)
1760 .setLgx(new LgxBuilder()
1761 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1762 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1763 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1764 .setLgxPortShelf("00")
1766 .setIndex(Uint8.ZERO)
1768 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1769 .setPort(new PortBuilder()
1770 .setPortDeviceName(rxPortDeviceName)
1771 .setPortName(rxPortName)
1772 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1774 .setPortType(TapiStringConstants.PORT_TYPE)
1776 .setLgx(new LgxBuilder()
1777 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1778 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1779 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1780 .setLgxPortShelf("00")
1782 .setIndex(Uint8.ZERO)
1784 if (serviceFormat.equals(ServiceFormat.ODU)) {
1785 serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
1786 } else if (serviceFormat.equals(ServiceFormat.OTU)) {
1787 serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
1789 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1791 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1792 .setCommittedBurstSize(Uint16.valueOf(64))
1793 .setCommittedInfoRate(Uint32.valueOf(100000))
1797 return serviceAEndBuilder.build();
1800 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1801 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
1802 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1803 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1804 // EndPoints are ROADMs
1805 return ConnectionType.RoadmLine;
1807 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1808 return ConnectionType.Infrastructure;
1811 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1812 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
1813 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1814 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1815 // EndPoints are ROADMs
1816 return ServiceFormat.OC;
1818 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1819 return ServiceFormat.OTU;
1822 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1823 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1824 TapiStringConstants.XPDR).getBytes(StandardCharsets.UTF_8))).toString());
1825 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1826 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8)))
1828 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1829 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1830 .getBytes(StandardCharsets.UTF_8)).toString());
1831 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1834 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1835 for (String networkPort:xpdrNetworkTplist) {
1836 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1843 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1844 List<String> clientPortList = new ArrayList<>();
1845 for (String networkPort:xpdrNetworkTplist) {
1846 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1847 networkPort.split("\\+")[0].split("-")[1]);
1848 String tpId = networkPort.split("\\+")[1];
1849 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1850 .child(Nodes.class, new NodesKey(nodeId))
1851 .child(Mapping.class, new MappingKey(tpId)).build();
1853 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1855 if (!optMapping.isPresent()) {
1856 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1858 Mapping mapping = optMapping.orElseThrow();
1859 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1860 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1861 mapping.getConnectionMapLcp());
1862 LOG.info("Key to be added to list = {}", key);
1863 if (!clientPortList.contains(key)) {
1864 clientPortList.add(key);
1866 } catch (InterruptedException | ExecutionException e) {
1867 LOG.error("Couldnt read mapping from datastore", e);
1872 return clientPortList;
1875 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1876 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1877 for (String xpdrNode:xpdrNodelist) {
1878 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.XPDR))
1879 .getBytes(StandardCharsets.UTF_8)).toString());
1880 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1881 .onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeIID = InstanceIdentifier.builder(
1882 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1883 .onf.otcc.yang.tapi.topology.rev221121.Context1.class).child(TopologyContext.class)
1884 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1885 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
1886 new NodeKey(nodeUuid)).build();
1888 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode
1889 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1890 if (optNode.isEmpty()) {
1893 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
1894 new NameKey("Node Type")).getValue());
1895 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1896 openroadmNodeTypeList.add(openroadmNodeType);
1898 } catch (InterruptedException | ExecutionException e) {
1899 LOG.error("Couldnt read node in topology", e);
1903 // TODO for now check that there is only one type, otherwise error
1904 if (openroadmNodeTypeList.size() != 1) {
1905 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1908 return openroadmNodeTypeList.get(0);
1911 private OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId,
1912 boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
1914 //TODO : complete implementation with SIP
1915 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, nepPhotonicSublayer,
1916 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
1917 Name nepName = new NameBuilder()
1918 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
1919 .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
1921 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1922 if (TapiStringConstants.MC.equals(nepPhotonicSublayer)) {
1923 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1924 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE)
1925 .setNumberOfCepInstances(Uint64.valueOf(1))
1928 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1929 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
1930 .setNumberOfCepInstances(Uint64.valueOf(1))
1933 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
1935 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
1936 .setName(Map.of(nepName.key(), nepName))
1937 .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
1938 .setDirection(Direction.BIDIRECTIONAL)
1939 .setLinkPortRole(PortRole.SYMMETRIC)
1940 .setAdministrativeState(adminState).setOperationalState(operState)
1941 .setLifecycleState(LifecycleState.INSTALLED)