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 Map<String, Map<String, Boolean>> networkMap = new HashMap<>();
129 private final NetworkTransactionService networkTransactionService;
131 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
132 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
133 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
134 NetworkTransactionService networkTransactionService) {
135 this.serviceDataStoreOperations = serviceDataStoreOperations;
136 this.tapiContext = tapiContext;
137 this.sipMap = sipMap;
138 this.connectionFullMap = new HashMap<>();
139 this.networkTransactionService = networkTransactionService;
142 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
143 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
144 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
145 if (serviceAEnd == null || serviceZEnd == null) {
146 LOG.warn("One of the endpoints could not be identified");
149 return new ServiceCreateInputBuilder()
150 .setCommonId("commonId")
151 .setConnectionType(ConnectionType.Service)
152 .setCustomer("Customer")
153 .setServiceName("service test")
154 .setServiceAEnd(serviceAEnd)
155 .setServiceZEnd(serviceZEnd)
156 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
157 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
163 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
164 String txPortName, String rxPortDeviceName, String rxPortName) {
165 return new ServiceAEndBuilder()
167 .setNodeId(new NodeIdType(nodeid))
168 .setOpticType(OpticTypes.Gray)
169 .setServiceFormat(ServiceFormat.Ethernet)
170 .setServiceRate(Uint32.valueOf(100))
171 .setTxDirection(new TxDirectionBuilder()
172 .setPort(new PortBuilder()
173 .setPortDeviceName(txPortDeviceName)
174 .setPortName(txPortName)
175 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
177 .setPortType(TapiStringConstants.PORT_TYPE)
179 .setLgx(new LgxBuilder()
180 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
181 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
182 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
183 .setLgxPortShelf("00")
186 .setRxDirection(new RxDirectionBuilder()
187 .setPort(new PortBuilder()
188 .setPortDeviceName(rxPortDeviceName)
189 .setPortName(rxPortName)
190 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
192 .setPortType(TapiStringConstants.PORT_TYPE)
194 .setLgx(new LgxBuilder()
195 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
196 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
197 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
198 .setLgxPortShelf("00")
204 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
205 String txPortName, String rxPortDeviceName, String rxPortName) {
206 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
207 .setOpticType(OpticTypes.Gray)
208 .setServiceFormat(ServiceFormat.Ethernet)
209 .setServiceRate(Uint32.valueOf(100))
210 .setTxDirection(new TxDirectionBuilder()
211 .setPort(new PortBuilder()
212 .setPortDeviceName(txPortDeviceName)
213 .setPortName(txPortName)
214 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
216 .setPortType(TapiStringConstants.PORT_TYPE)
218 .setLgx(new LgxBuilder()
219 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
220 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
221 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
222 .setLgxPortShelf("00")
225 .setRxDirection(new RxDirectionBuilder()
226 .setPort(new PortBuilder()
227 .setPortDeviceName(rxPortDeviceName)
228 .setPortName(rxPortName)
229 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
231 .setPortType(TapiStringConstants.PORT_TYPE)
233 .setLgx(new LgxBuilder()
234 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
235 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
236 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
237 .setLgxPortShelf("00")
243 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
244 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
245 return new ServiceAEndBuilder(sepA.getValue()).build();
246 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
247 return new ServiceAEndBuilder(sepZ.getValue()).build();
253 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
254 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
255 return new ServiceZEndBuilder(sepA.getValue()).build();
256 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
257 return new ServiceZEndBuilder(sepZ.getValue()).build();
263 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
267 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
268 // Get service path with the description in OR based models.
269 LOG.info("Service = {}", service);
270 Optional<ServicePaths> optServicePaths =
271 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
272 if (!optServicePaths.isPresent()) {
273 LOG.error("No service path found for service {}", service.getServiceName());
276 ServicePaths servicePaths = optServicePaths.get();
277 PathDescription pathDescription = servicePaths.getPathDescription();
278 LOG.info("Path description of service = {}", pathDescription);
279 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd
280 = service.getServiceAEnd();
282 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
283 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd
284 = service.getServiceZEnd();
285 EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
286 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
287 endPointMap.put(endPoint1.key(), endPoint1);
288 endPointMap.put(endPoint2.key(), endPoint2);
289 LOG.info("EndPoints of connectivity services = {}", endPointMap);
291 Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
293 // Connection creation
294 Map<ConnectionKey, Connection> connMap =
295 createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription);
296 // TODO: full connectivity service?? With constraints and the rest of fields...
297 return new ConnectivityServiceBuilder()
298 .setAdministrativeState(AdministrativeState.UNLOCKED)
299 .setOperationalState(OperationalState.ENABLED)
300 .setLifecycleState(LifecycleState.INSTALLED)
301 .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8")))
303 .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
304 .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
305 .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL)
306 .setName(Map.of(name.key(), name))
307 .setConnection(connMap)
308 .setEndPoint(endPointMap)
312 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
313 switch (serviceFormat) {
316 return LayerProtocolName.PHOTONICMEDIA;
318 return LayerProtocolName.ODU;
320 String node1 = endPoint1.getLocalId();
321 String node2 = endPoint2.getLocalId();
322 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
323 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
324 return LayerProtocolName.ETH;
326 return LayerProtocolName.DSR;
328 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
333 private OpenroadmNodeType getOpenroadmType(String nodeName) {
334 LOG.info("Node name = {}", nodeName);
335 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.DSR))
336 .getBytes(Charset.forName("UTF-8"))).toString());
337 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node tapiNode
338 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
339 if (tapiNode != null) {
340 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
346 private Map<ConnectionKey, Connection> createConnectionsFromService(
347 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
349 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
351 PathDescription pathDescription) {
352 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
353 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
354 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
355 // and the connections
357 List<String> xpdrClientTplist = new ArrayList<>();
358 List<String> xpdrNetworkTplist = new ArrayList<>();
359 List<String> rdmAddDropTplist = new ArrayList<>();
360 List<String> rdmDegTplist = new ArrayList<>();
361 List<String> rdmNodelist = new ArrayList<>();
362 List<String> xpdrNodelist = new ArrayList<>();
363 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
364 .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) {
365 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
366 switch (resourceType) {
367 case TapiStringConstants.TP:
368 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
369 String tpID = tp.getTpId();
371 if (tpID.contains("CLIENT")) {
372 tpNode = tp.getTpNodeId();
373 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
374 xpdrClientTplist.add(String.join("+", tpNode, tpID));
377 if (tpID.contains("NETWORK")) {
378 tpNode = tp.getTpNodeId();
379 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
380 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
383 if (tpID.contains("PP")) {
384 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
385 LOG.info("ROADM Node of tp = {}", tpNode);
386 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
387 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
390 if (tpID.contains("TTP")) {
391 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
392 LOG.info("ROADM Node of tp = {}", tpNode);
393 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
394 rdmDegTplist.add(String.join("+", tpNode, tpID));
398 case TapiStringConstants.NODE:
399 Node node = (Node) elem.getResource().getResource();
400 String nodeId = node.getNodeId();
401 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
402 LOG.info("Node id = {}", nodeId);
403 if (!xpdrNodelist.contains(nodeId)) {
404 xpdrNodelist.add(nodeId); // should contain only 2
407 if (nodeId.contains("ROADM")) {
408 nodeId = getIdBasedOnModelVersion(nodeId);
409 LOG.info("Node id = {}", nodeId);
410 if (!rdmNodelist.contains(nodeId)) {
411 rdmNodelist.add(nodeId);
416 LOG.warn("Resource is a {}", resourceType);
419 LOG.info("ROADM node list = {}", rdmNodelist);
420 LOG.info("ROADM degree list = {}", rdmDegTplist);
421 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
422 LOG.info("XPDR node list = {}", xpdrNodelist);
423 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
424 LOG.info("XPDR client list = {}", xpdrClientTplist);
425 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
426 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
427 // to trigger all the steps or not
428 String edgeRoadm1 = "";
429 String edgeRoadm2 = "";
430 if (!rdmNodelist.isEmpty()) {
431 edgeRoadm1 = rdmNodelist.get(0);
432 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
433 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
434 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
436 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
437 // CEPs must be included in the topology context as an augmentation for each ONEP!!
438 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd
439 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
440 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
441 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
442 // this needs to be changed
443 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
444 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
445 switch (serviceFormat) {
447 // Identify number of ROADMs
448 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
449 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
450 // - Top Connection MC betwwen MC CEPs of different roadms
451 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
452 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
453 edgeRoadm1, edgeRoadm2));
456 // Identify number of ROADMs between XPDRs and check if OC is created
457 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
458 // - Top Connection MC betwwen MC CEPs of different roadms
459 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
460 // - Top Connection OTSiMC betwwen OTSiMC CEPs of different roadms
461 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
462 edgeRoadm1, edgeRoadm2));
463 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
464 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
465 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
468 // - XC Connection OTSi betwwen iODU and eODU of xpdr
469 // - Top connection in the ODU layer, between xpdr eODU ports (?)
470 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
473 // Check if OC, OTU and ODU are created
474 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
475 LOG.info("WDM ETH service");
476 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
477 edgeRoadm1, edgeRoadm2));
478 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
479 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
480 LOG.info("Associated client ports = {}", xpdrClientTplist);
481 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
484 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
485 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
486 // - XC Connection OTSi betwwen iODU and eODU of xpdr
487 // - Top connection in the ODU layer, between xpdr eODU ports (?)
488 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
489 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
492 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
493 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
494 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
499 LOG.error("Service type format not supported");
501 return connectionServMap;
504 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
505 List<String> xpdrNodelist,
506 Map<ConnectionKey, Connection> lowerConn) {
507 // TODO: do we need to create cross connection between iODU and eODU??
508 // add the lower connections of the previous steps for this kind of service
509 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
510 for (Connection lowConn: lowerConn.values()) {
511 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
512 xcMap.put(conn.key(), conn);
514 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
515 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
516 ConnectionEndPoint> cepMapDsr = new HashMap<>();
517 // Create 1 cep per Xpdr in the CLIENT
518 // 1 top connection DSR between the CLIENT xpdrs
519 for (String xpdr:xpdrNodelist) {
520 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
521 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
523 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
524 LayerProtocolName.DSR);
525 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
527 cepMapDsr.put(netCep1.key(), netCep1);
529 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
530 .get(0))).findFirst().get();
531 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
532 .get(xpdrNodelist.size() - 1))).findFirst().get();
534 // DSR top connection between edge xpdr CLIENT DSR
535 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
536 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
537 LayerProtocolName.DSR, xcMap);
538 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
540 // DSR top connection that will be added to the service object
541 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
542 connServMap.put(conn1.key(), conn1);
547 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
548 List<String> xpdrNetworkTplist,
549 List<String> xpdrNodelist) {
550 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
551 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
552 ConnectionEndPoint> cepMapDsr = new HashMap<>();
553 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
554 ConnectionEndPoint> cepMapOdu = new HashMap<>();
555 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
556 // be added to the lower connection of a top connection
557 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
559 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
560 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
561 for (String xpdr:xpdrNodelist) {
562 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
563 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
565 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR,
566 LayerProtocolName.DSR);
567 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.DSR, netCep1);
569 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
570 TapiStringConstants.DSR, LayerProtocolName.ODU);
571 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.DSR,
574 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
575 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
577 cepMapDsr.put(netCep1.key(), netCep1);
578 cepMapOdu.put(netCep2.key(), netCep2);
579 // Create x connection between I_ODU and E_ODU within xpdr
580 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
581 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
582 TapiStringConstants.ODU, LayerProtocolName.ODU);
583 this.connectionFullMap.put(connection.key(), connection);
585 // Create X connection that will be added to the service object
586 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
587 xcMap.put(conn.key(), conn);
590 // DSR top connection between edge xpdr CLIENT DSR
591 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
592 .get(0))).findFirst().get();
593 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
594 .get(xpdrNodelist.size() - 1))).findFirst().get();
596 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
597 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
598 LayerProtocolName.ODU, xcMap);
599 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
601 // ODU top connection that will be added to the service object
602 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
603 connServMap.put(conn.key(), conn);
604 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
605 xcMap.put(lowerConn.key(), lowerConn);
607 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
608 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
609 LayerProtocolName.DSR, xcMap);
610 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
612 // DSR top connection that will be added to the service object
613 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
614 connServMap.put(conn1.key(), conn1);
619 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
620 List<String> xpdrNodelist) {
621 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
622 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
623 ConnectionEndPoint> cepMap = new HashMap<>();
624 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
625 // be added to the lower connection of a top connection
626 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
628 // Create 1 cep per Xpdr in the I_ODU and a top
629 // connection iODU between the xpdrs
630 for (String xpdr:xpdrNodelist) {
631 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
632 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
634 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
635 TapiStringConstants.DSR, LayerProtocolName.ODU);
636 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.DSR,
639 cepMap.put(netCep1.key(), netCep1);
642 // ODU top connection between edge xpdr i_ODU
643 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
644 .get(0))).findFirst().get();
645 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
646 .get(xpdrNodelist.size() - 1))).findFirst().get();
647 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
648 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
649 LayerProtocolName.ODU, xcMap);
650 this.connectionFullMap.put(connection.key(), connection);
652 // ODU top connection that will be added to the service object
653 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
654 connServMap.put(conn.key(), conn);
659 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
660 List<String> xpdrNodelist) {
661 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
662 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
663 ConnectionEndPoint> cepMap = new HashMap<>();
664 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
665 // be added to the lower connection of a top connection
666 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
668 // create ceps and x connections within xpdr
669 for (String xpdr:xpdrNodelist) {
670 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
671 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get();
672 // There should be 1 network tp per xpdr
673 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
674 // 3 different MC CEPs giving different IDs to show that they are different
675 // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs
676 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA,
677 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
678 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.OTSI,
680 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.E_OTSI,
681 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
682 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.E_OTSI, TapiStringConstants.OTSI,
684 ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
685 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
686 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
688 cepMap.put(netCep1.key(), netCep1);
689 cepMap.put(netCep2.key(), netCep2);
690 cepMap.put(netCep3.key(), netCep3);
692 // Create x connection between I_OTSi and E_OTSi within xpdr
693 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
694 connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork,
695 TapiStringConstants.OTSI, LayerProtocolName.PHOTONICMEDIA);
696 this.connectionFullMap.put(connection.key(), connection);
698 // Create X connection that will be added to the service object
699 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
700 xcMap.put(conn.key(), conn);
702 // OTSi top connection between edge I_OTSI Xpdr
703 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
704 .get(0))).findFirst().get();
705 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
706 .get(xpdrNodelist.size() - 1))).findFirst().get();
707 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
708 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_OTSI,
709 LayerProtocolName.PHOTONICMEDIA, xcMap);
710 this.connectionFullMap.put(connection.key(), connection);
712 // OTSi top connection that will be added to the service object
713 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
714 connServMap.put(conn.key(), conn);
720 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
721 List<String> rdmDegTplist,
722 List<String> rdmNodelist,
723 String edgeRoadm1, String edgeRoadm2) {
724 // TODO: when the number of roadms between 2 SPDR/XPDR is more thatn 1, we need to refine this code
725 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
726 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
727 ConnectionEndPoint> cepMap = new HashMap<>();
728 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
729 // create ceps and x connections within roadm
730 for (String roadm : rdmNodelist) {
731 LOG.info("Creating ceps and xc for roadm {}", roadm);
732 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
733 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
734 // There should be only 1 AD and 1 DEG per roadm
735 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
736 // 3 different MC CEPs giving different IDs to show that they are different
737 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
738 // created in the topology creation
739 // add CEPs to the topology to the corresponding ONEP
740 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA);
741 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA, adCep1);
742 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
743 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
744 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
745 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
746 cepMap.put(adCep1.key(), adCep1);
747 cepMap.put(adCep2.key(), adCep2);
748 cepMap.put(adCep3.key(), adCep3);
750 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get();
751 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
753 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA);
754 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA, degCep1);
755 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
756 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
757 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
758 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
759 cepMap.put(degCep1.key(), degCep1);
760 cepMap.put(degCep2.key(), degCep2);
761 cepMap.put(degCep3.key(), degCep3);
763 LOG.info("Going to create cross connections for ROADM {}", roadm);
764 // Create X connections between MC and OTSi_MC for full map
765 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
766 connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
767 LayerProtocolName.PHOTONICMEDIA);
768 LOG.info("Cross connection 1 created = {}", connection1);
769 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
770 connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
771 LayerProtocolName.PHOTONICMEDIA);
772 LOG.info("Cross connection 2 created = {}", connection2);
773 this.connectionFullMap.put(connection1.key(), connection1);
774 this.connectionFullMap.put(connection2.key(), connection2);
776 // Create X connections that will be added to the service object
777 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
778 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
780 xcMap.put(conn1.key(), conn1);
781 xcMap.put(conn2.key(), conn2);
783 LOG.info("Going to create top connections betwee roadms");
784 // create top connections between roadms: MC connections between AD MC CEPs of roadms
785 for (int i = 0; i < rdmNodelist.size(); i++) {
786 if (rdmNodelist.size() <= (i + 1)) {
787 LOG.info("Reached last roadm. No more MC connections");
790 // Current roadm with roadm i + 1 --> MC
791 String roadm1 = rdmNodelist.get(i);
792 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get();
793 String roadm2 = rdmNodelist.get(i + 1);
794 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get();
795 LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2);
797 // Create top connections between MC for full map
798 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
799 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
800 LayerProtocolName.PHOTONICMEDIA, xcMap);
801 this.connectionFullMap.put(connection.key(), connection);
802 LOG.info("Top connection created = {}", connection);
804 // Create top connections that will be added to the service object
805 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
806 connServMap.put(conn.key(), conn);
807 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
808 xcMap.put(conn1.key(), conn1);
811 // OTSiMC top connection between edge roadms
812 LOG.info("Going to created top connection between OTSiMC");
813 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get();
814 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get();
815 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
816 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
817 LayerProtocolName.PHOTONICMEDIA, xcMap);
818 this.connectionFullMap.put(connection.key(), connection);
819 LOG.info("Top connection created = {}", connection);
821 // OTSiMC top connections that will be added to the service object
822 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
823 connServMap.put(conn.key(), conn);
827 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
828 createTopConnection(String tp1, String tp2,
829 Map<org.opendaylight.yang.gen.v1.urn
830 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey,
831 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
832 Map<LowerConnectionKey, LowerConnection> xcMap) {
833 // find cep for each AD MC of roadm 1 and 2
834 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
835 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 =
836 cepMap.get(new org.opendaylight.yang.gen.v1.urn
837 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
838 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
839 qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
841 LOG.info("ADCEP1 = {}", adCep1);
842 org.opendaylight.yang.gen.v1.urn
843 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 =
844 new org.opendaylight.yang.gen.v1.urn
845 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
846 .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint()
847 .values().stream().findFirst().get().getNodeEdgePointUuid())
848 .setTopologyUuid(adCep1.getClientNodeEdgePoint()
849 .values().stream().findFirst().get().getTopologyUuid())
850 .setNodeUuid(adCep1.getClientNodeEdgePoint()
851 .values().stream().findFirst().get().getNodeUuid())
852 .setConnectionEndPointUuid(adCep1.getUuid())
854 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 =
855 cepMap.get(new org.opendaylight.yang.gen.v1.urn
856 .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey(
857 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
858 qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
860 LOG.info("ADCEP2 = {}", adCep2);
861 org.opendaylight.yang.gen.v1.urn
862 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 =
863 new org.opendaylight.yang.gen.v1.urn
864 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
865 .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint()
866 .values().stream().findFirst().get().getNodeEdgePointUuid())
867 .setTopologyUuid(adCep2.getClientNodeEdgePoint()
868 .values().stream().findFirst().get().getTopologyUuid())
869 .setNodeUuid(adCep2.getClientNodeEdgePoint()
870 .values().stream().findFirst().get().getNodeUuid())
871 .setConnectionEndPointUuid(adCep1.getUuid())
873 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
874 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
875 ceps.put(cep1.key(), cep1);
876 ceps.put(cep2.key(), cep2);
877 Name connName = new NameBuilder()
878 .setValueName("Connection name")
879 .setValue(String.join("+", "TOP", tp1, tp2, qual))
881 // TODO: lower connection, supported link.......
882 return new org.opendaylight.yang.gen.v1.urn
883 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
884 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
885 .getBytes(Charset.forName("UTF-8"))).toString()))
886 .setName(Map.of(connName.key(), connName))
887 .setConnectionEndPoint(ceps)
888 .setOperationalState(OperationalState.ENABLED)
889 .setLayerProtocolName(topPortocol)
890 .setLifecycleState(LifecycleState.INSTALLED)
891 .setDirection(ForwardingDirection.BIDIRECTIONAL)
892 .setLowerConnection(xcMap)
896 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection
897 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
898 LayerProtocolName xcProtocol) {
899 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
900 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
901 LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint());
902 LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint());
903 org.opendaylight.yang.gen.v1.urn
904 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 =
905 new org.opendaylight.yang.gen.v1.urn
906 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
907 .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint()
908 .values().stream().findFirst().get().getNodeEdgePointUuid())
909 .setTopologyUuid(cep1.getClientNodeEdgePoint()
910 .values().stream().findFirst().get().getTopologyUuid())
911 .setNodeUuid(cep1.getClientNodeEdgePoint()
912 .values().stream().findFirst().get().getNodeUuid())
913 .setConnectionEndPointUuid(cep1.getUuid())
915 org.opendaylight.yang.gen.v1.urn
916 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 =
917 new org.opendaylight.yang.gen.v1.urn
918 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder()
919 .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint()
920 .values().stream().findFirst().get().getNodeEdgePointUuid())
921 .setTopologyUuid(cep2.getClientNodeEdgePoint()
922 .values().stream().findFirst().get().getTopologyUuid())
923 .setNodeUuid(cep2.getClientNodeEdgePoint()
924 .values().stream().findFirst().get().getNodeUuid())
925 .setConnectionEndPointUuid(cep2.getUuid())
927 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
928 .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint> ceps = new HashMap<>();
929 ceps.put(cepServ1.key(), cepServ1);
930 ceps.put(cepServ2.key(), cepServ2);
931 Name connName = new NameBuilder()
932 .setValueName("Connection name")
933 .setValue(String.join("+", "XC", tp1, tp2, qual))
935 // TODO: lower connection, supported link.......
936 return new org.opendaylight.yang.gen.v1.urn
937 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder()
938 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
939 .getBytes(Charset.forName("UTF-8"))).toString()))
940 .setName(Map.of(connName.key(), connName))
941 .setConnectionEndPoint(ceps)
942 .setOperationalState(OperationalState.ENABLED)
943 .setLayerProtocolName(xcProtocol)
944 .setLifecycleState(LifecycleState.INSTALLED)
945 .setDirection(ForwardingDirection.BIDIRECTIONAL)
949 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
950 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
951 Name cepName = new NameBuilder()
952 .setValueName("ConnectionEndPoint name")
953 .setValue(String.join("+", id.split("\\+")[0], qualifier,
956 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
957 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
958 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
960 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
961 qualifier)).getBytes(Charset.forName("UTF-8")))
963 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
964 .getBytes(Charset.forName("UTF-8"))).toString()))
966 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
967 // TODO: add parent ONEP??
968 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
969 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
970 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
972 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
973 .setName(Map.of(cepName.key(), cepName))
974 .setConnectionPortRole(PortRole.SYMMETRIC)
975 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
976 .setOperationalState(OperationalState.ENABLED)
977 .setLifecycleState(LifecycleState.INSTALLED)
978 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
979 return cepBldr.build();
982 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
983 LayerProtocolName cepProtocol) {
984 Name cepName = new NameBuilder()
985 .setValueName("ConnectionEndPoint name")
986 .setValue(String.join("+", id.split("\\+")[0], qualifier,
989 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
990 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
991 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
993 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
994 nodeLayer)).getBytes(Charset.forName("UTF-8")))
996 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
997 .getBytes(Charset.forName("UTF-8"))).toString()))
999 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1000 // TODO: add parent ONEP??
1001 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1002 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1003 qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8")))
1005 .setClientNodeEdgePoint(Map.of(cnep.key(), cnep))
1006 .setName(Map.of(cepName.key(), cepName))
1007 .setConnectionPortRole(PortRole.SYMMETRIC)
1008 .setConnectionPortDirection(PortDirection.BIDIRECTIONAL)
1009 .setOperationalState(OperationalState.ENABLED)
1010 .setLifecycleState(LifecycleState.INSTALLED)
1011 .setLayerProtocolName(cepProtocol);
1012 return cepBldr.build();
1015 private EndPoint mapServiceZEndPoint(
1016 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd
1017 serviceZEnd, PathDescription pathDescription) {
1018 EndPointBuilder endPointBuilder = new EndPointBuilder();
1019 // 1. Service Format: ODU, OTU, ETH
1020 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1021 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1022 // Identify SIP name
1023 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1024 LOG.info("Uuid of z end {}", sipUuid);
1025 LayerProtocolName layerProtocols = null;
1026 // Layer protocol name
1027 switch (serviceFormat) {
1029 layerProtocols = LayerProtocolName.DSR;
1033 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1036 layerProtocols = LayerProtocolName.ODU;
1039 LOG.error("Service Format not supported");
1041 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1042 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1043 .setValueName("OpenROADM node id")
1044 .setValue(serviceZEnd.getTxDirection().getPort().getPortDeviceName())
1046 return endPointBuilder
1047 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1048 .setServiceInterfacePointUuid(sipUuid)
1050 .setName(Map.of(name.key(), name))
1051 .setAdministrativeState(AdministrativeState.UNLOCKED)
1052 .setDirection(PortDirection.BIDIRECTIONAL)
1053 .setLifecycleState(LifecycleState.INSTALLED)
1054 .setOperationalState(OperationalState.ENABLED)
1055 .setLayerProtocolName(layerProtocols)
1056 .setCapacity(new CapacityBuilder()
1057 .setTotalSize(new TotalSizeBuilder()
1058 .setValue(Uint64.valueOf(serviceZEnd.getServiceRate()))
1059 .setUnit(CapacityUnit.GBPS)
1061 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1063 .setProtectionRole(ProtectionRole.WORK)
1064 .setRole(PortRole.SYMMETRIC)
1065 .setLocalId(serviceZEnd.getTxDirection().getPort().getPortDeviceName())
1069 private EndPoint mapServiceAEndPoint(
1070 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd
1071 serviceAEnd, PathDescription pathDescription) {
1072 EndPointBuilder endPointBuilder = new EndPointBuilder();
1073 // 1. Service Format: ODU, OTU, ETH
1074 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1075 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1076 // Identify SIP name
1077 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1078 LOG.info("Uuid of a end {}", sipUuid);
1079 LayerProtocolName layerProtocols = null;
1080 // Layer protocol name
1081 switch (serviceFormat) {
1083 layerProtocols = LayerProtocolName.DSR;
1087 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1090 layerProtocols = LayerProtocolName.ODU;
1093 LOG.error("Service Format not supported");
1095 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name =
1096 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder()
1097 .setValueName("OpenROADM node id")
1098 .setValue(serviceAEnd.getTxDirection().getPort().getPortDeviceName())
1100 return endPointBuilder
1101 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1102 .setServiceInterfacePointUuid(sipUuid)
1104 .setName(Map.of(name.key(), name))
1105 .setAdministrativeState(AdministrativeState.UNLOCKED)
1106 .setDirection(PortDirection.BIDIRECTIONAL)
1107 .setLifecycleState(LifecycleState.INSTALLED)
1108 .setOperationalState(OperationalState.ENABLED)
1109 .setLayerProtocolName(layerProtocols)
1110 .setCapacity(new CapacityBuilder()
1111 .setTotalSize(new TotalSizeBuilder()
1112 .setValue(Uint64.valueOf(serviceAEnd.getServiceRate()))
1113 .setUnit(CapacityUnit.GBPS)
1115 .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1117 .setProtectionRole(ProtectionRole.WORK)
1118 .setRole(PortRole.SYMMETRIC)
1119 .setLocalId(serviceAEnd.getTxDirection().getPort().getPortDeviceName())
1123 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1124 Uuid zendUuid = null;
1125 if (serviceNodeId.contains("ROADM")) {
1126 // Service from ROADM to ROADM
1127 // AddDrop-AddDrop ports --> MC layer SIPs
1128 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1129 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1130 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1131 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1133 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1134 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1135 if (!sip.getUuid().equals(sipUuid)) {
1136 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1139 zendUuid = sip.getUuid();
1143 // Service from XPDR to XPDR
1145 TerminationPoint tp;
1147 switch (serviceFormat) {
1149 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1150 tp = (TerminationPoint) firstElement.getResource().getResource();
1151 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1152 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1153 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1155 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1159 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get();
1160 tp = (TerminationPoint) firstElement.getResource().getResource();
1161 // Network-Network ports --> iOTSi layer SIPs
1162 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1163 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1165 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1169 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1170 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get();
1171 tp = (TerminationPoint) firstElement.getResource().getResource();
1172 // Client-client ports --> DSR layer SIPs
1173 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1174 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1176 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1181 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1183 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1184 if (!sip.getUuid().equals(sipUuid)) {
1185 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1188 zendUuid = sip.getUuid();
1195 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1196 Uuid aendUuid = null;
1197 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1198 LOG.info("Map a to z = {}", mapatoz);
1199 if (serviceNodeId.contains("ROADM")) {
1200 // Service from ROADM to ROADM
1201 // AddDrop-AddDrop ports --> MC layer SIPs
1202 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1203 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1204 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1205 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1206 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1208 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1210 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1211 if (!sip.getUuid().equals(sipUuid)) {
1212 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1215 aendUuid = sip.getUuid();
1219 // Service from XPDR to XPDR
1221 TerminationPoint tp;
1223 switch (serviceFormat) {
1225 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1226 tp = (TerminationPoint) firstElement.getResource().getResource();
1227 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1228 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1229 tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1231 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1232 TapiStringConstants.I_ODU, tp.getTpId()));
1235 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get();
1236 tp = (TerminationPoint) firstElement.getResource().getResource();
1237 // Network-Network ports --> iOTSi layer SIPs
1238 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1239 tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1241 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1242 TapiStringConstants.I_OTSI, tp.getTpId()));
1245 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1246 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get();
1247 tp = (TerminationPoint) firstElement.getResource().getResource();
1248 // Client-client ports --> DSR layer SIPs
1249 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1250 tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8")))
1252 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1253 TapiStringConstants.DSR, tp.getTpId()));
1257 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1259 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1260 if (!sip.getUuid().equals(sipUuid)) {
1261 LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1264 aendUuid = sip.getUuid();
1271 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1272 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1273 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1274 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1275 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1276 .getBytes(Charset.forName("UTF-8"))).toString());
1277 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1278 .getBytes(Charset.forName("UTF-8"))).toString());
1279 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1280 .getBytes(Charset.forName("UTF-8"))).toString());
1281 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1284 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1285 ConnectionEndPoint cep) {
1286 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1287 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1288 .getBytes(Charset.forName("UTF-8"))).toString());
1289 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1290 .getBytes(Charset.forName("UTF-8"))).toString());
1291 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1292 .getBytes(Charset.forName("UTF-8"))).toString());
1293 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1296 public Map<org.opendaylight.yang.gen.v1.urn
1297 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
1298 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
1299 getConnectionFullMap() {
1300 return this.connectionFullMap;
1303 private String getIdBasedOnModelVersion(String nodeid) {
1304 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1305 nodeid.split("-")[1]) : nodeid.split("-")[0];
1308 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
1309 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
1310 Map<org.opendaylight.yang.gen.v1.urn
1311 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPointKey,
1312 org.opendaylight.yang.gen.v1.urn
1313 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint>
1314 endPointMap = input.getEndPoint();
1315 ConnectivityConstraint constraint = input.getConnectivityConstraint();
1316 ConnectionType connType = null;
1317 ServiceFormat serviceFormat = null;
1318 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1319 TapiStringConstants.DSR);
1320 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1321 TapiStringConstants.DSR);
1322 LOG.debug("Node a = {}", nodeAid);
1323 LOG.debug("Node z = {}", nodeZid);
1324 switch (constraint.getServiceLayer().getIntValue()) {
1327 connType = ConnectionType.Infrastructure;
1328 serviceFormat = ServiceFormat.ODU;
1331 LOG.info("ETH, no need to create OTU and ODU");
1332 connType = ConnectionType.Service;
1333 serviceFormat = ServiceFormat.Ethernet;
1336 LOG.info("DSR, need to create OTU and ODU");
1337 connType = ConnectionType.Service;
1338 serviceFormat = ServiceFormat.Ethernet;
1341 LOG.info("PHOTONIC");
1342 connType = getConnectionTypePhtnc(endPointMap.values());
1343 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
1344 if (serviceFormat.equals(ServiceFormat.OC)) {
1345 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1346 TapiStringConstants.PHTNC_MEDIA);
1347 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1348 TapiStringConstants.PHTNC_MEDIA);
1350 nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(),
1351 TapiStringConstants.OTSI);
1352 nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(),
1353 TapiStringConstants.OTSI);
1355 LOG.debug("Node a photonic = {}", nodeAid);
1356 LOG.debug("Node z photonic = {}", nodeZid);
1359 LOG.info("Service type {} not supported", constraint.getServiceLayer().getName());
1361 // Requested Capacity for connectivity service
1362 Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue();
1363 // map endpoints into service end points. Map the type of service from TAPI to OR
1364 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().get(),
1365 serviceFormat, nodeAid, capacity, constraint.getServiceLayer());
1366 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(),
1367 serviceFormat, nodeZid, capacity, constraint.getServiceLayer());
1368 if (serviceAEnd == null || serviceZEnd == null) {
1369 LOG.error("Couldnt map endpoints to service end");
1372 LOG.info("Service a end = {}", serviceAEnd);
1373 LOG.info("Service z end = {}", serviceZEnd);
1374 return new ServiceCreateInputBuilder()
1375 .setServiceAEnd(serviceAEnd)
1376 .setServiceZEnd(serviceZEnd)
1377 .setConnectionType(connType)
1378 .setServiceName(serviceUuid.getValue())
1379 .setCommonId("common id")
1380 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
1381 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
1382 .setRequestSystemId("appname")
1384 .setCustomer("customer")
1385 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
1386 .setOperatorContact("pw1234")
1390 private ServiceZEnd tapiEndPointToServiceZPoint(
1391 org.opendaylight.yang.gen.v1.urn
1392 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1393 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1394 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1395 // Not the rest which is needed in the txPortDeviceName.
1396 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1397 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1398 // Todo -> need to find the NEP associated to that SIP
1399 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString());
1400 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1401 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1403 LOG.error("Node not found in datastore");
1406 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1407 // connection is between 2 CLIENT ports. Otherwise it will not work...
1408 OwnedNodeEdgePoint nep = null;
1409 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1410 if (onep.getMappedServiceInterfacePoint() == null) {
1413 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1419 LOG.error("Nep not found in datastore");
1422 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1423 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1424 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1425 String txPortDeviceName = nepName.split("\\+")[0];
1426 String txPortName = nepName.split("\\+")[2];
1427 String rxPortDeviceName = txPortDeviceName;
1428 String rxPortName = txPortName;
1429 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1430 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1431 if (serviceFormat.equals(ServiceFormat.ODU)) {
1432 // TODO --> populate network map
1433 populateNetworkMap(nodeid, txPortName);
1435 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1436 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1437 // Set boolean to true and update txportName and so on
1438 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1439 if (updTxName != null) {
1440 txPortName = updTxName;
1441 rxPortName = txPortName;
1444 // TODO --> get clli from datastore?
1445 String clli = "NodeSC";
1446 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1447 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1448 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1450 .setNodeId(new NodeIdType(nodeid))
1451 .setOpticType(OpticTypes.Gray)
1452 .setServiceFormat(serviceFormat)
1453 .setServiceRate(Uint32.valueOf(capacity))
1454 .setTxDirection(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")
1469 .setRxDirection(new RxDirectionBuilder()
1470 .setPort(new PortBuilder()
1471 .setPortDeviceName(rxPortDeviceName)
1472 .setPortName(rxPortName)
1473 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1475 .setPortType(TapiStringConstants.PORT_TYPE)
1477 .setLgx(new LgxBuilder()
1478 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1479 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1480 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1481 .setLgxPortShelf("00")
1484 if (serviceFormat.equals(ServiceFormat.ODU)) {
1485 serviceZEndBuilder.setOduServiceRate(ODU4.class);
1487 if (serviceFormat.equals(ServiceFormat.OTU)) {
1488 serviceZEndBuilder.setOtuServiceRate(OTU4.class);
1490 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1492 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(new org.opendaylight.yang.gen.v1.http
1493 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1494 .setCommittedBurstSize(Uint16.valueOf(64))
1495 .setCommittedInfoRate(Uint32.valueOf(100000))
1499 return serviceZEndBuilder.build();
1502 private ServiceAEnd tapiEndPointToServiceAPoint(
1503 org.opendaylight.yang.gen.v1.urn
1504 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint,
1505 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1506 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1507 // Not the rest which is needed in the txPortDeviceName.
1508 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1509 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1510 // Todo -> need to find the NEP associated to that SIP
1511 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString());
1512 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node =
1513 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1515 LOG.error("Node not found in datastore");
1518 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1519 // connection is between 2 CLIENT ports. Otherwise it will not work...
1520 OwnedNodeEdgePoint nep = null;
1521 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1522 if (onep.getMappedServiceInterfacePoint() == null) {
1525 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1531 LOG.error("Nep not found in datastore");
1534 String nodeName = endPoint.getName().values().stream().findFirst().get().getValue();
1535 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1536 String nepName = nep.getName().values().stream().findFirst().get().getValue();
1537 String txPortDeviceName = nepName.split("\\+")[0];
1538 String txPortName = nepName.split("\\+")[2];
1539 String rxPortDeviceName = txPortDeviceName;
1540 String rxPortName = txPortName;
1541 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1542 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1543 if (serviceFormat.equals(ServiceFormat.ODU)) {
1544 // TODO --> populate network map
1545 populateNetworkMap(nodeid, txPortName);
1547 if (serviceFormat.equals(ServiceFormat.Ethernet)) {
1548 // TODO --> choose from network Map un network port which hasnt been used yet by another service.
1549 // Set boolean to true and update txportName and so on
1550 String updTxName = findFreeConfiguredNetworkPort(nodeid);
1551 if (updTxName != null) {
1552 txPortName = updTxName;
1553 rxPortName = txPortName;
1556 // TODO --> get clli from datastore?
1557 String clli = "NodeSA";
1558 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1559 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1560 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1562 .setNodeId(new NodeIdType(nodeid))
1563 .setOpticType(OpticTypes.Gray)
1564 .setServiceFormat(serviceFormat)
1565 .setServiceRate(Uint32.valueOf(capacity))
1566 .setTxDirection(new TxDirectionBuilder()
1567 .setPort(new PortBuilder()
1568 .setPortDeviceName(txPortDeviceName)
1569 .setPortName(txPortName)
1570 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1572 .setPortType(TapiStringConstants.PORT_TYPE)
1574 .setLgx(new LgxBuilder()
1575 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1576 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1577 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1578 .setLgxPortShelf("00")
1581 .setRxDirection(new RxDirectionBuilder()
1582 .setPort(new PortBuilder()
1583 .setPortDeviceName(rxPortDeviceName)
1584 .setPortName(rxPortName)
1585 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1587 .setPortType(TapiStringConstants.PORT_TYPE)
1589 .setLgx(new LgxBuilder()
1590 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1591 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1592 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1593 .setLgxPortShelf("00")
1596 if (serviceFormat.equals(ServiceFormat.ODU)) {
1597 serviceAEndBuilder.setOduServiceRate(ODU4.class);
1599 if (serviceFormat.equals(ServiceFormat.OTU)) {
1600 serviceAEndBuilder.setOtuServiceRate(OTU4.class);
1602 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1604 .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla(new org.opendaylight.yang.gen.v1.http
1605 .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder()
1606 .setCommittedBurstSize(Uint16.valueOf(64))
1607 .setCommittedInfoRate(Uint32.valueOf(100000))
1611 return serviceAEndBuilder.build();
1614 private String findFreeConfiguredNetworkPort(String nodeid) {
1615 if (!this.networkMap.containsKey(nodeid)) {
1618 Map<String, Boolean> netMap = this.networkMap.get(nodeid);
1619 for (Map.Entry<String, Boolean> entry : netMap.entrySet()) {
1620 if (!entry.getValue()) {
1621 this.networkMap.get(nodeid).put(entry.getKey(), true);
1622 return entry.getKey();
1628 private void populateNetworkMap(String nodeid, String txPortName) {
1629 Map<String, Boolean> netMap = new HashMap<>();
1630 netMap.put(txPortName, false);
1631 if (!this.networkMap.containsKey(nodeid)) {
1632 this.networkMap.put(nodeid, netMap);
1633 } else if (!this.networkMap.get(nodeid).containsKey(txPortName)) {
1634 this.networkMap.get(nodeid).putAll(netMap);
1638 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1639 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1640 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1641 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1642 // EndPoints are ROADMs
1643 return ConnectionType.RoadmLine;
1645 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1646 return ConnectionType.Infrastructure;
1649 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1650 .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
1651 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1652 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1653 // EndPoints are ROADMs
1654 return ServiceFormat.OC;
1656 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1657 return ServiceFormat.OTU;
1660 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1661 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1662 TapiStringConstants.DSR).getBytes(Charset.forName("UTF-8")))).toString());
1663 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1664 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(Charset.forName("UTF-8"))))
1666 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1667 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1668 .getBytes(Charset.forName("UTF-8"))).toString());
1669 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1672 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1673 for (String networkPort:xpdrNetworkTplist) {
1674 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1681 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1682 List<String> clientPortList = new ArrayList<>();
1683 for (String networkPort:xpdrNetworkTplist) {
1684 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1685 networkPort.split("\\+")[0].split("-")[1]);
1686 String tpId = networkPort.split("\\+")[1];
1687 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1688 .child(Nodes.class, new NodesKey(nodeId))
1689 .child(Mapping.class, new MappingKey(tpId)).build();
1691 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1693 if (!optMapping.isPresent()) {
1694 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1696 Mapping mapping = optMapping.get();
1697 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1698 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1699 mapping.getConnectionMapLcp());
1700 LOG.info("Key to be added to list = {}", key);
1701 if (!clientPortList.contains(key)) {
1702 clientPortList.add(key);
1704 } catch (InterruptedException | ExecutionException e) {
1705 LOG.error("Couldnt read mapping from datastore", e);
1710 return clientPortList;
1713 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1714 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1715 for (String xpdrNode:xpdrNodelist) {
1716 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.DSR))
1717 .getBytes(Charset.forName("UTF-8"))).toString());
1718 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1719 .onf.otcc.yang.tapi.topology.rev181210.topology.Node> nodeIID = InstanceIdentifier.builder(
1720 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1721 .onf.otcc.yang.tapi.topology.rev181210.Context1.class).child(TopologyContext.class)
1722 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1723 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
1724 new NodeKey(nodeUuid)).build();
1726 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> optNode
1727 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1728 if (!optNode.isPresent()) {
1731 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.get().getName().get(
1732 new NameKey("Node Type")).getValue()).get();
1733 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1734 openroadmNodeTypeList.add(openroadmNodeType);
1736 } catch (InterruptedException | ExecutionException e) {
1737 LOG.error("Couldnt read node in topology", e);
1741 // TODO for now check that there is only one type, otherwise error
1742 if (openroadmNodeTypeList.size() != 1) {
1743 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1746 return openroadmNodeTypeList.get(0);