2 * Copyright © 2018 Orange & 2021 Nokia, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.tapi.connectivity;
10 import java.nio.charset.StandardCharsets;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Comparator;
14 import java.util.HashMap;
15 import java.util.List;
17 import java.util.Optional;
18 import java.util.UUID;
19 import java.util.concurrent.ExecutionException;
20 import java.util.stream.Collectors;
21 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
22 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
23 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
24 import org.opendaylight.transportpce.tapi.TapiStringConstants;
25 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
26 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
27 import org.opendaylight.transportpce.tapi.utils.TapiContext;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingKey;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.NodesKey;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev191129.OpticTypes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.Service;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ethernet.subrate.attributes.grp.EthernetAttributesBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirectionBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirectionKey;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionKey;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.lgx.LgxBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.port.PortBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.subrate.eth.sla.SubrateEthSlaBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OTU4;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceAEnd;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceAEndBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceZEnd;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceZEndBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription;
58 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToA;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToAKey;
62 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Node;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.BandwidthProfileBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ProtectionRole;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ServiceType;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointKey;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnection;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnectionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnectionKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePoint;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePointBuilder;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionKey;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.CapacityBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.ConnectivityConstraint;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
111 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
112 import org.opendaylight.yangtools.yang.common.Uint16;
113 import org.opendaylight.yangtools.yang.common.Uint32;
114 import org.opendaylight.yangtools.yang.common.Uint64;
115 import org.opendaylight.yangtools.yang.common.Uint8;
116 import org.slf4j.Logger;
117 import org.slf4j.LoggerFactory;
119 public final class ConnectivityUtils {
121 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
122 .getBytes(StandardCharsets.UTF_8)).toString());
123 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
125 private final ServiceDataStoreOperations serviceDataStoreOperations;
126 private final TapiContext tapiContext;
127 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
128 private final Map<org.opendaylight.yang.gen.v1.urn
129 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
130 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
131 connectionFullMap; // this variable is for complete connection objects
132 private final NetworkTransactionService networkTransactionService;
133 private Connection topConnRdmRdm;
134 private Connection topConnXpdrXpdrPhtn;
135 private Connection topConnXpdrXpdrOdu;
137 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
138 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
139 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
140 NetworkTransactionService networkTransactionService) {
141 this.serviceDataStoreOperations = serviceDataStoreOperations;
142 this.tapiContext = tapiContext;
143 this.sipMap = sipMap;
144 this.connectionFullMap = new HashMap<>();
145 this.networkTransactionService = networkTransactionService;
146 this.topConnRdmRdm = null;
147 this.topConnXpdrXpdrPhtn = null;
148 this.topConnXpdrXpdrOdu = null;
151 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
152 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
153 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
154 if (serviceAEnd == null || serviceZEnd == null) {
155 LOG.warn("One of the endpoints could not be identified");
158 return new ServiceCreateInputBuilder()
159 .setCommonId("commonId")
160 .setConnectionType(ConnectionType.Service)
161 .setCustomer("Customer")
162 .setServiceName("service test")
163 .setServiceAEnd(serviceAEnd)
164 .setServiceZEnd(serviceZEnd)
165 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
166 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
172 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
173 String txPortName, String rxPortDeviceName, String rxPortName) {
174 return new ServiceAEndBuilder()
176 .setNodeId(new NodeIdType(nodeid))
177 .setOpticType(OpticTypes.Gray)
178 .setServiceFormat(ServiceFormat.Ethernet)
179 .setServiceRate(Uint32.valueOf(100))
180 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
181 .setPort(new PortBuilder()
182 .setPortDeviceName(txPortDeviceName)
183 .setPortName(txPortName)
184 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
186 .setPortType(TapiStringConstants.PORT_TYPE)
188 .setLgx(new LgxBuilder()
189 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
190 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
191 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
192 .setLgxPortShelf("00")
195 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
196 .setPort(new PortBuilder()
197 .setPortDeviceName(rxPortDeviceName)
198 .setPortName(rxPortName)
199 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
201 .setPortType(TapiStringConstants.PORT_TYPE)
203 .setLgx(new LgxBuilder()
204 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
205 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
206 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
207 .setLgxPortShelf("00")
213 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
214 String txPortName, String rxPortDeviceName, String rxPortName) {
215 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
216 .setOpticType(OpticTypes.Gray)
217 .setServiceFormat(ServiceFormat.Ethernet)
218 .setServiceRate(Uint32.valueOf(100))
219 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
220 .setPort(new PortBuilder()
221 .setPortDeviceName(txPortDeviceName)
222 .setPortName(txPortName)
223 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
225 .setPortType(TapiStringConstants.PORT_TYPE)
227 .setLgx(new LgxBuilder()
228 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
229 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
230 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
231 .setLgxPortShelf("00")
234 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
235 .setPort(new PortBuilder()
236 .setPortDeviceName(rxPortDeviceName)
237 .setPortName(rxPortName)
238 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
240 .setPortType(TapiStringConstants.PORT_TYPE)
242 .setLgx(new LgxBuilder()
243 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
244 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
245 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
246 .setLgxPortShelf("00")
252 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
253 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
254 return new ServiceAEndBuilder(sepA.getValue()).build();
255 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
256 return new ServiceAEndBuilder(sepZ.getValue()).build();
262 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
263 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
264 return new ServiceZEndBuilder(sepA.getValue()).build();
265 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
266 return new ServiceZEndBuilder(sepZ.getValue()).build();
272 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
276 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
277 // Get service path with the description in OR based models.
278 LOG.info("Service = {}", service);
279 Optional<ServicePaths> optServicePaths =
280 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
281 if (!optServicePaths.isPresent()) {
282 LOG.error("No service path found for service {}", service.getServiceName());
285 ServicePaths servicePaths = optServicePaths.get();
286 PathDescription pathDescription = servicePaths.getPathDescription();
287 LOG.info("Path description of service = {}", pathDescription);
288 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd serviceAEnd
289 = service.getServiceAEnd();
291 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
292 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd serviceZEnd
293 = service.getServiceZEnd();
294 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
295 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
296 endPointMap.put(endPoint1.key(), endPoint1);
297 endPointMap.put(endPoint2.key(), endPoint2);
298 LOG.info("EndPoints of connectivity services = {}", endPointMap);
300 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
302 // Connection creation
303 Map<ConnectionKey, Connection> connMap =
304 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
305 // TODO: full connectivity service?? With constraints and the rest of fields...
306 return new ConnectivityServiceBuilder()
307 .setAdministrativeState(AdministrativeState.UNLOCKED)
308 .setOperationalState(OperationalState.ENABLED)
309 .setLifecycleState(LifecycleState.INSTALLED)
310 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8))
312 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
313 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
314 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
315 .setName(Map.of(name.key(), name))
316 .setConnection(connMap)
317 .setEndPoint(endPointMap)
321 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
322 switch (serviceFormat) {
325 return LayerProtocolName.PHOTONICMEDIA;
327 return LayerProtocolName.ODU;
329 String node1 = endPoint1.getLocalId();
330 String node2 = endPoint2.getLocalId();
331 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
332 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
333 return LayerProtocolName.ETH;
335 return LayerProtocolName.DSR;
337 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
342 private OpenroadmNodeType getOpenroadmType(String nodeName) {
343 LOG.info("Node name = {}", nodeName);
344 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.DSR))
345 .getBytes(StandardCharsets.UTF_8)).toString());
346 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node tapiNode
347 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
348 if (tapiNode != null) {
349 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
355 private Map<ConnectionKey, Connection> createConnectionsFromService(
356 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd
358 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd
360 PathDescription pathDescription) {
361 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
362 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
363 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
364 // and the connections
366 List<String> xpdrClientTplist = new ArrayList<>();
367 List<String> xpdrNetworkTplist = new ArrayList<>();
368 List<String> rdmAddDropTplist = new ArrayList<>();
369 List<String> rdmDegTplist = new ArrayList<>();
370 List<String> rdmNodelist = new ArrayList<>();
371 List<String> xpdrNodelist = new ArrayList<>();
372 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
373 .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
374 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
375 switch (resourceType) {
376 case TapiStringConstants.TP:
377 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
378 String tpID = tp.getTpId();
380 if (tpID.contains("CLIENT")) {
381 tpNode = tp.getTpNodeId();
382 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
383 xpdrClientTplist.add(String.join("+", tpNode, tpID));
386 if (tpID.contains("NETWORK")) {
387 tpNode = tp.getTpNodeId();
388 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
389 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
392 if (tpID.contains("PP")) {
393 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
394 LOG.info("ROADM Node of tp = {}", tpNode);
395 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
396 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
399 if (tpID.contains("TTP")) {
400 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
401 LOG.info("ROADM Node of tp = {}", tpNode);
402 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
403 rdmDegTplist.add(String.join("+", tpNode, tpID));
407 case TapiStringConstants.NODE:
408 Node node = (Node) elem.getResource().getResource();
409 String nodeId = node.getNodeId();
410 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
411 LOG.info("Node id = {}", nodeId);
412 if (!xpdrNodelist.contains(nodeId)) {
413 xpdrNodelist.add(nodeId); // should contain only 2
416 if (nodeId.contains("ROADM")) {
417 nodeId = getIdBasedOnModelVersion(nodeId);
418 LOG.info("Node id = {}", nodeId);
419 if (!rdmNodelist.contains(nodeId)) {
420 rdmNodelist.add(nodeId);
425 LOG.warn("Resource is a {}", resourceType);
428 LOG.info("ROADM node list = {}", rdmNodelist);
429 LOG.info("ROADM degree list = {}", rdmDegTplist);
430 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
431 LOG.info("XPDR node list = {}", xpdrNodelist);
432 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
433 LOG.info("XPDR client list = {}", xpdrClientTplist);
434 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
435 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
436 // to trigger all the steps or not
437 String edgeRoadm1 = "";
438 String edgeRoadm2 = "";
439 if (!rdmNodelist.isEmpty()) {
440 edgeRoadm1 = rdmNodelist.get(0);
441 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
442 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
443 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
445 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
446 // CEPs must be included in the topology context as an augmentation for each ONEP!!
447 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
448 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
449 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
450 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
451 // this needs to be changed
452 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
453 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
454 switch (serviceFormat) {
456 // Identify number of ROADMs
457 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
458 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
459 // - Top Connection MC betwwen MC CEPs of different roadms
460 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
461 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
462 edgeRoadm1, edgeRoadm2));
465 // Identify number of ROADMs between XPDRs and check if OC is created
466 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
467 // - Top Connection MC betwwen MC CEPs of different roadms
468 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
469 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
470 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
471 edgeRoadm1, edgeRoadm2));
472 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
473 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
474 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
475 this.topConnRdmRdm = null;
478 // TODO: verify if this is correct
479 // - XC Connection OTSi betwwen iODU and eODU of xpdr
480 // - Top connection in the ODU layer, between xpdr eODU ports (?)
481 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
482 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
483 this.topConnXpdrXpdrPhtn = null;
487 // Check if OC, OTU and ODU are created
488 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
489 LOG.info("WDM ETH service");
490 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
491 edgeRoadm1, edgeRoadm2));
492 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
493 this.topConnRdmRdm = null;
494 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
495 LOG.info("Associated client ports = {}", xpdrClientTplist);
496 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
498 this.topConnXpdrXpdrPhtn = null;
500 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
501 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
502 // - XC Connection OTSi betwwen iODU and eODU of xpdr
503 // - Top connection in the ODU layer, between xpdr eODU ports (?)
504 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
506 this.topConnXpdrXpdrPhtn = null;
508 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
509 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
510 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
512 this.topConnXpdrXpdrOdu = null;
516 LOG.error("Service type format not supported");
518 return connectionServMap;
521 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
522 List<String> xpdrNodelist,
523 Map<ConnectionKey, Connection> lowerConn) {
524 // TODO: do we need to create cross connection between iODU and eODU??
525 // add the lower connections of the previous steps for this kind of service
526 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
527 for (Connection lowConn: lowerConn.values()) {
528 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
529 xcMap.put(conn.key(), conn);
531 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
532 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
533 ConnectionEndPoint> cepMapDsr = new HashMap<>();
534 // Create 1 cep per Xpdr in the CLIENT
535 // 1 top connection DSR between the CLIENT xpdrs
536 for (String xpdr:xpdrNodelist) {
537 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
538 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
540 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
541 LayerProtocolName.DSR);
542 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
544 cepMapDsr.put(netCep1.key(), netCep1);
546 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
547 .get(0))).findFirst().get();
548 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
549 .get(xpdrNodelist.size() - 1))).findFirst().get();
551 // DSR top connection between edge xpdr CLIENT DSR
552 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
553 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
554 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
555 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
557 // DSR top connection that will be added to the service object
558 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
559 connServMap.put(conn1.key(), conn1);
564 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
565 List<String> xpdrNetworkTplist,
566 List<String> xpdrNodelist) {
567 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
568 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
569 ConnectionEndPoint> cepMapDsr = new HashMap<>();
570 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
571 ConnectionEndPoint> cepMapOdu = new HashMap<>();
572 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
573 // be added to the lower connection of a top connection
574 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
576 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
577 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
578 for (String xpdr:xpdrNodelist) {
579 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
580 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
582 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
583 LayerProtocolName.DSR);
584 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
586 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
587 TapiStringConstants.DSR, LayerProtocolName.ODU);
588 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.DSR,
591 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
592 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
594 cepMapDsr.put(netCep1.key(), netCep1);
595 cepMapOdu.put(netCep2.key(), netCep2);
596 // Create x connection between I_ODU and E_ODU within xpdr
597 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
598 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
599 TapiStringConstants.ODU, LayerProtocolName.ODU);
600 this.connectionFullMap.put(connection.key(), connection);
602 // Create X connection that will be added to the service object
603 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
604 xcMap.put(conn.key(), conn);
607 // DSR top connection between edge xpdr CLIENT DSR
608 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
609 .get(0))).findFirst().get();
610 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
611 .get(xpdrNodelist.size() - 1))).findFirst().get();
613 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
614 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
615 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
616 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
618 // ODU top connection that will be added to the service object
619 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
620 connServMap.put(conn.key(), conn);
621 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
622 xcMap.put(lowerConn.key(), lowerConn);
624 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
625 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
626 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
627 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
629 // DSR top connection that will be added to the service object
630 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
631 connServMap.put(conn1.key(), conn1);
636 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
637 List<String> xpdrNodelist) {
638 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
639 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
640 ConnectionEndPoint> cepMap = new HashMap<>();
641 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
642 // be added to the lower connection of a top connection
643 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
645 // Create 1 cep per Xpdr in the I_ODU and a top
646 // connection iODU between the xpdrs
647 for (String xpdr:xpdrNodelist) {
648 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
649 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
651 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
652 TapiStringConstants.DSR, LayerProtocolName.ODU);
653 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
656 cepMap.put(netCep1.key(), netCep1);
659 // ODU top connection between edge xpdr i_ODU
660 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
661 .get(0))).findFirst().get();
662 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
663 .get(xpdrNodelist.size() - 1))).findFirst().get();
664 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
665 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
666 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
667 this.connectionFullMap.put(connection.key(), connection);
669 // ODU top connection that will be added to the service object
670 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
671 connServMap.put(conn.key(), conn);
672 this.topConnXpdrXpdrOdu = conn;
677 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
678 List<String> xpdrNodelist) {
679 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
680 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
681 ConnectionEndPoint> cepMap = new HashMap<>();
682 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
683 // be added to the lower connection of a top connection
684 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
686 // create ceps and x connections within xpdr
687 for (String xpdr:xpdrNodelist) {
688 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
689 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
690 // There should be 1 network tp per xpdr
691 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
692 // 3 different MC CEPs giving different IDs to show that they are different
693 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
694 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA,
695 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
696 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.OTSI,
698 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_OTSI,
699 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
700 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_OTSI, TapiStringConstants.OTSI,
702 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
703 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
704 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
706 cepMap.put(netCep1.key(), netCep1);
707 cepMap.put(netCep2.key(), netCep2);
708 cepMap.put(netCep3.key(), netCep3);
710 // Create x connection between I_OTSi and E_OTSi within xpdr
711 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
712 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork,
713 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
714 this.connectionFullMap.put(connection.key(), connection);
716 // Create X connection that will be added to the service object
717 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
718 xcMap.put(conn.key(), conn);
720 // OTSi top connection between edge I_OTSI Xpdr
721 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
722 .get(0))).findFirst().get();
723 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
724 .get(xpdrNodelist.size() - 1))).findFirst().get();
725 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
726 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
727 LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
728 this.connectionFullMap.put(connection.key(), connection);
730 // OTSi top connection that will be added to the service object
731 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
732 connServMap.put(conn.key(), conn);
733 this.topConnXpdrXpdrPhtn = conn;
738 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
739 List<String> rdmDegTplist,
740 List<String> rdmNodelist,
741 String edgeRoadm1, String edgeRoadm2) {
742 // TODO: will need to check if things exist already or not
743 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
744 ConnectionEndPoint> cepMap = new HashMap<>();
745 // create ceps and x connections within roadm
746 Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
747 for (String roadm : rdmNodelist) {
748 LOG.info("Creating ceps and xc for roadm {}", roadm);
749 if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
750 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
751 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
752 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
753 // There should be only 1 AD and 1 DEG per roadm
754 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
755 // 3 different MC CEPs giving different IDs to show that they are different
756 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
757 // created in the topology creation
758 // add CEPs to the topology to the corresponding ONEP
759 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA);
760 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA, adCep1);
761 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
762 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
763 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
764 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
765 cepMap.put(adCep1.key(), adCep1);
766 cepMap.put(adCep2.key(), adCep2);
767 cepMap.put(adCep3.key(), adCep3);
769 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
770 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
772 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
773 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA, degCep1);
774 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
775 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
776 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
777 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
778 cepMap.put(degCep1.key(), degCep1);
779 cepMap.put(degCep2.key(), degCep2);
780 cepMap.put(degCep3.key(), degCep3);
782 LOG.info("Going to create cross connections for ROADM {}", roadm);
783 // Create X connections between MC and OTSi_MC for full map
784 org.opendaylight.yang.gen.v1.urn
785 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection connection1
786 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
787 LayerProtocolName.PHOTONICMEDIA);
788 LOG.info("Cross connection 1 created = {}", connection1.toString());
789 org.opendaylight.yang.gen.v1.urn
790 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection connection2
791 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
792 LayerProtocolName.PHOTONICMEDIA);
793 LOG.info("Cross connection 2 created = {}", connection2.toString());
794 this.connectionFullMap.put(connection1.key(), connection1);
795 this.connectionFullMap.put(connection2.key(), connection2);
797 // Create X connections that will be added to the service object
798 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
799 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
801 xcLowerMap.put(conn1.key(), conn1);
802 xcLowerMap.put(conn2.key(), conn2);
804 LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
805 String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
806 LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
808 ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA);
809 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA, deg1Cep1);
810 ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC);
811 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2);
812 ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC);
813 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3);
814 cepMap.put(deg1Cep1.key(), deg1Cep1);
815 cepMap.put(deg1Cep2.key(), deg1Cep2);
816 cepMap.put(deg1Cep3.key(), deg1Cep3);
818 String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().get();
819 LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
821 ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA);
822 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA, deg2Cep1);
823 ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC);
824 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2);
825 ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC);
826 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3);
827 cepMap.put(deg2Cep1.key(), deg2Cep1);
828 cepMap.put(deg2Cep2.key(), deg2Cep2);
829 cepMap.put(deg2Cep3.key(), deg2Cep3);
831 LOG.info("Going to create cross connections for ROADM {}", roadm);
832 // Create X connections between MC and OTSi_MC for full map
833 org.opendaylight.yang.gen.v1.urn
834 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection connection1
835 = createXCBetweenCeps(deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
836 TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
837 LOG.info("Cross connection 1 created = {}", connection1.toString());
838 org.opendaylight.yang.gen.v1.urn
839 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection connection2
840 = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
841 TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
842 LOG.info("Cross connection 2 created = {}", connection2.toString());
843 this.connectionFullMap.put(connection1.key(), connection1);
844 this.connectionFullMap.put(connection2.key(), connection2);
846 // Create X connections that will be added to the service object
847 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
848 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
850 xcLowerMap.put(conn1.key(), conn1);
851 xcLowerMap.put(conn2.key(), conn2);
854 LOG.info("Going to create top connections between roadms");
855 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
856 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
857 // MC top connection between edge roadms
858 LOG.info("Going to created top connection between MC");
859 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
860 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
861 LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
862 this.connectionFullMap.put(connection.key(), connection);
863 LOG.info("Top connection created = {}", connection.toString());
865 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
866 // OTSiMC top connections that will be added to the service object
867 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
868 connServMap.put(conn.key(), conn);
869 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
870 Map<LowerConnectionKey, LowerConnection> topLowerMap = new HashMap<>();
871 topLowerMap.put(conn1.key(), conn1);
873 // OTSiMC top connection between edge roadms
874 LOG.info("Going to created top connection between OTSiMC");
875 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
876 connection1 = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
877 LayerProtocolName.PHOTONICMEDIA, topLowerMap, null);
878 this.connectionFullMap.put(connection1.key(), connection1);
879 LOG.info("Top connection created = {}", connection1.toString());
881 // OTSiMC top connections that will be added to the service object
882 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
883 connServMap.put(conn2.key(), conn2);
884 this.topConnRdmRdm = conn2;
888 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
889 createTopConnection(String tp1, String tp2,
890 Map<org.opendaylight.yang.gen.v1.urn
891 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
892 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
893 Map<LowerConnectionKey, LowerConnection> xcMap, Connection additionalLowerConn) {
894 // find cep for each AD MC of roadm 1 and 2
895 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
896 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
897 cepMap.get(new org.opendaylight.yang.gen.v1.urn
898 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
899 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
900 qual, tp1.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
902 LOG.info("ADCEP1 = {}", adCep1);
903 org.opendaylight.yang.gen.v1.urn
904 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
905 new org.opendaylight.yang.gen.v1.urn
906 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
907 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
908 .values().stream().findFirst().get().getNodeEdgePointUuid())
909 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
910 .values().stream().findFirst().get().getTopologyUuid())
911 .setNodeUuid(adCep1.getClientNodeEdgePoint()
912 .values().stream().findFirst().get().getNodeUuid())
913 .setConnectionEndPointUuid(adCep1.getUuid())
915 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
916 cepMap.get(new org.opendaylight.yang.gen.v1.urn
917 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
918 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
919 qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
921 LOG.info("ADCEP2 = {}", adCep2);
922 org.opendaylight.yang.gen.v1.urn
923 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
924 new org.opendaylight.yang.gen.v1.urn
925 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
926 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
927 .values().stream().findFirst().get().getNodeEdgePointUuid())
928 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
929 .values().stream().findFirst().get().getTopologyUuid())
930 .setNodeUuid(adCep2.getClientNodeEdgePoint()
931 .values().stream().findFirst().get().getNodeUuid())
932 .setConnectionEndPointUuid(adCep1.getUuid())
934 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
935 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
936 ceps.put(cep1.key(), cep1);
937 ceps.put(cep2.key(), cep2);
938 Name connName = new NameBuilder()
939 .setValueName("Connection name")
940 .setValue(String.join("+", "TOP", tp1, tp2, qual))
942 // TODO: lower connection, supported link.......
943 if (additionalLowerConn != null) {
944 xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
945 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
947 return new org.opendaylight.yang.gen.v1.urn
948 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
949 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
950 .getBytes(StandardCharsets.UTF_8)).toString()))
951 .setName(Map.of(connName.key(), connName))
952 .setConnectionEndPoint(ceps)
953 .setOperationalState(OperationalState.ENABLED)
954 .setLayerProtocolName(topPortocol)
955 .setLifecycleState(LifecycleState.INSTALLED)
956 .setDirection(ForwardingDirection.BIDIRECTIONAL)
957 .setLowerConnection(xcMap)
961 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
962 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
963 LayerProtocolName xcProtocol) {
964 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
965 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
966 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
967 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
968 org.opendaylight.yang.gen.v1.urn
969 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
970 new org.opendaylight.yang.gen.v1.urn
971 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
972 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
973 .values().stream().findFirst().get().getNodeEdgePointUuid())
974 .setTopologyUuid(cep1.getClientNodeEdgePoint()
975 .values().stream().findFirst().get().getTopologyUuid())
976 .setNodeUuid(cep1.getClientNodeEdgePoint()
977 .values().stream().findFirst().get().getNodeUuid())
978 .setConnectionEndPointUuid(cep1.getUuid())
980 org.opendaylight.yang.gen.v1.urn
981 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
982 new org.opendaylight.yang.gen.v1.urn
983 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
984 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
985 .values().stream().findFirst().get().getNodeEdgePointUuid())
986 .setTopologyUuid(cep2.getClientNodeEdgePoint()
987 .values().stream().findFirst().get().getTopologyUuid())
988 .setNodeUuid(cep2.getClientNodeEdgePoint()
989 .values().stream().findFirst().get().getNodeUuid())
990 .setConnectionEndPointUuid(cep2.getUuid())
992 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
993 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
994 ceps.put(cepServ1.key(), cepServ1);
995 ceps.put(cepServ2.key(), cepServ2);
996 Name connName = new NameBuilder()
997 .setValueName("Connection name")
998 .setValue(String.join("+", "XC", tp1, tp2, qual))
1000 // TODO: lower connection, supported link.......
1001 return new org.opendaylight.yang.gen.v1.urn
1002 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
1003 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
1004 .getBytes(StandardCharsets.UTF_8)).toString()))
1005 .setName(Map.of(connName.key(), connName))
1006 .setConnectionEndPoint(ceps)
1007 .setOperationalState(OperationalState.ENABLED)
1008 .setLayerProtocolName(xcProtocol)
1009 .setLifecycleState(LifecycleState.INSTALLED)
1010 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1014 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
1015 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1016 Name cepName = new NameBuilder()
1017 .setValueName("ConnectionEndPoint name")
1018 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1019 id.split("\\+")[1]))
1021 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1022 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1023 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1025 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1026 qualifier)).getBytes(StandardCharsets.UTF_8))
1028 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1029 .getBytes(StandardCharsets.UTF_8)).toString()))
1031 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1032 // TODO: add parent ONEP??
1033 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1034 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1035 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1037 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
1038 .setName(Map.of(cepName.key(), cepName))
1039 .setConnectionPortRole(PortRole.SYMMETRIC)
1040 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
1041 .setOperationalState(OperationalState.ENABLED)
1042 .setLifecycleState(LifecycleState.INSTALLED)
1043 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
1044 return cepBldr.build();
1047 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
1048 LayerProtocolName cepProtocol) {
1049 Name cepName = new NameBuilder()
1050 .setValueName("ConnectionEndPoint name")
1051 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1052 id.split("\\+")[1]))
1054 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1055 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1056 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1058 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1059 nodeLayer)).getBytes(StandardCharsets.UTF_8))
1061 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1062 .getBytes(StandardCharsets.UTF_8)).toString()))
1064 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1065 // TODO: add parent ONEP??
1066 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1067 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1068 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1070 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
1071 .setName(Map.of(cepName.key(), cepName))
1072 .setConnectionPortRole(PortRole.SYMMETRIC)
1073 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
1074 .setOperationalState(OperationalState.ENABLED)
1075 .setLifecycleState(LifecycleState.INSTALLED)
1076 .setLayerProtocolName(cepProtocol);
1077 return cepBldr.build();
1080 private EndPoint mapServiceZEndPoint(
1081 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd
1082 serviceZEnd, PathDescription pathDescription) {
1083 EndPointBuilder endPointBuilder = new EndPointBuilder();
1084 // 1. Service Format: ODU, OTU, ETH
1085 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1086 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1087 // Identify SIP name
1088 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1089 LOG.info("Uuid of z end {}", sipUuid);
1090 LayerProtocolName layerProtocols = null;
1091 // Layer protocol name
1092 switch (serviceFormat) {
1094 layerProtocols = LayerProtocolName.DSR;
1098 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1101 layerProtocols = LayerProtocolName.ODU;
1104 LOG.error("Service Format not supported");
1106 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1107 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1108 .setValueName("OpenROADM info")
1109 .setValue(String.join("-", serviceZEnd.getClli(),
1110 serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
1111 serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
1113 return endPointBuilder
1114 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1115 .setServiceInterfacePointUuid(sipUuid)
1117 .setName(Map.of(name.key(), name))
1118 .setAdministrativeState(AdministrativeState.UNLOCKED)
1119 .setDirection(PortDirection.BIDIRECTIONAL)
1120 .setLifecycleState(LifecycleState.INSTALLED)
1121 .setOperationalState(OperationalState.ENABLED)
1122 .setLayerProtocolName(layerProtocols)
1123 .setCapacity(new CapacityBuilder()
1124 .setTotalSize(new TotalSizeBuilder()
1125 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
1126 .setUnit(CapacityUnit.GBPS)
1128 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1130 .setProtectionRole(ProtectionRole.WORK)
1131 .setRole(PortRole.SYMMETRIC)
1132 .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().get()
1133 .getPort().getPortDeviceName())
1137 private EndPoint mapServiceAEndPoint(
1138 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd
1139 serviceAEnd, PathDescription pathDescription) {
1140 EndPointBuilder endPointBuilder = new EndPointBuilder();
1141 // 1. Service Format: ODU, OTU, ETH
1142 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1143 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1144 // Identify SIP name
1145 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1146 LOG.info("Uuid of a end {}", sipUuid);
1147 LayerProtocolName layerProtocols = null;
1148 // Layer protocol name
1149 switch (serviceFormat) {
1151 layerProtocols = LayerProtocolName.DSR;
1155 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1158 layerProtocols = LayerProtocolName.ODU;
1161 LOG.error("Service Format not supported");
1163 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1164 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1165 .setValueName("OpenROADM info")
1166 .setValue(String.join("-", serviceAEnd.getClli(),
1167 serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
1168 serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
1170 return endPointBuilder
1171 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1172 .setServiceInterfacePointUuid(sipUuid)
1174 .setName(Map.of(name.key(), name))
1175 .setAdministrativeState(AdministrativeState.UNLOCKED)
1176 .setDirection(PortDirection.BIDIRECTIONAL)
1177 .setLifecycleState(LifecycleState.INSTALLED)
1178 .setOperationalState(OperationalState.ENABLED)
1179 .setLayerProtocolName(layerProtocols)
1180 .setCapacity(new CapacityBuilder()
1181 .setTotalSize(new TotalSizeBuilder()
1182 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
1183 .setUnit(CapacityUnit.GBPS)
1185 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1187 .setProtectionRole(ProtectionRole.WORK)
1188 .setRole(PortRole.SYMMETRIC)
1189 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName())
1193 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1194 Uuid zendUuid = null;
1195 if (serviceNodeId.contains("ROADM")) {
1196 // Service from ROADM to ROADM
1197 // AddDrop-AddDrop ports --> MC layer SIPs
1198 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1199 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1200 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1201 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1203 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1204 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1205 if (!sip.getUuid().equals(sipUuid)) {
1206 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1209 zendUuid = sip.getUuid();
1213 // Service from XPDR to XPDR
1215 TerminationPoint tp;
1217 switch (serviceFormat) {
1219 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1220 tp = (TerminationPoint) firstElement.getResource().getResource();
1221 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1222 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1223 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1224 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1228 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1229 tp = (TerminationPoint) firstElement.getResource().getResource();
1230 // Network-Network ports --> iOTSi layer SIPs
1231 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1232 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1233 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1237 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1238 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1239 tp = (TerminationPoint) firstElement.getResource().getResource();
1240 // Client-client ports --> DSR layer SIPs
1241 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1242 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1243 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1248 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1250 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1251 if (!sip.getUuid().equals(sipUuid)) {
1252 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1255 zendUuid = sip.getUuid();
1262 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1263 Uuid aendUuid = null;
1264 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1265 LOG.info("Map a to z = {}", mapatoz);
1266 if (serviceNodeId.contains("ROADM")) {
1267 // Service from ROADM to ROADM
1268 // AddDrop-AddDrop ports --> MC layer SIPs
1269 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1270 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1271 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1272 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1273 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1275 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1277 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1278 if (!sip.getUuid().equals(sipUuid)) {
1279 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1282 aendUuid = sip.getUuid();
1286 // Service from XPDR to XPDR
1288 TerminationPoint tp;
1290 switch (serviceFormat) {
1292 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1293 tp = (TerminationPoint) firstElement.getResource().getResource();
1294 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1295 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1296 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1297 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1298 TapiStringConstants.I_ODU, tp.getTpId()));
1301 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1302 tp = (TerminationPoint) firstElement.getResource().getResource();
1303 // Network-Network ports --> iOTSi layer SIPs
1304 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1305 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1306 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1307 TapiStringConstants.I_OTSI, tp.getTpId()));
1310 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1311 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1312 tp = (TerminationPoint) firstElement.getResource().getResource();
1313 // Client-client ports --> DSR layer SIPs
1314 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1315 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1316 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1317 TapiStringConstants.DSR, tp.getTpId()));
1321 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1323 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1324 if (!sip.getUuid().equals(sipUuid)) {
1325 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1328 aendUuid = sip.getUuid();
1335 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1336 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1337 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1338 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1339 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1340 .getBytes(StandardCharsets.UTF_8)).toString());
1341 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1342 .getBytes(StandardCharsets.UTF_8)).toString());
1343 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1344 .getBytes(StandardCharsets.UTF_8)).toString());
1345 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1348 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1349 ConnectionEndPoint cep) {
1350 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1351 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1352 .getBytes(StandardCharsets.UTF_8)).toString());
1353 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1354 .getBytes(StandardCharsets.UTF_8)).toString());
1355 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1356 .getBytes(StandardCharsets.UTF_8)).toString());
1357 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1360 public Map<org.opendaylight.yang.gen.v1.urn
1361 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1362 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1363 getConnectionFullMap() {
1364 return this.connectionFullMap;
1367 private String getIdBasedOnModelVersion(String nodeid) {
1368 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1369 nodeid.split("-")[1]) : nodeid.split("-")[0];
1372 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1373 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1374 Map<org.opendaylight.yang.gen.v1.urn
1375 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1376 org.opendaylight.yang.gen.v1.urn
1377 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1378 endPointMap = input.getEndPoint();
1379 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1380 ConnectionType connType = null;
1381 ServiceFormat serviceFormat = null;
1382 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1383 TapiStringConstants.DSR);
1384 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1385 TapiStringConstants.DSR);
1386 LOG.debug("Node a = {}", nodeAid);
1387 LOG.debug("Node z = {}", nodeZid);
1388 switch (constraint.getServiceLayer().getIntValue()) {
1391 connType = ConnectionType.Infrastructure;
1392 serviceFormat = ServiceFormat.ODU;
1395 LOG.info("ETH, no need to create OTU and ODU");
1396 connType = ConnectionType.Service;
1397 serviceFormat = ServiceFormat.Ethernet;
1400 LOG.info("DSR, need to create OTU and ODU");
1401 connType = ConnectionType.Service;
1402 serviceFormat = ServiceFormat.Ethernet;
1405 LOG.info("PHOTONIC");
1406 connType = getConnectionTypePhtnc(endPointMap.values());
1407 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1408 if (serviceFormat.equals(ServiceFormat.OC)) {
1409 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1410 TapiStringConstants.PHTNC_MEDIA);
1411 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1412 TapiStringConstants.PHTNC_MEDIA);
1414 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1415 TapiStringConstants.OTSI);
1416 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1417 TapiStringConstants.OTSI);
1419 LOG.debug("Node a photonic = {}", nodeAid);
1420 LOG.debug("Node z photonic = {}", nodeZid);
1423 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1425 // Requested Capacity for connectivity service
1426 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1427 // map endpoints into service end points. Map the type of service from TAPI to OR
1428 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1429 serviceFormat, nodeAid, capacity, constraint.getServiceLayer());
1430 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1431 serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
1432 if (serviceAEnd == null || serviceZEnd == null) {
1433 LOG.error("Couldnt map endpoints to service end");
1436 LOG.info("Service a end = {}", serviceAEnd);
1437 LOG.info("Service z end = {}", serviceZEnd);
1438 return new ServiceCreateInputBuilder()
1439 .setServiceAEnd(serviceAEnd)
1440 .setServiceZEnd(serviceZEnd)
1441 .setConnectionType(connType)
1442 .setServiceName(serviceUuid.getValue())
1443 .setCommonId("common id")
1444 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1445 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1446 .setRequestSystemId("appname")
1448 .setCustomer("customer")
1449 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1450 .setOperatorContact("pw1234")
1454 private ServiceZEnd tapiEndPointToServiceZPoint(
1455 org.opendaylight.yang.gen.v1.urn
1456 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1457 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1458 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1459 // Not the rest which is needed in the txPortDeviceName.
1460 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1461 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1462 // Todo -> need to find the NEP associated to that SIP
1463 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString());
1464 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1465 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1467 LOG.error("Node not found in datastore");
1470 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1471 // connection is between 2 CLIENT ports. Otherwise it will not work...
1472 OwnedNodeEdgePoint nep = null;
1473 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1474 if (onep.getMappedServiceInterfacePoint() == null) {
1477 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1483 LOG.error("Nep not found in datastore");
1486 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1487 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1488 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1489 String txPortDeviceName = nepName.split("\\+")[0];
1490 String txPortName = nepName.split("\\+")[2];
1491 String rxPortDeviceName = txPortDeviceName;
1492 String rxPortName = txPortName;
1493 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1494 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1495 // TODO --> get clli from datastore?
1496 String clli = "NodeSC";
1497 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1498 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1499 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1501 .setNodeId(new NodeIdType(nodeid))
1502 .setOpticType(OpticTypes.Gray)
1503 .setServiceFormat(serviceFormat)
1504 .setServiceRate(Uint32.valueOf(capacity))
1505 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1506 .setCommittedBurstSize(Uint16.valueOf(64))
1507 .setCommittedInfoRate(Uint32.valueOf(100000))
1510 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1511 .setPort(new PortBuilder()
1512 .setPortDeviceName(txPortDeviceName)
1513 .setPortName(txPortName)
1514 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1516 .setPortType(TapiStringConstants.PORT_TYPE)
1518 .setLgx(new LgxBuilder()
1519 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1520 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1521 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1522 .setLgxPortShelf("00")
1524 .setIndex(Uint8.ZERO)
1526 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1527 .setPort(new PortBuilder()
1528 .setPortDeviceName(rxPortDeviceName)
1529 .setPortName(rxPortName)
1530 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1532 .setPortType(TapiStringConstants.PORT_TYPE)
1534 .setLgx(new LgxBuilder()
1535 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1536 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1537 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1538 .setLgxPortShelf("00")
1540 .setIndex(Uint8.ZERO)
1542 if (serviceFormat.equals(ServiceFormat.ODU)) {
1543 serviceZEndBuilder.setOduServiceRate(ODU4.VALUE);
1545 if (serviceFormat.equals(ServiceFormat.OTU)) {
1546 serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
1548 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1550 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1551 .setCommittedBurstSize(Uint16.valueOf(64))
1552 .setCommittedInfoRate(Uint32.valueOf(100000))
1556 return serviceZEndBuilder.build();
1559 private ServiceAEnd tapiEndPointToServiceAPoint(
1560 org.opendaylight.yang.gen.v1.urn
1561 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1562 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1563 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1564 // Not the rest which is needed in the txPortDeviceName.
1565 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1566 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1567 // Todo -> need to find the NEP associated to that SIP
1568 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString());
1569 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1570 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1572 LOG.error("Node not found in datastore");
1575 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1576 // connection is between 2 CLIENT ports. Otherwise it will not work...
1577 OwnedNodeEdgePoint nep = null;
1578 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1579 if (onep.getMappedServiceInterfacePoint() == null) {
1582 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1588 LOG.error("Nep not found in datastore");
1591 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1592 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1593 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1594 String txPortDeviceName = nepName.split("\\+")[0];
1595 String txPortName = nepName.split("\\+")[2];
1596 String rxPortDeviceName = txPortDeviceName;
1597 String rxPortName = txPortName;
1598 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1599 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1600 // TODO --> get clli from datastore?
1601 String clli = "NodeSA";
1602 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1603 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1604 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1606 .setNodeId(new NodeIdType(nodeid))
1607 .setOpticType(OpticTypes.Gray)
1608 .setServiceFormat(serviceFormat)
1609 .setServiceRate(Uint32.valueOf(capacity))
1610 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1611 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.subrate.eth
1612 .sla.SubrateEthSlaBuilder()
1613 .setCommittedBurstSize(Uint16.valueOf(64))
1614 .setCommittedInfoRate(Uint32.valueOf(100000))
1617 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1618 .setPort(new PortBuilder()
1619 .setPortDeviceName(txPortDeviceName)
1620 .setPortName(txPortName)
1621 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1623 .setPortType(TapiStringConstants.PORT_TYPE)
1625 .setLgx(new LgxBuilder()
1626 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1627 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1628 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1629 .setLgxPortShelf("00")
1631 .setIndex(Uint8.ZERO)
1633 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1634 .setPort(new PortBuilder()
1635 .setPortDeviceName(rxPortDeviceName)
1636 .setPortName(rxPortName)
1637 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1639 .setPortType(TapiStringConstants.PORT_TYPE)
1641 .setLgx(new LgxBuilder()
1642 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1643 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1644 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1645 .setLgxPortShelf("00")
1647 .setIndex(Uint8.ZERO)
1649 if (serviceFormat.equals(ServiceFormat.ODU)) {
1650 serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
1652 if (serviceFormat.equals(ServiceFormat.OTU)) {
1653 serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
1655 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1657 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1658 .setCommittedBurstSize(Uint16.valueOf(64))
1659 .setCommittedInfoRate(Uint32.valueOf(100000))
1663 return serviceAEndBuilder.build();
1666 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1667 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1668 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1669 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1670 // EndPoints are ROADMs
1671 return ConnectionType.RoadmLine;
1673 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1674 return ConnectionType.Infrastructure;
1677 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1678 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1679 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1680 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1681 // EndPoints are ROADMs
1682 return ServiceFormat.OC;
1684 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1685 return ServiceFormat.OTU;
1688 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1689 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1690 TapiStringConstants.DSR).getBytes(StandardCharsets.UTF_8))).toString());
1691 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1692 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8)))
1694 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1695 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1696 .getBytes(StandardCharsets.UTF_8)).toString());
1697 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1700 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1701 for (String networkPort:xpdrNetworkTplist) {
1702 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1709 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1710 List<String> clientPortList = new ArrayList<>();
1711 for (String networkPort:xpdrNetworkTplist) {
1712 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1713 networkPort.split("\\+")[0].split("-")[1]);
1714 String tpId = networkPort.split("\\+")[1];
1715 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1716 .child(Nodes.class, new NodesKey(nodeId))
1717 .child(Mapping.class, new MappingKey(tpId)).build();
1719 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1721 if (!optMapping.isPresent()) {
1722 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1724 Mapping mapping = optMapping.get();
1725 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1726 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1727 mapping.getConnectionMapLcp());
1728 LOG.info("Key to be added to list = {}", key);
1729 if (!clientPortList.contains(key)) {
1730 clientPortList.add(key);
1732 } catch (InterruptedException | ExecutionException e) {
1733 LOG.error("Couldnt read mapping from datastore", e);
1738 return clientPortList;
1741 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1742 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1743 for (String xpdrNode:xpdrNodelist) {
1744 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.DSR))
1745 .getBytes(StandardCharsets.UTF_8)).toString());
1746 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1747 .onf.otcc.yang.tapi.topology.rev181210.topology.Node> nodeIID = InstanceIdentifier.builder(
1748 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1749 .onf.otcc.yang.tapi.topology.rev181210.Context1.class).child(TopologyContext.class)
1750 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1751 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
1752 new NodeKey(nodeUuid)).build();
1754 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> optNode
1755 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1756 if (!optNode.isPresent()) {
1759 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
1760 new NameKey("Node Type")).getValue());
1761 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1762 openroadmNodeTypeList.add(openroadmNodeType);
1764 } catch (InterruptedException | ExecutionException e) {
1765 LOG.error("Couldnt read node in topology", e);
1769 // TODO for now check that there is only one type, otherwise error
1770 if (openroadmNodeTypeList.size() != 1) {
1771 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1774 return openroadmNodeTypeList.get(0);