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.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.rev200529.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(Charset.forName("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;
134 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
135 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
136 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
137 NetworkTransactionService networkTransactionService) {
138 this.serviceDataStoreOperations = serviceDataStoreOperations;
139 this.tapiContext = tapiContext;
140 this.sipMap = sipMap;
141 this.connectionFullMap = new HashMap<>();
142 this.networkTransactionService = networkTransactionService;
145 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
146 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
147 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
148 if (serviceAEnd == null || serviceZEnd == null) {
149 LOG.warn("One of the endpoints could not be identified");
152 return new ServiceCreateInputBuilder()
153 .setCommonId("commonId")
154 .setConnectionType(ConnectionType.Service)
155 .setCustomer("Customer")
156 .setServiceName("service test")
157 .setServiceAEnd(serviceAEnd)
158 .setServiceZEnd(serviceZEnd)
159 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
160 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
166 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
167 String txPortName, String rxPortDeviceName, String rxPortName) {
168 return new ServiceAEndBuilder()
170 .setNodeId(new NodeIdType(nodeid))
171 .setOpticType(OpticTypes.Gray)
172 .setServiceFormat(ServiceFormat.Ethernet)
173 .setServiceRate(Uint32.valueOf(100))
174 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
175 .setPort(new PortBuilder()
176 .setPortDeviceName(txPortDeviceName)
177 .setPortName(txPortName)
178 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
180 .setPortType(TapiStringConstants.PORT_TYPE)
182 .setLgx(new LgxBuilder()
183 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
184 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
185 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
186 .setLgxPortShelf("00")
189 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
190 .setPort(new PortBuilder()
191 .setPortDeviceName(rxPortDeviceName)
192 .setPortName(rxPortName)
193 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
195 .setPortType(TapiStringConstants.PORT_TYPE)
197 .setLgx(new LgxBuilder()
198 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
199 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
200 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
201 .setLgxPortShelf("00")
207 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
208 String txPortName, String rxPortDeviceName, String rxPortName) {
209 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
210 .setOpticType(OpticTypes.Gray)
211 .setServiceFormat(ServiceFormat.Ethernet)
212 .setServiceRate(Uint32.valueOf(100))
213 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
214 .setPort(new PortBuilder()
215 .setPortDeviceName(txPortDeviceName)
216 .setPortName(txPortName)
217 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
219 .setPortType(TapiStringConstants.PORT_TYPE)
221 .setLgx(new LgxBuilder()
222 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
223 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
224 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
225 .setLgxPortShelf("00")
228 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
229 .setPort(new PortBuilder()
230 .setPortDeviceName(rxPortDeviceName)
231 .setPortName(rxPortName)
232 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
234 .setPortType(TapiStringConstants.PORT_TYPE)
236 .setLgx(new LgxBuilder()
237 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
238 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
239 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
240 .setLgxPortShelf("00")
246 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
247 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
248 return new ServiceAEndBuilder(sepA.getValue()).build();
249 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
250 return new ServiceAEndBuilder(sepZ.getValue()).build();
256 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
257 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
258 return new ServiceZEndBuilder(sepA.getValue()).build();
259 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
260 return new ServiceZEndBuilder(sepZ.getValue()).build();
266 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
270 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
271 // Get service path with the description in OR based models.
272 LOG.info("Service = {}", service);
273 Optional<ServicePaths> optServicePaths =
274 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
275 if (!optServicePaths.isPresent()) {
276 LOG.error("No service path found for service {}", service.getServiceName());
279 ServicePaths servicePaths = optServicePaths.get();
280 PathDescription pathDescription = servicePaths.getPathDescription();
281 LOG.info("Path description of service = {}", pathDescription);
282 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd serviceAEnd
283 = service.getServiceAEnd();
285 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
286 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd serviceZEnd
287 = service.getServiceZEnd();
288 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
289 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
290 endPointMap.put(endPoint1.key(), endPoint1);
291 endPointMap.put(endPoint2.key(), endPoint2);
292 LOG.info("EndPoints of connectivity services = {}", endPointMap);
294 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
296 // Connection creation
297 Map<ConnectionKey, Connection> connMap =
298 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
299 // TODO: full connectivity service?? With constraints and the rest of fields...
300 return new ConnectivityServiceBuilder()
301 .setAdministrativeState(AdministrativeState.UNLOCKED)
302 .setOperationalState(OperationalState.ENABLED)
303 .setLifecycleState(LifecycleState.INSTALLED)
304 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
306 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
307 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
308 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
309 .setName(Map.of(name.key(), name))
310 .setConnection(connMap)
311 .setEndPoint(endPointMap)
315 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
316 switch (serviceFormat) {
319 return LayerProtocolName.PHOTONICMEDIA;
321 return LayerProtocolName.ODU;
323 String node1 = endPoint1.getLocalId();
324 String node2 = endPoint2.getLocalId();
325 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
326 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
327 return LayerProtocolName.ETH;
329 return LayerProtocolName.DSR;
331 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
336 private OpenroadmNodeType getOpenroadmType(String nodeName) {
337 LOG.info("Node name = {}", nodeName);
338 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.DSR))
339 .getBytes(Charset.forName("UTF-8"))).toString());
340 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node tapiNode
341 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
342 if (tapiNode != null) {
343 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
349 private Map<ConnectionKey, Connection> createConnectionsFromService(
350 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd
352 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd
354 PathDescription pathDescription) {
355 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
356 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
357 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
358 // and the connections
360 List<String> xpdrClientTplist = new ArrayList<>();
361 List<String> xpdrNetworkTplist = new ArrayList<>();
362 List<String> rdmAddDropTplist = new ArrayList<>();
363 List<String> rdmDegTplist = new ArrayList<>();
364 List<String> rdmNodelist = new ArrayList<>();
365 List<String> xpdrNodelist = new ArrayList<>();
366 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
367 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
368 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
369 switch (resourceType) {
370 case TapiStringConstants.TP:
371 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
372 String tpID = tp.getTpId();
374 if (tpID.contains("CLIENT")) {
375 tpNode = tp.getTpNodeId();
376 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
377 xpdrClientTplist.add(String.join("+", tpNode, tpID));
380 if (tpID.contains("NETWORK")) {
381 tpNode = tp.getTpNodeId();
382 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
383 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
386 if (tpID.contains("PP")) {
387 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
388 LOG.info("ROADM Node of tp = {}", tpNode);
389 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
390 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
393 if (tpID.contains("TTP")) {
394 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
395 LOG.info("ROADM Node of tp = {}", tpNode);
396 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
397 rdmDegTplist.add(String.join("+", tpNode, tpID));
401 case TapiStringConstants.NODE:
402 Node node = (Node) elem.getResource().getResource();
403 String nodeId = node.getNodeId();
404 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
405 LOG.info("Node id = {}", nodeId);
406 if (!xpdrNodelist.contains(nodeId)) {
407 xpdrNodelist.add(nodeId); // should contain only 2
410 if (nodeId.contains("ROADM")) {
411 nodeId = getIdBasedOnModelVersion(nodeId);
412 LOG.info("Node id = {}", nodeId);
413 if (!rdmNodelist.contains(nodeId)) {
414 rdmNodelist.add(nodeId);
419 LOG.warn("Resource is a {}", resourceType);
422 LOG.info("ROADM node list = {}", rdmNodelist);
423 LOG.info("ROADM degree list = {}", rdmDegTplist);
424 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
425 LOG.info("XPDR node list = {}", xpdrNodelist);
426 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
427 LOG.info("XPDR client list = {}", xpdrClientTplist);
428 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
429 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
430 // to trigger all the steps or not
431 String edgeRoadm1 = "";
432 String edgeRoadm2 = "";
433 if (!rdmNodelist.isEmpty()) {
434 edgeRoadm1 = rdmNodelist.get(0);
435 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
436 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
437 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
439 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
440 // CEPs must be included in the topology context as an augmentation for each ONEP!!
441 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
442 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
443 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
444 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
445 // this needs to be changed
446 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
447 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
448 switch (serviceFormat) {
450 // Identify number of ROADMs
451 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
452 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
453 // - Top Connection MC betwwen MC CEPs of different roadms
454 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
455 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
456 edgeRoadm1, edgeRoadm2));
459 // Identify number of ROADMs between XPDRs and check if OC is created
460 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
461 // - Top Connection MC betwwen MC CEPs of different roadms
462 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
463 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
464 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
465 edgeRoadm1, edgeRoadm2));
466 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
467 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
468 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
471 // - XC Connection OTSi betwwen iODU and eODU of xpdr
472 // - Top connection in the ODU layer, between xpdr eODU ports (?)
473 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
476 // Check if OC, OTU and ODU are created
477 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
478 LOG.info("WDM ETH service");
479 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
480 edgeRoadm1, edgeRoadm2));
481 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
482 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
483 LOG.info("Associated client ports = {}", xpdrClientTplist);
484 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
487 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
488 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
489 // - XC Connection OTSi betwwen iODU and eODU of xpdr
490 // - Top connection in the ODU layer, between xpdr eODU ports (?)
491 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
492 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
495 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
496 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
497 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
502 LOG.error("Service type format not supported");
504 return connectionServMap;
507 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
508 List<String> xpdrNodelist,
509 Map<ConnectionKey, Connection> lowerConn) {
510 // TODO: do we need to create cross connection between iODU and eODU??
511 // add the lower connections of the previous steps for this kind of service
512 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
513 for (Connection lowConn: lowerConn.values()) {
514 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
515 xcMap.put(conn.key(), conn);
517 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
518 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
519 ConnectionEndPoint> cepMapDsr = new HashMap<>();
520 // Create 1 cep per Xpdr in the CLIENT
521 // 1 top connection DSR between the CLIENT xpdrs
522 for (String xpdr:xpdrNodelist) {
523 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
524 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
526 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
527 LayerProtocolName.DSR);
528 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
530 cepMapDsr.put(netCep1.key(), netCep1);
532 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
533 .get(0))).findFirst().get();
534 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
535 .get(xpdrNodelist.size() - 1))).findFirst().get();
537 // DSR top connection between edge xpdr CLIENT DSR
538 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
539 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
540 LayerProtocolName.DSR, xcMap);
541 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
543 // DSR top connection that will be added to the service object
544 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
545 connServMap.put(conn1.key(), conn1);
550 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
551 List<String> xpdrNetworkTplist,
552 List<String> xpdrNodelist) {
553 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
554 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
555 ConnectionEndPoint> cepMapDsr = new HashMap<>();
556 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
557 ConnectionEndPoint> cepMapOdu = new HashMap<>();
558 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
559 // be added to the lower connection of a top connection
560 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
562 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
563 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
564 for (String xpdr:xpdrNodelist) {
565 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
566 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
568 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
569 LayerProtocolName.DSR);
570 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
572 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
573 TapiStringConstants.DSR, LayerProtocolName.ODU);
574 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.DSR,
577 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
578 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
580 cepMapDsr.put(netCep1.key(), netCep1);
581 cepMapOdu.put(netCep2.key(), netCep2);
582 // Create x connection between I_ODU and E_ODU within xpdr
583 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
584 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
585 TapiStringConstants.ODU, LayerProtocolName.ODU);
586 this.connectionFullMap.put(connection.key(), connection);
588 // Create X connection that will be added to the service object
589 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
590 xcMap.put(conn.key(), conn);
593 // DSR top connection between edge xpdr CLIENT DSR
594 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
595 .get(0))).findFirst().get();
596 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
597 .get(xpdrNodelist.size() - 1))).findFirst().get();
599 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
600 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
601 LayerProtocolName.ODU, xcMap);
602 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
604 // ODU top connection that will be added to the service object
605 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
606 connServMap.put(conn.key(), conn);
607 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
608 xcMap.put(lowerConn.key(), lowerConn);
610 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
611 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
612 LayerProtocolName.DSR, xcMap);
613 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
615 // DSR top connection that will be added to the service object
616 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
617 connServMap.put(conn1.key(), conn1);
622 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
623 List<String> xpdrNodelist) {
624 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
625 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
626 ConnectionEndPoint> cepMap = new HashMap<>();
627 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
628 // be added to the lower connection of a top connection
629 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
631 // Create 1 cep per Xpdr in the I_ODU and a top
632 // connection iODU between the xpdrs
633 for (String xpdr:xpdrNodelist) {
634 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
635 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
637 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
638 TapiStringConstants.DSR, LayerProtocolName.ODU);
639 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
642 cepMap.put(netCep1.key(), netCep1);
645 // ODU top connection between edge xpdr i_ODU
646 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
647 .get(0))).findFirst().get();
648 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
649 .get(xpdrNodelist.size() - 1))).findFirst().get();
650 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
651 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
652 LayerProtocolName.ODU, xcMap);
653 this.connectionFullMap.put(connection.key(), connection);
655 // ODU top connection that will be added to the service object
656 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
657 connServMap.put(conn.key(), conn);
662 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
663 List<String> xpdrNodelist) {
664 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
665 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
666 ConnectionEndPoint> cepMap = new HashMap<>();
667 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
668 // be added to the lower connection of a top connection
669 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
671 // create ceps and x connections within xpdr
672 for (String xpdr:xpdrNodelist) {
673 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
674 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
675 // There should be 1 network tp per xpdr
676 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
677 // 3 different MC CEPs giving different IDs to show that they are different
678 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
679 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA,
680 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
681 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.OTSI,
683 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_OTSI,
684 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
685 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_OTSI, TapiStringConstants.OTSI,
687 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
688 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
689 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
691 cepMap.put(netCep1.key(), netCep1);
692 cepMap.put(netCep2.key(), netCep2);
693 cepMap.put(netCep3.key(), netCep3);
695 // Create x connection between I_OTSi and E_OTSi within xpdr
696 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
697 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork,
698 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
699 this.connectionFullMap.put(connection.key(), connection);
701 // Create X connection that will be added to the service object
702 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
703 xcMap.put(conn.key(), conn);
705 // OTSi top connection between edge I_OTSI Xpdr
706 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
707 .get(0))).findFirst().get();
708 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
709 .get(xpdrNodelist.size() - 1))).findFirst().get();
710 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
711 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
712 LayerProtocolName.PHOTONICMEDIA, xcMap);
713 this.connectionFullMap.put(connection.key(), connection);
715 // OTSi top connection that will be added to the service object
716 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
717 connServMap.put(conn.key(), conn);
723 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
724 List<String> rdmDegTplist,
725 List<String> rdmNodelist,
726 String edgeRoadm1, String edgeRoadm2) {
727 // TODO: when the number of roadms between 2 SPDR/XPDR is more thatn 1, we need to refine this code
728 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
729 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
730 ConnectionEndPoint> cepMap = new HashMap<>();
731 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
732 // create ceps and x connections within roadm
733 for (String roadm : rdmNodelist) {
734 LOG.info("Creating ceps and xc for roadm {}", roadm);
735 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
736 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
737 // There should be only 1 AD and 1 DEG per roadm
738 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
739 // 3 different MC CEPs giving different IDs to show that they are different
740 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
741 // created in the topology creation
742 // add CEPs to the topology to the corresponding ONEP
743 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA);
744 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA, adCep1);
745 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
746 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
747 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
748 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
749 cepMap.put(adCep1.key(), adCep1);
750 cepMap.put(adCep2.key(), adCep2);
751 cepMap.put(adCep3.key(), adCep3);
753 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
754 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
756 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
757 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA, degCep1);
758 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
759 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
760 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
761 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
762 cepMap.put(degCep1.key(), degCep1);
763 cepMap.put(degCep2.key(), degCep2);
764 cepMap.put(degCep3.key(), degCep3);
766 LOG.info("Going to create cross connections for ROADM {}", roadm);
767 // Create X connections between MC and OTSi_MC for full map
768 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
769 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
770 LayerProtocolName.PHOTONICMEDIA);
771 LOG.info("Cross connection 1 created = {}", connection1);
772 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
773 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
774 LayerProtocolName.PHOTONICMEDIA);
775 LOG.info("Cross connection 2 created = {}", connection2);
776 this.connectionFullMap.put(connection1.key(), connection1);
777 this.connectionFullMap.put(connection2.key(), connection2);
779 // Create X connections that will be added to the service object
780 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
781 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
783 xcMap.put(conn1.key(), conn1);
784 xcMap.put(conn2.key(), conn2);
786 LOG.info("Going to create top connections betwee roadms");
787 // create top connections between roadms: MC connections between AD MC CEPs of roadms
788 for (int i = 0; i < rdmNodelist.size(); i++) {
789 if (rdmNodelist.size() <= (i + 1)) {
790 LOG.info("Reached last roadm. No more MC connections");
793 // Current roadm with roadm i + 1 --> MC
794 String roadm1 = rdmNodelist.get(i);
795 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
796 String roadm2 = rdmNodelist.get(i + 1);
797 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
798 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
800 // Create top connections between MC for full map
801 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
802 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
803 LayerProtocolName.PHOTONICMEDIA, xcMap);
804 this.connectionFullMap.put(connection.key(), connection);
805 LOG.info("Top connection created = {}", connection);
807 // Create top connections that will be added to the service object
808 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
809 connServMap.put(conn.key(), conn);
810 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
811 xcMap.put(conn1.key(), conn1);
814 // OTSiMC top connection between edge roadms
815 LOG.info("Going to created top connection between OTSiMC");
816 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
817 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
818 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
819 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
820 LayerProtocolName.PHOTONICMEDIA, xcMap);
821 this.connectionFullMap.put(connection.key(), connection);
822 LOG.info("Top connection created = {}", connection);
824 // OTSiMC top connections that will be added to the service object
825 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
826 connServMap.put(conn.key(), conn);
830 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
831 createTopConnection(String tp1, String tp2,
832 Map<org.opendaylight.yang.gen.v1.urn
833 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
834 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
835 Map<LowerConnectionKey, LowerConnection> xcMap) {
836 // find cep for each AD MC of roadm 1 and 2
837 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
838 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
839 cepMap.get(new org.opendaylight.yang.gen.v1.urn
840 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
841 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
842 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
844 LOG.info("ADCEP1 = {}", adCep1);
845 org.opendaylight.yang.gen.v1.urn
846 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
847 new org.opendaylight.yang.gen.v1.urn
848 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
849 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
850 .values().stream().findFirst().get().getNodeEdgePointUuid())
851 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
852 .values().stream().findFirst().get().getTopologyUuid())
853 .setNodeUuid(adCep1.getClientNodeEdgePoint()
854 .values().stream().findFirst().get().getNodeUuid())
855 .setConnectionEndPointUuid(adCep1.getUuid())
857 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
858 cepMap.get(new org.opendaylight.yang.gen.v1.urn
859 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
860 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
861 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
863 LOG.info("ADCEP2 = {}", adCep2);
864 org.opendaylight.yang.gen.v1.urn
865 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
866 new org.opendaylight.yang.gen.v1.urn
867 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
868 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
869 .values().stream().findFirst().get().getNodeEdgePointUuid())
870 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
871 .values().stream().findFirst().get().getTopologyUuid())
872 .setNodeUuid(adCep2.getClientNodeEdgePoint()
873 .values().stream().findFirst().get().getNodeUuid())
874 .setConnectionEndPointUuid(adCep1.getUuid())
876 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
877 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
878 ceps.put(cep1.key(), cep1);
879 ceps.put(cep2.key(), cep2);
880 Name connName = new NameBuilder()
881 .setValueName("Connection name")
882 .setValue(String.join("+", "TOP", tp1, tp2, qual))
884 // TODO: lower connection, supported link.......
885 return new org.opendaylight.yang.gen.v1.urn
886 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
887 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
888 .getBytes(Charset.forName("UTF-8"))).toString()))
889 .setName(Map.of(connName.key(), connName))
890 .setConnectionEndPoint(ceps)
891 .setOperationalState(OperationalState.ENABLED)
892 .setLayerProtocolName(topPortocol)
893 .setLifecycleState(LifecycleState.INSTALLED)
894 .setDirection(ForwardingDirection.BIDIRECTIONAL)
895 .setLowerConnection(xcMap)
899 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
900 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
901 LayerProtocolName xcProtocol) {
902 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
903 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
904 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
905 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
906 org.opendaylight.yang.gen.v1.urn
907 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
908 new org.opendaylight.yang.gen.v1.urn
909 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
910 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
911 .values().stream().findFirst().get().getNodeEdgePointUuid())
912 .setTopologyUuid(cep1.getClientNodeEdgePoint()
913 .values().stream().findFirst().get().getTopologyUuid())
914 .setNodeUuid(cep1.getClientNodeEdgePoint()
915 .values().stream().findFirst().get().getNodeUuid())
916 .setConnectionEndPointUuid(cep1.getUuid())
918 org.opendaylight.yang.gen.v1.urn
919 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
920 new org.opendaylight.yang.gen.v1.urn
921 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
922 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
923 .values().stream().findFirst().get().getNodeEdgePointUuid())
924 .setTopologyUuid(cep2.getClientNodeEdgePoint()
925 .values().stream().findFirst().get().getTopologyUuid())
926 .setNodeUuid(cep2.getClientNodeEdgePoint()
927 .values().stream().findFirst().get().getNodeUuid())
928 .setConnectionEndPointUuid(cep2.getUuid())
930 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
931 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
932 ceps.put(cepServ1.key(), cepServ1);
933 ceps.put(cepServ2.key(), cepServ2);
934 Name connName = new NameBuilder()
935 .setValueName("Connection name")
936 .setValue(String.join("+", "XC", tp1, tp2, qual))
938 // TODO: lower connection, supported link.......
939 return new org.opendaylight.yang.gen.v1.urn
940 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
941 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
942 .getBytes(Charset.forName("UTF-8"))).toString()))
943 .setName(Map.of(connName.key(), connName))
944 .setConnectionEndPoint(ceps)
945 .setOperationalState(OperationalState.ENABLED)
946 .setLayerProtocolName(xcProtocol)
947 .setLifecycleState(LifecycleState.INSTALLED)
948 .setDirection(ForwardingDirection.BIDIRECTIONAL)
952 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
953 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
954 Name cepName = new NameBuilder()
955 .setValueName("ConnectionEndPoint name")
956 .setValue(String.join("+", id.split("\\+")[0], qualifier,
959 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
960 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
961 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
963 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
964 qualifier)).getBytes(Charset.forName("UTF-8")))
966 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
967 .getBytes(Charset.forName("UTF-8"))).toString()))
969 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
970 // TODO: add parent ONEP??
971 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
972 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
973 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
975 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
976 .setName(Map.of(cepName.key(), cepName))
977 .setConnectionPortRole(PortRole.SYMMETRIC)
978 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
979 .setOperationalState(OperationalState.ENABLED)
980 .setLifecycleState(LifecycleState.INSTALLED)
981 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
982 return cepBldr.build();
985 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
986 LayerProtocolName cepProtocol) {
987 Name cepName = new NameBuilder()
988 .setValueName("ConnectionEndPoint name")
989 .setValue(String.join("+", id.split("\\+")[0], qualifier,
992 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
993 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
994 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
996 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
997 nodeLayer)).getBytes(Charset.forName("UTF-8")))
999 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1000 .getBytes(Charset.forName("UTF-8"))).toString()))
1002 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1003 // TODO: add parent ONEP??
1004 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1005 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1006 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
1008 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
1009 .setName(Map.of(cepName.key(), cepName))
1010 .setConnectionPortRole(PortRole.SYMMETRIC)
1011 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
1012 .setOperationalState(OperationalState.ENABLED)
1013 .setLifecycleState(LifecycleState.INSTALLED)
1014 .setLayerProtocolName(cepProtocol);
1015 return cepBldr.build();
1018 private EndPoint mapServiceZEndPoint(
1019 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceZEnd
1020 serviceZEnd, PathDescription pathDescription) {
1021 EndPointBuilder endPointBuilder = new EndPointBuilder();
1022 // 1. Service Format: ODU, OTU, ETH
1023 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1024 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1025 // Identify SIP name
1026 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1027 LOG.info("Uuid of z end {}", sipUuid);
1028 LayerProtocolName layerProtocols = null;
1029 // Layer protocol name
1030 switch (serviceFormat) {
1032 layerProtocols = LayerProtocolName.DSR;
1036 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1039 layerProtocols = LayerProtocolName.ODU;
1042 LOG.error("Service Format not supported");
1044 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1045 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1046 .setValueName("OpenROADM info")
1047 .setValue(String.join("-", serviceZEnd.getClli(),
1048 serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
1049 serviceZEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
1051 return endPointBuilder
1052 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1053 .setServiceInterfacePointUuid(sipUuid)
1055 .setName(Map.of(name.key(), name))
1056 .setAdministrativeState(AdministrativeState.UNLOCKED)
1057 .setDirection(PortDirection.BIDIRECTIONAL)
1058 .setLifecycleState(LifecycleState.INSTALLED)
1059 .setOperationalState(OperationalState.ENABLED)
1060 .setLayerProtocolName(layerProtocols)
1061 .setCapacity(new CapacityBuilder()
1062 .setTotalSize(new TotalSizeBuilder()
1063 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
1064 .setUnit(CapacityUnit.GBPS)
1066 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1068 .setProtectionRole(ProtectionRole.WORK)
1069 .setRole(PortRole.SYMMETRIC)
1070 .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().get()
1071 .getPort().getPortDeviceName())
1075 private EndPoint mapServiceAEndPoint(
1076 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEnd
1077 serviceAEnd, PathDescription pathDescription) {
1078 EndPointBuilder endPointBuilder = new EndPointBuilder();
1079 // 1. Service Format: ODU, OTU, ETH
1080 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1081 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1082 // Identify SIP name
1083 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1084 LOG.info("Uuid of a end {}", sipUuid);
1085 LayerProtocolName layerProtocols = null;
1086 // Layer protocol name
1087 switch (serviceFormat) {
1089 layerProtocols = LayerProtocolName.DSR;
1093 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1096 layerProtocols = LayerProtocolName.ODU;
1099 LOG.error("Service Format not supported");
1101 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1102 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1103 .setValueName("OpenROADM info")
1104 .setValue(String.join("-", serviceAEnd.getClli(),
1105 serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName(),
1106 serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortName()))
1108 return endPointBuilder
1109 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1110 .setServiceInterfacePointUuid(sipUuid)
1112 .setName(Map.of(name.key(), name))
1113 .setAdministrativeState(AdministrativeState.UNLOCKED)
1114 .setDirection(PortDirection.BIDIRECTIONAL)
1115 .setLifecycleState(LifecycleState.INSTALLED)
1116 .setOperationalState(OperationalState.ENABLED)
1117 .setLayerProtocolName(layerProtocols)
1118 .setCapacity(new CapacityBuilder()
1119 .setTotalSize(new TotalSizeBuilder()
1120 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
1121 .setUnit(CapacityUnit.GBPS)
1123 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1125 .setProtectionRole(ProtectionRole.WORK)
1126 .setRole(PortRole.SYMMETRIC)
1127 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().get().getPort().getPortDeviceName())
1131 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1132 Uuid zendUuid = null;
1133 if (serviceNodeId.contains("ROADM")) {
1134 // Service from ROADM to ROADM
1135 // AddDrop-AddDrop ports --> MC layer SIPs
1136 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1137 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1138 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1139 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1141 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1142 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1143 if (!sip.getUuid().equals(sipUuid)) {
1144 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1147 zendUuid = sip.getUuid();
1151 // Service from XPDR to XPDR
1153 TerminationPoint tp;
1155 switch (serviceFormat) {
1157 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1158 tp = (TerminationPoint) firstElement.getResource().getResource();
1159 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1160 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1161 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1163 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1167 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1168 tp = (TerminationPoint) firstElement.getResource().getResource();
1169 // Network-Network ports --> iOTSi layer SIPs
1170 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1171 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1173 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1177 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1178 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1179 tp = (TerminationPoint) firstElement.getResource().getResource();
1180 // Client-client ports --> DSR layer SIPs
1181 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1182 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1184 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1189 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1191 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1192 if (!sip.getUuid().equals(sipUuid)) {
1193 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1196 zendUuid = sip.getUuid();
1203 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1204 Uuid aendUuid = null;
1205 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1206 LOG.info("Map a to z = {}", mapatoz);
1207 if (serviceNodeId.contains("ROADM")) {
1208 // Service from ROADM to ROADM
1209 // AddDrop-AddDrop ports --> MC layer SIPs
1210 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1211 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1212 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1213 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1214 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1216 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1218 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1219 if (!sip.getUuid().equals(sipUuid)) {
1220 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1223 aendUuid = sip.getUuid();
1227 // Service from XPDR to XPDR
1229 TerminationPoint tp;
1231 switch (serviceFormat) {
1233 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1234 tp = (TerminationPoint) firstElement.getResource().getResource();
1235 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1236 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1237 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1239 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1240 TapiStringConstants.I_ODU, tp.getTpId()));
1243 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1244 tp = (TerminationPoint) firstElement.getResource().getResource();
1245 // Network-Network ports --> iOTSi layer SIPs
1246 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1247 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1249 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1250 TapiStringConstants.I_OTSI, tp.getTpId()));
1253 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1254 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1255 tp = (TerminationPoint) firstElement.getResource().getResource();
1256 // Client-client ports --> DSR layer SIPs
1257 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1258 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1260 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1261 TapiStringConstants.DSR, tp.getTpId()));
1265 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1267 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1268 if (!sip.getUuid().equals(sipUuid)) {
1269 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1272 aendUuid = sip.getUuid();
1279 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1280 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1281 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1282 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1283 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1284 .getBytes(Charset.forName("UTF-8"))).toString());
1285 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1286 .getBytes(Charset.forName("UTF-8"))).toString());
1287 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1288 .getBytes(Charset.forName("UTF-8"))).toString());
1289 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1292 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1293 ConnectionEndPoint cep) {
1294 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1295 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1296 .getBytes(Charset.forName("UTF-8"))).toString());
1297 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1298 .getBytes(Charset.forName("UTF-8"))).toString());
1299 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1300 .getBytes(Charset.forName("UTF-8"))).toString());
1301 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1304 public Map<org.opendaylight.yang.gen.v1.urn
1305 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1306 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1307 getConnectionFullMap() {
1308 return this.connectionFullMap;
1311 private String getIdBasedOnModelVersion(String nodeid) {
1312 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1313 nodeid.split("-")[1]) : nodeid.split("-")[0];
1316 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1317 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1318 Map<org.opendaylight.yang.gen.v1.urn
1319 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1320 org.opendaylight.yang.gen.v1.urn
1321 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1322 endPointMap = input.getEndPoint();
1323 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1324 ConnectionType connType = null;
1325 ServiceFormat serviceFormat = null;
1326 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1327 TapiStringConstants.DSR);
1328 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1329 TapiStringConstants.DSR);
1330 LOG.debug("Node a = {}", nodeAid);
1331 LOG.debug("Node z = {}", nodeZid);
1332 switch (constraint.getServiceLayer().getIntValue()) {
1335 connType = ConnectionType.Infrastructure;
1336 serviceFormat = ServiceFormat.ODU;
1339 LOG.info("ETH, no need to create OTU and ODU");
1340 connType = ConnectionType.Service;
1341 serviceFormat = ServiceFormat.Ethernet;
1344 LOG.info("DSR, need to create OTU and ODU");
1345 connType = ConnectionType.Service;
1346 serviceFormat = ServiceFormat.Ethernet;
1349 LOG.info("PHOTONIC");
1350 connType = getConnectionTypePhtnc(endPointMap.values());
1351 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1352 if (serviceFormat.equals(ServiceFormat.OC)) {
1353 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1354 TapiStringConstants.PHTNC_MEDIA);
1355 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1356 TapiStringConstants.PHTNC_MEDIA);
1358 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1359 TapiStringConstants.OTSI);
1360 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1361 TapiStringConstants.OTSI);
1363 LOG.debug("Node a photonic = {}", nodeAid);
1364 LOG.debug("Node z photonic = {}", nodeZid);
1367 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1369 // Requested Capacity for connectivity service
1370 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1371 // map endpoints into service end points. Map the type of service from TAPI to OR
1372 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1373 serviceFormat, nodeAid, capacity, constraint.getServiceLayer());
1374 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1375 serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
1376 if (serviceAEnd == null || serviceZEnd == null) {
1377 LOG.error("Couldnt map endpoints to service end");
1380 LOG.info("Service a end = {}", serviceAEnd);
1381 LOG.info("Service z end = {}", serviceZEnd);
1382 return new ServiceCreateInputBuilder()
1383 .setServiceAEnd(serviceAEnd)
1384 .setServiceZEnd(serviceZEnd)
1385 .setConnectionType(connType)
1386 .setServiceName(serviceUuid.getValue())
1387 .setCommonId("common id")
1388 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1389 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1390 .setRequestSystemId("appname")
1392 .setCustomer("customer")
1393 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1394 .setOperatorContact("pw1234")
1398 private ServiceZEnd tapiEndPointToServiceZPoint(
1399 org.opendaylight.yang.gen.v1.urn
1400 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1401 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1402 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1403 // Not the rest which is needed in the txPortDeviceName.
1404 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1405 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1406 // Todo -> need to find the NEP associated to that SIP
1407 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString());
1408 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1409 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1411 LOG.error("Node not found in datastore");
1414 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1415 // connection is between 2 CLIENT ports. Otherwise it will not work...
1416 OwnedNodeEdgePoint nep = null;
1417 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1418 if (onep.getMappedServiceInterfacePoint() == null) {
1421 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1427 LOG.error("Nep not found in datastore");
1430 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1431 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1432 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1433 String txPortDeviceName = nepName.split("\\+")[0];
1434 String txPortName = nepName.split("\\+")[2];
1435 String rxPortDeviceName = txPortDeviceName;
1436 String rxPortName = txPortName;
1437 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1438 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1439 // TODO --> get clli from datastore?
1440 String clli = "NodeSC";
1441 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1442 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1443 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1445 .setNodeId(new NodeIdType(nodeid))
1446 .setOpticType(OpticTypes.Gray)
1447 .setServiceFormat(serviceFormat)
1448 .setServiceRate(Uint32.valueOf(capacity))
1449 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1450 .setCommittedBurstSize(Uint16.valueOf(64))
1451 .setCommittedInfoRate(Uint32.valueOf(100000))
1454 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1455 .setPort(new PortBuilder()
1456 .setPortDeviceName(txPortDeviceName)
1457 .setPortName(txPortName)
1458 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1460 .setPortType(TapiStringConstants.PORT_TYPE)
1462 .setLgx(new LgxBuilder()
1463 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1464 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1465 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1466 .setLgxPortShelf("00")
1468 .setIndex(Uint8.ZERO)
1470 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1471 .setPort(new PortBuilder()
1472 .setPortDeviceName(rxPortDeviceName)
1473 .setPortName(rxPortName)
1474 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1476 .setPortType(TapiStringConstants.PORT_TYPE)
1478 .setLgx(new LgxBuilder()
1479 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1480 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1481 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1482 .setLgxPortShelf("00")
1484 .setIndex(Uint8.ZERO)
1486 if (serviceFormat.equals(ServiceFormat.ODU)) {
1487 serviceZEndBuilder.setOduServiceRate(ODU4.class);
1489 if (serviceFormat.equals(ServiceFormat.OTU)) {
1490 serviceZEndBuilder.setOtuServiceRate(OTU4.class);
1492 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1494 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1495 .setCommittedBurstSize(Uint16.valueOf(64))
1496 .setCommittedInfoRate(Uint32.valueOf(100000))
1500 return serviceZEndBuilder.build();
1503 private ServiceAEnd tapiEndPointToServiceAPoint(
1504 org.opendaylight.yang.gen.v1.urn
1505 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1506 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1507 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1508 // Not the rest which is needed in the txPortDeviceName.
1509 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1510 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1511 // Todo -> need to find the NEP associated to that SIP
1512 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString());
1513 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1514 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1516 LOG.error("Node not found in datastore");
1519 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1520 // connection is between 2 CLIENT ports. Otherwise it will not work...
1521 OwnedNodeEdgePoint nep = null;
1522 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1523 if (onep.getMappedServiceInterfacePoint() == null) {
1526 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1532 LOG.error("Nep not found in datastore");
1535 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1536 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1537 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1538 String txPortDeviceName = nepName.split("\\+")[0];
1539 String txPortName = nepName.split("\\+")[2];
1540 String rxPortDeviceName = txPortDeviceName;
1541 String rxPortName = txPortName;
1542 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1543 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1544 // TODO --> get clli from datastore?
1545 String clli = "NodeSA";
1546 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1547 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1548 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1550 .setNodeId(new NodeIdType(nodeid))
1551 .setOpticType(OpticTypes.Gray)
1552 .setServiceFormat(serviceFormat)
1553 .setServiceRate(Uint32.valueOf(capacity))
1554 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1555 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.subrate.eth
1556 .sla.SubrateEthSlaBuilder()
1557 .setCommittedBurstSize(Uint16.valueOf(64))
1558 .setCommittedInfoRate(Uint32.valueOf(100000))
1561 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1562 .setPort(new PortBuilder()
1563 .setPortDeviceName(txPortDeviceName)
1564 .setPortName(txPortName)
1565 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1567 .setPortType(TapiStringConstants.PORT_TYPE)
1569 .setLgx(new LgxBuilder()
1570 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1571 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1572 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1573 .setLgxPortShelf("00")
1575 .setIndex(Uint8.ZERO)
1577 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1578 .setPort(new PortBuilder()
1579 .setPortDeviceName(rxPortDeviceName)
1580 .setPortName(rxPortName)
1581 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1583 .setPortType(TapiStringConstants.PORT_TYPE)
1585 .setLgx(new LgxBuilder()
1586 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1587 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1588 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1589 .setLgxPortShelf("00")
1591 .setIndex(Uint8.ZERO)
1593 if (serviceFormat.equals(ServiceFormat.ODU)) {
1594 serviceAEndBuilder.setOduServiceRate(ODU4.class);
1596 if (serviceFormat.equals(ServiceFormat.OTU)) {
1597 serviceAEndBuilder.setOtuServiceRate(OTU4.class);
1599 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1601 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1602 .setCommittedBurstSize(Uint16.valueOf(64))
1603 .setCommittedInfoRate(Uint32.valueOf(100000))
1607 return serviceAEndBuilder.build();
1610 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1611 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1612 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1613 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1614 // EndPoints are ROADMs
1615 return ConnectionType.RoadmLine;
1617 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1618 return ConnectionType.Infrastructure;
1621 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1622 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1623 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1624 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1625 // EndPoints are ROADMs
1626 return ServiceFormat.OC;
1628 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1629 return ServiceFormat.OTU;
1632 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1633 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1634 TapiStringConstants.DSR).getBytes(Charset.forName("UTF-8")))).toString());
1635 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1636 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(Charset.forName("UTF-8"))))
1638 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1639 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1640 .getBytes(Charset.forName("UTF-8"))).toString());
1641 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1644 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1645 for (String networkPort:xpdrNetworkTplist) {
1646 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1653 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1654 List<String> clientPortList = new ArrayList<>();
1655 for (String networkPort:xpdrNetworkTplist) {
1656 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1657 networkPort.split("\\+")[0].split("-")[1]);
1658 String tpId = networkPort.split("\\+")[1];
1659 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1660 .child(Nodes.class, new NodesKey(nodeId))
1661 .child(Mapping.class, new MappingKey(tpId)).build();
1663 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1665 if (!optMapping.isPresent()) {
1666 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1668 Mapping mapping = optMapping.get();
1669 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1670 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1671 mapping.getConnectionMapLcp());
1672 LOG.info("Key to be added to list = {}", key);
1673 if (!clientPortList.contains(key)) {
1674 clientPortList.add(key);
1676 } catch (InterruptedException | ExecutionException e) {
1677 LOG.error("Couldnt read mapping from datastore", e);
1682 return clientPortList;
1685 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1686 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1687 for (String xpdrNode:xpdrNodelist) {
1688 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.DSR))
1689 .getBytes(Charset.forName("UTF-8"))).toString());
1690 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1691 .onf.otcc.yang.tapi.topology.rev181210.topology.Node> nodeIID = InstanceIdentifier.builder(
1692 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1693 .onf.otcc.yang.tapi.topology.rev181210.Context1.class).child(TopologyContext.class)
1694 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1695 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
1696 new NodeKey(nodeUuid)).build();
1698 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> optNode
1699 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1700 if (!optNode.isPresent()) {
1703 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
1704 new NameKey("Node Type")).getValue()).get();
1705 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1706 openroadmNodeTypeList.add(openroadmNodeType);
1708 } catch (InterruptedException | ExecutionException e) {
1709 LOG.error("Couldnt read node in topology", e);
1713 // TODO for now check that there is only one type, otherwise error
1714 if (openroadmNodeTypeList.size() != 1) {
1715 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1718 return openroadmNodeTypeList.get(0);