2 * Copyright © 2018 Orange & 2021 Nokia, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.tapi.connectivity;
10 import java.nio.charset.Charset;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Comparator;
14 import java.util.HashMap;
15 import java.util.List;
17 import java.util.Optional;
18 import java.util.UUID;
19 import java.util.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.rev220114.Network;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.MappingKey;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.NodesKey;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev181130.OpticTypes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.Service;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.SubrateEthSlaBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.OTU4;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEnd;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEndBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEnd;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEndBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription;
55 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
56 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
57 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToA;
58 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ztoa.direction.ZToAKey;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.Node;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPoint;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.BandwidthProfileBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ProtectionRole;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ServiceType;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointKey;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnection;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnectionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.LowerConnectionKey;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePoint;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePointBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionKey;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.CapacityBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.ConnectivityConstraint;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
108 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
109 import org.opendaylight.yangtools.yang.common.Uint16;
110 import org.opendaylight.yangtools.yang.common.Uint32;
111 import org.opendaylight.yangtools.yang.common.Uint64;
112 import org.slf4j.Logger;
113 import org.slf4j.LoggerFactory;
115 public final class ConnectivityUtils {
117 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
118 .getBytes(Charset.forName("UTF-8"))).toString());
119 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
121 private final ServiceDataStoreOperations serviceDataStoreOperations;
122 private final TapiContext tapiContext;
123 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
124 private final Map<org.opendaylight.yang.gen.v1.urn
125 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
126 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
127 connectionFullMap; // this variable is for complete connection objects
128 private final NetworkTransactionService networkTransactionService;
130 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
131 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
132 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
133 NetworkTransactionService networkTransactionService) {
134 this.serviceDataStoreOperations = serviceDataStoreOperations;
135 this.tapiContext = tapiContext;
136 this.sipMap = sipMap;
137 this.connectionFullMap = new HashMap<>();
138 this.networkTransactionService = networkTransactionService;
141 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
142 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
143 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
144 if (serviceAEnd == null || serviceZEnd == null) {
145 LOG.warn("One of the endpoints could not be identified");
148 return new ServiceCreateInputBuilder()
149 .setCommonId("commonId")
150 .setConnectionType(ConnectionType.Service)
151 .setCustomer("Customer")
152 .setServiceName("service test")
153 .setServiceAEnd(serviceAEnd)
154 .setServiceZEnd(serviceZEnd)
155 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
156 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
162 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
163 String txPortName, String rxPortDeviceName, String rxPortName) {
164 return new ServiceAEndBuilder()
166 .setNodeId(new NodeIdType(nodeid))
167 .setOpticType(OpticTypes.Gray)
168 .setServiceFormat(ServiceFormat.Ethernet)
169 .setServiceRate(Uint32.valueOf(100))
170 .setTxDirection(new TxDirectionBuilder()
171 .setPort(new PortBuilder()
172 .setPortDeviceName(txPortDeviceName)
173 .setPortName(txPortName)
174 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
176 .setPortType(TapiStringConstants.PORT_TYPE)
178 .setLgx(new LgxBuilder()
179 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
180 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
181 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
182 .setLgxPortShelf("00")
185 .setRxDirection(new RxDirectionBuilder()
186 .setPort(new PortBuilder()
187 .setPortDeviceName(rxPortDeviceName)
188 .setPortName(rxPortName)
189 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
191 .setPortType(TapiStringConstants.PORT_TYPE)
193 .setLgx(new LgxBuilder()
194 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
195 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
196 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
197 .setLgxPortShelf("00")
203 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
204 String txPortName, String rxPortDeviceName, String rxPortName) {
205 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
206 .setOpticType(OpticTypes.Gray)
207 .setServiceFormat(ServiceFormat.Ethernet)
208 .setServiceRate(Uint32.valueOf(100))
209 .setTxDirection(new TxDirectionBuilder()
210 .setPort(new PortBuilder()
211 .setPortDeviceName(txPortDeviceName)
212 .setPortName(txPortName)
213 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
215 .setPortType(TapiStringConstants.PORT_TYPE)
217 .setLgx(new LgxBuilder()
218 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
219 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
220 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
221 .setLgxPortShelf("00")
224 .setRxDirection(new RxDirectionBuilder()
225 .setPort(new PortBuilder()
226 .setPortDeviceName(rxPortDeviceName)
227 .setPortName(rxPortName)
228 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
230 .setPortType(TapiStringConstants.PORT_TYPE)
232 .setLgx(new LgxBuilder()
233 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
234 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
235 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
236 .setLgxPortShelf("00")
242 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
243 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
244 return new ServiceAEndBuilder(sepA.getValue()).build();
245 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
246 return new ServiceAEndBuilder(sepZ.getValue()).build();
252 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
253 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
254 return new ServiceZEndBuilder(sepA.getValue()).build();
255 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
256 return new ServiceZEndBuilder(sepZ.getValue()).build();
262 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
266 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
267 // Get service path with the description in OR based models.
268 LOG.info("Service = {}", service);
269 Optional<ServicePaths> optServicePaths =
270 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
271 if (!optServicePaths.isPresent()) {
272 LOG.error("No service path found for service {}", service.getServiceName());
275 ServicePaths servicePaths = optServicePaths.get();
276 PathDescription pathDescription = servicePaths.getPathDescription();
277 LOG.info("Path description of service = {}", pathDescription);
278 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd
279 = service.getServiceAEnd();
281 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
282 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd
283 = service.getServiceZEnd();
284 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
285 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
286 endPointMap.put(endPoint1.key(), endPoint1);
287 endPointMap.put(endPoint2.key(), endPoint2);
288 LOG.info("EndPoints of connectivity services = {}", endPointMap);
290 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
292 // Connection creation
293 Map<ConnectionKey, Connection> connMap =
294 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
295 // TODO: full connectivity service?? With constraints and the rest of fields...
296 return new ConnectivityServiceBuilder()
297 .setAdministrativeState(AdministrativeState.UNLOCKED)
298 .setOperationalState(OperationalState.ENABLED)
299 .setLifecycleState(LifecycleState.INSTALLED)
300 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
302 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
303 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
304 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
305 .setName(Map.of(name.key(), name))
306 .setConnection(connMap)
307 .setEndPoint(endPointMap)
311 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
312 switch (serviceFormat) {
315 return LayerProtocolName.PHOTONICMEDIA;
317 return LayerProtocolName.ODU;
319 String node1 = endPoint1.getLocalId();
320 String node2 = endPoint2.getLocalId();
321 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
322 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
323 return LayerProtocolName.ETH;
325 return LayerProtocolName.DSR;
327 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
332 private OpenroadmNodeType getOpenroadmType(String nodeName) {
333 LOG.info("Node name = {}", nodeName);
334 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.DSR))
335 .getBytes(Charset.forName("UTF-8"))).toString());
336 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node tapiNode
337 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
338 if (tapiNode != null) {
339 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
345 private Map<ConnectionKey, Connection> createConnectionsFromService(
346 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
348 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
350 PathDescription pathDescription) {
351 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
352 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
353 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
354 // and the connections
356 List<String> xpdrClientTplist = new ArrayList<>();
357 List<String> xpdrNetworkTplist = new ArrayList<>();
358 List<String> rdmAddDropTplist = new ArrayList<>();
359 List<String> rdmDegTplist = new ArrayList<>();
360 List<String> rdmNodelist = new ArrayList<>();
361 List<String> xpdrNodelist = new ArrayList<>();
362 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
363 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
364 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
365 switch (resourceType) {
366 case TapiStringConstants.TP:
367 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
368 String tpID = tp.getTpId();
370 if (tpID.contains("CLIENT")) {
371 tpNode = tp.getTpNodeId();
372 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
373 xpdrClientTplist.add(String.join("+", tpNode, tpID));
376 if (tpID.contains("NETWORK")) {
377 tpNode = tp.getTpNodeId();
378 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
379 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
382 if (tpID.contains("PP")) {
383 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
384 LOG.info("ROADM Node of tp = {}", tpNode);
385 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
386 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
389 if (tpID.contains("TTP")) {
390 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
391 LOG.info("ROADM Node of tp = {}", tpNode);
392 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
393 rdmDegTplist.add(String.join("+", tpNode, tpID));
397 case TapiStringConstants.NODE:
398 Node node = (Node) elem.getResource().getResource();
399 String nodeId = node.getNodeId();
400 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
401 LOG.info("Node id = {}", nodeId);
402 if (!xpdrNodelist.contains(nodeId)) {
403 xpdrNodelist.add(nodeId); // should contain only 2
406 if (nodeId.contains("ROADM")) {
407 nodeId = getIdBasedOnModelVersion(nodeId);
408 LOG.info("Node id = {}", nodeId);
409 if (!rdmNodelist.contains(nodeId)) {
410 rdmNodelist.add(nodeId);
415 LOG.warn("Resource is a {}", resourceType);
418 LOG.info("ROADM node list = {}", rdmNodelist);
419 LOG.info("ROADM degree list = {}", rdmDegTplist);
420 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
421 LOG.info("XPDR node list = {}", xpdrNodelist);
422 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
423 LOG.info("XPDR client list = {}", xpdrClientTplist);
424 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
425 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
426 // to trigger all the steps or not
427 String edgeRoadm1 = "";
428 String edgeRoadm2 = "";
429 if (!rdmNodelist.isEmpty()) {
430 edgeRoadm1 = rdmNodelist.get(0);
431 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
432 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
433 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
435 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
436 // CEPs must be included in the topology context as an augmentation for each ONEP!!
437 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
438 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
439 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
440 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
441 // this needs to be changed
442 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
443 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
444 switch (serviceFormat) {
446 // Identify number of ROADMs
447 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
448 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
449 // - Top Connection MC betwwen MC CEPs of different roadms
450 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
451 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
452 edgeRoadm1, edgeRoadm2));
455 // Identify number of ROADMs between XPDRs and check if OC is created
456 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
457 // - Top Connection MC betwwen MC CEPs of different roadms
458 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
459 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
460 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
461 edgeRoadm1, edgeRoadm2));
462 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
463 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
464 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
467 // - XC Connection OTSi betwwen iODU and eODU of xpdr
468 // - Top connection in the ODU layer, between xpdr eODU ports (?)
469 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
472 // Check if OC, OTU and ODU are created
473 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
474 LOG.info("WDM ETH service");
475 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
476 edgeRoadm1, edgeRoadm2));
477 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
478 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
479 LOG.info("Associated client ports = {}", xpdrClientTplist);
480 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
483 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
484 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
485 // - XC Connection OTSi betwwen iODU and eODU of xpdr
486 // - Top connection in the ODU layer, between xpdr eODU ports (?)
487 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
488 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
491 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
492 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
493 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
498 LOG.error("Service type format not supported");
500 return connectionServMap;
503 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
504 List<String> xpdrNodelist,
505 Map<ConnectionKey, Connection> lowerConn) {
506 // TODO: do we need to create cross connection between iODU and eODU??
507 // add the lower connections of the previous steps for this kind of service
508 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
509 for (Connection lowConn: lowerConn.values()) {
510 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
511 xcMap.put(conn.key(), conn);
513 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
514 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
515 ConnectionEndPoint> cepMapDsr = new HashMap<>();
516 // Create 1 cep per Xpdr in the CLIENT
517 // 1 top connection DSR between the CLIENT xpdrs
518 for (String xpdr:xpdrNodelist) {
519 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
520 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
522 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
523 LayerProtocolName.DSR);
524 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
526 cepMapDsr.put(netCep1.key(), netCep1);
528 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
529 .get(0))).findFirst().get();
530 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
531 .get(xpdrNodelist.size() - 1))).findFirst().get();
533 // DSR top connection between edge xpdr CLIENT DSR
534 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
535 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
536 LayerProtocolName.DSR, xcMap);
537 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
539 // DSR top connection that will be added to the service object
540 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
541 connServMap.put(conn1.key(), conn1);
546 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
547 List<String> xpdrNetworkTplist,
548 List<String> xpdrNodelist) {
549 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
550 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
551 ConnectionEndPoint> cepMapDsr = new HashMap<>();
552 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
553 ConnectionEndPoint> cepMapOdu = new HashMap<>();
554 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
555 // be added to the lower connection of a top connection
556 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
558 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
559 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
560 for (String xpdr:xpdrNodelist) {
561 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
562 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
564 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
565 LayerProtocolName.DSR);
566 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
568 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
569 TapiStringConstants.DSR, LayerProtocolName.ODU);
570 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.DSR,
573 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
574 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
576 cepMapDsr.put(netCep1.key(), netCep1);
577 cepMapOdu.put(netCep2.key(), netCep2);
578 // Create x connection between I_ODU and E_ODU within xpdr
579 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
580 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
581 TapiStringConstants.ODU, LayerProtocolName.ODU);
582 this.connectionFullMap.put(connection.key(), connection);
584 // Create X connection that will be added to the service object
585 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
586 xcMap.put(conn.key(), conn);
589 // DSR top connection between edge xpdr CLIENT DSR
590 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
591 .get(0))).findFirst().get();
592 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
593 .get(xpdrNodelist.size() - 1))).findFirst().get();
595 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
596 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
597 LayerProtocolName.ODU, xcMap);
598 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
600 // ODU top connection that will be added to the service object
601 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
602 connServMap.put(conn.key(), conn);
603 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
604 xcMap.put(lowerConn.key(), lowerConn);
606 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
607 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
608 LayerProtocolName.DSR, xcMap);
609 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
611 // DSR top connection that will be added to the service object
612 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
613 connServMap.put(conn1.key(), conn1);
618 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
619 List<String> xpdrNodelist) {
620 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
621 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
622 ConnectionEndPoint> cepMap = new HashMap<>();
623 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
624 // be added to the lower connection of a top connection
625 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
627 // Create 1 cep per Xpdr in the I_ODU and a top
628 // connection iODU between the xpdrs
629 for (String xpdr:xpdrNodelist) {
630 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
631 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
633 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
634 TapiStringConstants.DSR, LayerProtocolName.ODU);
635 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
638 cepMap.put(netCep1.key(), netCep1);
641 // ODU top connection between edge xpdr i_ODU
642 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
643 .get(0))).findFirst().get();
644 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
645 .get(xpdrNodelist.size() - 1))).findFirst().get();
646 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
647 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
648 LayerProtocolName.ODU, xcMap);
649 this.connectionFullMap.put(connection.key(), connection);
651 // ODU top connection that will be added to the service object
652 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
653 connServMap.put(conn.key(), conn);
658 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
659 List<String> xpdrNodelist) {
660 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
661 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
662 ConnectionEndPoint> cepMap = new HashMap<>();
663 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
664 // be added to the lower connection of a top connection
665 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
667 // create ceps and x connections within xpdr
668 for (String xpdr:xpdrNodelist) {
669 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
670 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
671 // There should be 1 network tp per xpdr
672 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
673 // 3 different MC CEPs giving different IDs to show that they are different
674 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
675 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA,
676 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
677 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.OTSI,
679 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_OTSI,
680 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
681 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_OTSI, TapiStringConstants.OTSI,
683 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
684 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
685 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
687 cepMap.put(netCep1.key(), netCep1);
688 cepMap.put(netCep2.key(), netCep2);
689 cepMap.put(netCep3.key(), netCep3);
691 // Create x connection between I_OTSi and E_OTSi within xpdr
692 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
693 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork,
694 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
695 this.connectionFullMap.put(connection.key(), connection);
697 // Create X connection that will be added to the service object
698 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
699 xcMap.put(conn.key(), conn);
701 // OTSi top connection between edge I_OTSI Xpdr
702 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
703 .get(0))).findFirst().get();
704 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
705 .get(xpdrNodelist.size() - 1))).findFirst().get();
706 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
707 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
708 LayerProtocolName.PHOTONICMEDIA, xcMap);
709 this.connectionFullMap.put(connection.key(), connection);
711 // OTSi top connection that will be added to the service object
712 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
713 connServMap.put(conn.key(), conn);
719 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
720 List<String> rdmDegTplist,
721 List<String> rdmNodelist,
722 String edgeRoadm1, String edgeRoadm2) {
723 // TODO: when the number of roadms between 2 SPDR/XPDR is more thatn 1, we need to refine this code
724 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
725 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
726 ConnectionEndPoint> cepMap = new HashMap<>();
727 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
728 // create ceps and x connections within roadm
729 for (String roadm : rdmNodelist) {
730 LOG.info("Creating ceps and xc for roadm {}", roadm);
731 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
732 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
733 // There should be only 1 AD and 1 DEG per roadm
734 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
735 // 3 different MC CEPs giving different IDs to show that they are different
736 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
737 // created in the topology creation
738 // add CEPs to the topology to the corresponding ONEP
739 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA);
740 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA, adCep1);
741 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
742 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
743 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
744 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
745 cepMap.put(adCep1.key(), adCep1);
746 cepMap.put(adCep2.key(), adCep2);
747 cepMap.put(adCep3.key(), adCep3);
749 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
750 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
752 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
753 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA, degCep1);
754 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
755 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
756 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
757 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
758 cepMap.put(degCep1.key(), degCep1);
759 cepMap.put(degCep2.key(), degCep2);
760 cepMap.put(degCep3.key(), degCep3);
762 LOG.info("Going to create cross connections for ROADM {}", roadm);
763 // Create X connections between MC and OTSi_MC for full map
764 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
765 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
766 LayerProtocolName.PHOTONICMEDIA);
767 LOG.info("Cross connection 1 created = {}", connection1);
768 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
769 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
770 LayerProtocolName.PHOTONICMEDIA);
771 LOG.info("Cross connection 2 created = {}", connection2);
772 this.connectionFullMap.put(connection1.key(), connection1);
773 this.connectionFullMap.put(connection2.key(), connection2);
775 // Create X connections that will be added to the service object
776 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
777 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
779 xcMap.put(conn1.key(), conn1);
780 xcMap.put(conn2.key(), conn2);
782 LOG.info("Going to create top connections betwee roadms");
783 // create top connections between roadms: MC connections between AD MC CEPs of roadms
784 for (int i = 0; i < rdmNodelist.size(); i++) {
785 if (rdmNodelist.size() <= (i + 1)) {
786 LOG.info("Reached last roadm. No more MC connections");
789 // Current roadm with roadm i + 1 --> MC
790 String roadm1 = rdmNodelist.get(i);
791 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
792 String roadm2 = rdmNodelist.get(i + 1);
793 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
794 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
796 // Create top connections between MC for full map
797 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
798 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
799 LayerProtocolName.PHOTONICMEDIA, xcMap);
800 this.connectionFullMap.put(connection.key(), connection);
801 LOG.info("Top connection created = {}", connection);
803 // Create top connections that will be added to the service object
804 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
805 connServMap.put(conn.key(), conn);
806 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
807 xcMap.put(conn1.key(), conn1);
810 // OTSiMC top connection between edge roadms
811 LOG.info("Going to created top connection between OTSiMC");
812 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
813 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
814 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
815 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
816 LayerProtocolName.PHOTONICMEDIA, xcMap);
817 this.connectionFullMap.put(connection.key(), connection);
818 LOG.info("Top connection created = {}", connection);
820 // OTSiMC top connections that will be added to the service object
821 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
822 connServMap.put(conn.key(), conn);
826 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
827 createTopConnection(String tp1, String tp2,
828 Map<org.opendaylight.yang.gen.v1.urn
829 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
830 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
831 Map<LowerConnectionKey, LowerConnection> xcMap) {
832 // find cep for each AD MC of roadm 1 and 2
833 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
834 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
835 cepMap.get(new org.opendaylight.yang.gen.v1.urn
836 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
837 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
838 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
840 LOG.info("ADCEP1 = {}", adCep1);
841 org.opendaylight.yang.gen.v1.urn
842 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
843 new org.opendaylight.yang.gen.v1.urn
844 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
845 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
846 .values().stream().findFirst().get().getNodeEdgePointUuid())
847 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
848 .values().stream().findFirst().get().getTopologyUuid())
849 .setNodeUuid(adCep1.getClientNodeEdgePoint()
850 .values().stream().findFirst().get().getNodeUuid())
851 .setConnectionEndPointUuid(adCep1.getUuid())
853 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
854 cepMap.get(new org.opendaylight.yang.gen.v1.urn
855 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
856 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
857 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
859 LOG.info("ADCEP2 = {}", adCep2);
860 org.opendaylight.yang.gen.v1.urn
861 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
862 new org.opendaylight.yang.gen.v1.urn
863 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
864 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
865 .values().stream().findFirst().get().getNodeEdgePointUuid())
866 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
867 .values().stream().findFirst().get().getTopologyUuid())
868 .setNodeUuid(adCep2.getClientNodeEdgePoint()
869 .values().stream().findFirst().get().getNodeUuid())
870 .setConnectionEndPointUuid(adCep1.getUuid())
872 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
873 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
874 ceps.put(cep1.key(), cep1);
875 ceps.put(cep2.key(), cep2);
876 Name connName = new NameBuilder()
877 .setValueName("Connection name")
878 .setValue(String.join("+", "TOP", tp1, tp2, qual))
880 // TODO: lower connection, supported link.......
881 return new org.opendaylight.yang.gen.v1.urn
882 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
883 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
884 .getBytes(Charset.forName("UTF-8"))).toString()))
885 .setName(Map.of(connName.key(), connName))
886 .setConnectionEndPoint(ceps)
887 .setOperationalState(OperationalState.ENABLED)
888 .setLayerProtocolName(topPortocol)
889 .setLifecycleState(LifecycleState.INSTALLED)
890 .setDirection(ForwardingDirection.BIDIRECTIONAL)
891 .setLowerConnection(xcMap)
895 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
896 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
897 LayerProtocolName xcProtocol) {
898 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
899 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
900 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
901 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
902 org.opendaylight.yang.gen.v1.urn
903 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
904 new org.opendaylight.yang.gen.v1.urn
905 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
906 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
907 .values().stream().findFirst().get().getNodeEdgePointUuid())
908 .setTopologyUuid(cep1.getClientNodeEdgePoint()
909 .values().stream().findFirst().get().getTopologyUuid())
910 .setNodeUuid(cep1.getClientNodeEdgePoint()
911 .values().stream().findFirst().get().getNodeUuid())
912 .setConnectionEndPointUuid(cep1.getUuid())
914 org.opendaylight.yang.gen.v1.urn
915 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
916 new org.opendaylight.yang.gen.v1.urn
917 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
918 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
919 .values().stream().findFirst().get().getNodeEdgePointUuid())
920 .setTopologyUuid(cep2.getClientNodeEdgePoint()
921 .values().stream().findFirst().get().getTopologyUuid())
922 .setNodeUuid(cep2.getClientNodeEdgePoint()
923 .values().stream().findFirst().get().getNodeUuid())
924 .setConnectionEndPointUuid(cep2.getUuid())
926 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
927 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
928 ceps.put(cepServ1.key(), cepServ1);
929 ceps.put(cepServ2.key(), cepServ2);
930 Name connName = new NameBuilder()
931 .setValueName("Connection name")
932 .setValue(String.join("+", "XC", tp1, tp2, qual))
934 // TODO: lower connection, supported link.......
935 return new org.opendaylight.yang.gen.v1.urn
936 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
937 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
938 .getBytes(Charset.forName("UTF-8"))).toString()))
939 .setName(Map.of(connName.key(), connName))
940 .setConnectionEndPoint(ceps)
941 .setOperationalState(OperationalState.ENABLED)
942 .setLayerProtocolName(xcProtocol)
943 .setLifecycleState(LifecycleState.INSTALLED)
944 .setDirection(ForwardingDirection.BIDIRECTIONAL)
948 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
949 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
950 Name cepName = new NameBuilder()
951 .setValueName("ConnectionEndPoint name")
952 .setValue(String.join("+", id.split("\\+")[0], qualifier,
955 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
956 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
957 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
959 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
960 qualifier)).getBytes(Charset.forName("UTF-8")))
962 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
963 .getBytes(Charset.forName("UTF-8"))).toString()))
965 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
966 // TODO: add parent ONEP??
967 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
968 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
969 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
971 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
972 .setName(Map.of(cepName.key(), cepName))
973 .setConnectionPortRole(PortRole.SYMMETRIC)
974 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
975 .setOperationalState(OperationalState.ENABLED)
976 .setLifecycleState(LifecycleState.INSTALLED)
977 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
978 return cepBldr.build();
981 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
982 LayerProtocolName cepProtocol) {
983 Name cepName = new NameBuilder()
984 .setValueName("ConnectionEndPoint name")
985 .setValue(String.join("+", id.split("\\+")[0], qualifier,
988 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
989 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
990 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
992 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
993 nodeLayer)).getBytes(Charset.forName("UTF-8")))
995 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
996 .getBytes(Charset.forName("UTF-8"))).toString()))
998 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
999 // TODO: add parent ONEP??
1000 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1001 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1002 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
1004 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
1005 .setName(Map.of(cepName.key(), cepName))
1006 .setConnectionPortRole(PortRole.SYMMETRIC)
1007 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
1008 .setOperationalState(OperationalState.ENABLED)
1009 .setLifecycleState(LifecycleState.INSTALLED)
1010 .setLayerProtocolName(cepProtocol);
1011 return cepBldr.build();
1014 private EndPoint mapServiceZEndPoint(
1015 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
1016 serviceZEnd, PathDescription pathDescription) {
1017 EndPointBuilder endPointBuilder = new EndPointBuilder();
1018 // 1. Service Format: ODU, OTU, ETH
1019 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1020 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1021 // Identify SIP name
1022 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1023 LOG.info("Uuid of z end {}", sipUuid);
1024 LayerProtocolName layerProtocols = null;
1025 // Layer protocol name
1026 switch (serviceFormat) {
1028 layerProtocols = LayerProtocolName.DSR;
1032 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1035 layerProtocols = LayerProtocolName.ODU;
1038 LOG.error("Service Format not supported");
1040 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1041 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1042 .setValueName("OpenROADM node id")
1043 .setValue(serviceZEnd.getTxDirection().getPort().getPortDeviceName())
1045 return endPointBuilder
1046 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1047 .setServiceInterfacePointUuid(sipUuid)
1049 .setName(Map.of(name.key(), name))
1050 .setAdministrativeState(AdministrativeState.UNLOCKED)
1051 .setDirection(PortDirection.BIDIRECTIONAL)
1052 .setLifecycleState(LifecycleState.INSTALLED)
1053 .setOperationalState(OperationalState.ENABLED)
1054 .setLayerProtocolName(layerProtocols)
1055 .setCapacity(new CapacityBuilder()
1056 .setTotalSize(new TotalSizeBuilder()
1057 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
1058 .setUnit(CapacityUnit.GBPS)
1060 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1062 .setProtectionRole(ProtectionRole.WORK)
1063 .setRole(PortRole.SYMMETRIC)
1064 .setLocalId(serviceZEnd.getTxDirection().getPort().getPortDeviceName())
1068 private EndPoint mapServiceAEndPoint(
1069 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
1070 serviceAEnd, PathDescription pathDescription) {
1071 EndPointBuilder endPointBuilder = new EndPointBuilder();
1072 // 1. Service Format: ODU, OTU, ETH
1073 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1074 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1075 // Identify SIP name
1076 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1077 LOG.info("Uuid of a end {}", sipUuid);
1078 LayerProtocolName layerProtocols = null;
1079 // Layer protocol name
1080 switch (serviceFormat) {
1082 layerProtocols = LayerProtocolName.DSR;
1086 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1089 layerProtocols = LayerProtocolName.ODU;
1092 LOG.error("Service Format not supported");
1094 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1095 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1096 .setValueName("OpenROADM node id")
1097 .setValue(serviceAEnd.getTxDirection().getPort().getPortDeviceName())
1099 return endPointBuilder
1100 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1101 .setServiceInterfacePointUuid(sipUuid)
1103 .setName(Map.of(name.key(), name))
1104 .setAdministrativeState(AdministrativeState.UNLOCKED)
1105 .setDirection(PortDirection.BIDIRECTIONAL)
1106 .setLifecycleState(LifecycleState.INSTALLED)
1107 .setOperationalState(OperationalState.ENABLED)
1108 .setLayerProtocolName(layerProtocols)
1109 .setCapacity(new CapacityBuilder()
1110 .setTotalSize(new TotalSizeBuilder()
1111 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
1112 .setUnit(CapacityUnit.GBPS)
1114 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1116 .setProtectionRole(ProtectionRole.WORK)
1117 .setRole(PortRole.SYMMETRIC)
1118 .setLocalId(serviceAEnd.getTxDirection().getPort().getPortDeviceName())
1122 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1123 Uuid zendUuid = null;
1124 if (serviceNodeId.contains("ROADM")) {
1125 // Service from ROADM to ROADM
1126 // AddDrop-AddDrop ports --> MC layer SIPs
1127 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1128 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1129 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1130 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1132 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1133 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1134 if (!sip.getUuid().equals(sipUuid)) {
1135 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1138 zendUuid = sip.getUuid();
1142 // Service from XPDR to XPDR
1144 TerminationPoint tp;
1146 switch (serviceFormat) {
1148 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1149 tp = (TerminationPoint) firstElement.getResource().getResource();
1150 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1151 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1152 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1154 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1158 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1159 tp = (TerminationPoint) firstElement.getResource().getResource();
1160 // Network-Network ports --> iOTSi layer SIPs
1161 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1162 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1164 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1168 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1169 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1170 tp = (TerminationPoint) firstElement.getResource().getResource();
1171 // Client-client ports --> DSR layer SIPs
1172 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1173 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1175 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1180 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1182 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1183 if (!sip.getUuid().equals(sipUuid)) {
1184 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1187 zendUuid = sip.getUuid();
1194 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1195 Uuid aendUuid = null;
1196 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1197 LOG.info("Map a to z = {}", mapatoz);
1198 if (serviceNodeId.contains("ROADM")) {
1199 // Service from ROADM to ROADM
1200 // AddDrop-AddDrop ports --> MC layer SIPs
1201 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1202 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1203 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1204 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1205 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1207 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1209 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1210 if (!sip.getUuid().equals(sipUuid)) {
1211 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1214 aendUuid = sip.getUuid();
1218 // Service from XPDR to XPDR
1220 TerminationPoint tp;
1222 switch (serviceFormat) {
1224 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1225 tp = (TerminationPoint) firstElement.getResource().getResource();
1226 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1227 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1228 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1230 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1231 TapiStringConstants.I_ODU, tp.getTpId()));
1234 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1235 tp = (TerminationPoint) firstElement.getResource().getResource();
1236 // Network-Network ports --> iOTSi layer SIPs
1237 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1238 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1240 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1241 TapiStringConstants.I_OTSI, tp.getTpId()));
1244 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1245 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1246 tp = (TerminationPoint) firstElement.getResource().getResource();
1247 // Client-client ports --> DSR layer SIPs
1248 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1249 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1251 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1252 TapiStringConstants.DSR, tp.getTpId()));
1256 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1258 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1259 if (!sip.getUuid().equals(sipUuid)) {
1260 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1263 aendUuid = sip.getUuid();
1270 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1271 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1272 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1273 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1274 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1275 .getBytes(Charset.forName("UTF-8"))).toString());
1276 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1277 .getBytes(Charset.forName("UTF-8"))).toString());
1278 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1279 .getBytes(Charset.forName("UTF-8"))).toString());
1280 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1283 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1284 ConnectionEndPoint cep) {
1285 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1286 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1287 .getBytes(Charset.forName("UTF-8"))).toString());
1288 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1289 .getBytes(Charset.forName("UTF-8"))).toString());
1290 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1291 .getBytes(Charset.forName("UTF-8"))).toString());
1292 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1295 public Map<org.opendaylight.yang.gen.v1.urn
1296 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1297 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1298 getConnectionFullMap() {
1299 return this.connectionFullMap;
1302 private String getIdBasedOnModelVersion(String nodeid) {
1303 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1304 nodeid.split("-")[1]) : nodeid.split("-")[0];
1307 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1308 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1309 Map<org.opendaylight.yang.gen.v1.urn
1310 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1311 org.opendaylight.yang.gen.v1.urn
1312 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1313 endPointMap = input.getEndPoint();
1314 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1315 ConnectionType connType = null;
1316 ServiceFormat serviceFormat = null;
1317 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1318 TapiStringConstants.DSR);
1319 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1320 TapiStringConstants.DSR);
1321 LOG.debug("Node a = {}", nodeAid);
1322 LOG.debug("Node z = {}", nodeZid);
1323 switch (constraint.getServiceLayer().getIntValue()) {
1326 connType = ConnectionType.Infrastructure;
1327 serviceFormat = ServiceFormat.ODU;
1330 LOG.info("ETH, no need to create OTU and ODU");
1331 connType = ConnectionType.Service;
1332 serviceFormat = ServiceFormat.Ethernet;
1335 LOG.info("DSR, need to create OTU and ODU");
1336 connType = ConnectionType.Service;
1337 serviceFormat = ServiceFormat.Ethernet;
1340 LOG.info("PHOTONIC");
1341 connType = getConnectionTypePhtnc(endPointMap.values());
1342 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1343 if (serviceFormat.equals(ServiceFormat.OC)) {
1344 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1345 TapiStringConstants.PHTNC_MEDIA);
1346 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1347 TapiStringConstants.PHTNC_MEDIA);
1349 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1350 TapiStringConstants.OTSI);
1351 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1352 TapiStringConstants.OTSI);
1354 LOG.debug("Node a photonic = {}", nodeAid);
1355 LOG.debug("Node z photonic = {}", nodeZid);
1358 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1360 // Requested Capacity for connectivity service
1361 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1362 // map endpoints into service end points. Map the type of service from TAPI to OR
1363 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1364 serviceFormat, nodeAid, capacity, constraint.getServiceLayer());
1365 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1366 serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
1367 if (serviceAEnd == null || serviceZEnd == null) {
1368 LOG.error("Couldnt map endpoints to service end");
1371 LOG.info("Service a end = {}", serviceAEnd);
1372 LOG.info("Service z end = {}", serviceZEnd);
1373 return new ServiceCreateInputBuilder()
1374 .setServiceAEnd(serviceAEnd)
1375 .setServiceZEnd(serviceZEnd)
1376 .setConnectionType(connType)
1377 .setServiceName(serviceUuid.getValue())
1378 .setCommonId("common id")
1379 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1380 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1381 .setRequestSystemId("appname")
1383 .setCustomer("customer")
1384 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1385 .setOperatorContact("pw1234")
1389 private ServiceZEnd tapiEndPointToServiceZPoint(
1390 org.opendaylight.yang.gen.v1.urn
1391 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1392 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1393 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1394 // Not the rest which is needed in the txPortDeviceName.
1395 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1396 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1397 // Todo -> need to find the NEP associated to that SIP
1398 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString());
1399 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1400 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1402 LOG.error("Node not found in datastore");
1405 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1406 // connection is between 2 CLIENT ports. Otherwise it will not work...
1407 OwnedNodeEdgePoint nep = null;
1408 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1409 if (onep.getMappedServiceInterfacePoint() == null) {
1412 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1418 LOG.error("Nep not found in datastore");
1421 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1422 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1423 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1424 String txPortDeviceName = nepName.split("\\+")[0];
1425 String txPortName = nepName.split("\\+")[2];
1426 String rxPortDeviceName = txPortDeviceName;
1427 String rxPortName = txPortName;
1428 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1429 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1430 // TODO --> get clli from datastore?
1431 String clli = "NodeSC";
1432 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1433 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1434 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1436 .setNodeId(new NodeIdType(nodeid))
1437 .setOpticType(OpticTypes.Gray)
1438 .setServiceFormat(serviceFormat)
1439 .setServiceRate(Uint32.valueOf(capacity))
1440 .setTxDirection(new TxDirectionBuilder()
1441 .setPort(new PortBuilder()
1442 .setPortDeviceName(txPortDeviceName)
1443 .setPortName(txPortName)
1444 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1446 .setPortType(TapiStringConstants.PORT_TYPE)
1448 .setLgx(new LgxBuilder()
1449 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1450 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1451 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1452 .setLgxPortShelf("00")
1455 .setRxDirection(new RxDirectionBuilder()
1456 .setPort(new PortBuilder()
1457 .setPortDeviceName(rxPortDeviceName)
1458 .setPortName(rxPortName)
1459 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1461 .setPortType(TapiStringConstants.PORT_TYPE)
1463 .setLgx(new LgxBuilder()
1464 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1465 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1466 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1467 .setLgxPortShelf("00")
1470 if (serviceFormat.equals(ServiceFormat.ODU)) {
1471 serviceZEndBuilder.setOduServiceRate(ODU4.class);
1473 if (serviceFormat.equals(ServiceFormat.OTU)) {
1474 serviceZEndBuilder.setOtuServiceRate(OTU4.class);
1476 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1478 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(new org.opendaylight.yang.gen.v1.http
1479 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1480 .setCommittedBurstSize(Uint16.valueOf(64))
1481 .setCommittedInfoRate(Uint32.valueOf(100000))
1485 return serviceZEndBuilder.build();
1488 private ServiceAEnd tapiEndPointToServiceAPoint(
1489 org.opendaylight.yang.gen.v1.urn
1490 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1491 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1492 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1493 // Not the rest which is needed in the txPortDeviceName.
1494 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1495 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1496 // Todo -> need to find the NEP associated to that SIP
1497 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString());
1498 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1499 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1501 LOG.error("Node not found in datastore");
1504 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1505 // connection is between 2 CLIENT ports. Otherwise it will not work...
1506 OwnedNodeEdgePoint nep = null;
1507 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1508 if (onep.getMappedServiceInterfacePoint() == null) {
1511 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1517 LOG.error("Nep not found in datastore");
1520 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1521 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1522 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1523 String txPortDeviceName = nepName.split("\\+")[0];
1524 String txPortName = nepName.split("\\+")[2];
1525 String rxPortDeviceName = txPortDeviceName;
1526 String rxPortName = txPortName;
1527 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1528 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1529 // TODO --> get clli from datastore?
1530 String clli = "NodeSA";
1531 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1532 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1533 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1535 .setNodeId(new NodeIdType(nodeid))
1536 .setOpticType(OpticTypes.Gray)
1537 .setServiceFormat(serviceFormat)
1538 .setServiceRate(Uint32.valueOf(capacity))
1539 .setTxDirection(new TxDirectionBuilder()
1540 .setPort(new PortBuilder()
1541 .setPortDeviceName(txPortDeviceName)
1542 .setPortName(txPortName)
1543 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1545 .setPortType(TapiStringConstants.PORT_TYPE)
1547 .setLgx(new LgxBuilder()
1548 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1549 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1550 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1551 .setLgxPortShelf("00")
1554 .setRxDirection(new RxDirectionBuilder()
1555 .setPort(new PortBuilder()
1556 .setPortDeviceName(rxPortDeviceName)
1557 .setPortName(rxPortName)
1558 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1560 .setPortType(TapiStringConstants.PORT_TYPE)
1562 .setLgx(new LgxBuilder()
1563 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1564 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1565 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1566 .setLgxPortShelf("00")
1569 if (serviceFormat.equals(ServiceFormat.ODU)) {
1570 serviceAEndBuilder.setOduServiceRate(ODU4.class);
1572 if (serviceFormat.equals(ServiceFormat.OTU)) {
1573 serviceAEndBuilder.setOtuServiceRate(OTU4.class);
1575 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1577 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(new org.opendaylight.yang.gen.v1.http
1578 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1579 .setCommittedBurstSize(Uint16.valueOf(64))
1580 .setCommittedInfoRate(Uint32.valueOf(100000))
1584 return serviceAEndBuilder.build();
1587 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1588 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1589 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1590 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1591 // EndPoints are ROADMs
1592 return ConnectionType.RoadmLine;
1594 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1595 return ConnectionType.Infrastructure;
1598 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1599 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1600 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1601 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1602 // EndPoints are ROADMs
1603 return ServiceFormat.OC;
1605 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1606 return ServiceFormat.OTU;
1609 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1610 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1611 TapiStringConstants.DSR).getBytes(Charset.forName("UTF-8")))).toString());
1612 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1613 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(Charset.forName("UTF-8"))))
1615 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1616 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1617 .getBytes(Charset.forName("UTF-8"))).toString());
1618 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1621 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1622 for (String networkPort:xpdrNetworkTplist) {
1623 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1630 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1631 List<String> clientPortList = new ArrayList<>();
1632 for (String networkPort:xpdrNetworkTplist) {
1633 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1634 networkPort.split("\\+")[0].split("-")[1]);
1635 String tpId = networkPort.split("\\+")[1];
1636 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1637 .child(Nodes.class, new NodesKey(nodeId))
1638 .child(Mapping.class, new MappingKey(tpId)).build();
1640 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1642 if (!optMapping.isPresent()) {
1643 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1645 Mapping mapping = optMapping.get();
1646 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1647 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1648 mapping.getConnectionMapLcp());
1649 LOG.info("Key to be added to list = {}", key);
1650 if (!clientPortList.contains(key)) {
1651 clientPortList.add(key);
1653 } catch (InterruptedException | ExecutionException e) {
1654 LOG.error("Couldnt read mapping from datastore", e);
1659 return clientPortList;
1662 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1663 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1664 for (String xpdrNode:xpdrNodelist) {
1665 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.DSR))
1666 .getBytes(Charset.forName("UTF-8"))).toString());
1667 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1668 .onf.otcc.yang.tapi.topology.rev181210.topology.Node> nodeIID = InstanceIdentifier.builder(
1669 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1670 .onf.otcc.yang.tapi.topology.rev181210.Context1.class).child(TopologyContext.class)
1671 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1672 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
1673 new NodeKey(nodeUuid)).build();
1675 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> optNode
1676 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1677 if (!optNode.isPresent()) {
1680 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
1681 new NameKey("Node Type")).getValue()).get();
1682 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1683 openroadmNodeTypeList.add(openroadmNodeType);
1685 } catch (InterruptedException | ExecutionException e) {
1686 LOG.error("Couldnt read node in topology", e);
1690 // TODO for now check that there is only one type, otherwise error
1691 if (openroadmNodeTypeList.size() != 1) {
1692 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1695 return openroadmNodeTypeList.get(0);