2 * Copyright © 2018 Orange & 2021 Nokia, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.tapi.connectivity;
10 import java.math.BigDecimal;
11 import java.nio.charset.Charset;
12 import java.nio.charset.StandardCharsets;
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.Comparator;
16 import java.util.HashMap;
17 import java.util.List;
19 import java.util.Optional;
20 import java.util.UUID;
21 import java.util.concurrent.ExecutionException;
22 import java.util.stream.Collectors;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
25 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
26 import org.opendaylight.transportpce.tapi.TapiStringConstants;
27 import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint;
28 import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType;
29 import org.opendaylight.transportpce.tapi.utils.TapiContext;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingKey;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.NodesKey;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev191129.OpticTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.Service;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ethernet.subrate.attributes.grp.EthernetAttributesBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionKey;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.lgx.LgxBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth.sla.SubrateEthSlaBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OTU4;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEnd;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEndBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEnd;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEndBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
62 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToAKey;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.TotalSizeBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ProtectionRole;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointKey;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.Connection;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionKey;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.CapacityBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.ServiceInterfacePointBuilder;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
121 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
122 import org.opendaylight.yangtools.yang.common.Decimal64;
123 import org.opendaylight.yangtools.yang.common.Uint16;
124 import org.opendaylight.yangtools.yang.common.Uint32;
125 import org.opendaylight.yangtools.yang.common.Uint64;
126 import org.opendaylight.yangtools.yang.common.Uint8;
127 import org.slf4j.Logger;
128 import org.slf4j.LoggerFactory;
130 public final class ConnectivityUtils {
132 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
133 .getBytes(StandardCharsets.UTF_8)).toString());
134 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
136 private final ServiceDataStoreOperations serviceDataStoreOperations;
137 private final TapiContext tapiContext;
138 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
140 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
141 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
142 connectionFullMap; // this variable is for complete connection objects
143 private final NetworkTransactionService networkTransactionService;
144 private Connection topConnRdmRdm;
145 private Connection topConnXpdrXpdrPhtn;
146 private Connection topConnXpdrXpdrOdu;
148 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
149 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
150 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
151 NetworkTransactionService networkTransactionService) {
152 this.serviceDataStoreOperations = serviceDataStoreOperations;
153 this.tapiContext = tapiContext;
154 this.sipMap = sipMap;
155 this.connectionFullMap = new HashMap<>();
156 this.networkTransactionService = networkTransactionService;
157 this.topConnRdmRdm = null;
158 this.topConnXpdrXpdrPhtn = null;
159 this.topConnXpdrXpdrOdu = null;
162 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
163 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
164 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
165 if (serviceAEnd == null || serviceZEnd == null) {
166 LOG.warn("One of the endpoints could not be identified");
169 return new ServiceCreateInputBuilder()
170 .setCommonId("commonId")
171 .setConnectionType(ConnectionType.Service)
172 .setCustomer("Customer")
173 .setServiceName("service test")
174 .setServiceAEnd(serviceAEnd)
175 .setServiceZEnd(serviceZEnd)
176 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
177 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
183 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
184 String txPortName, String rxPortDeviceName, String rxPortName) {
185 return new ServiceAEndBuilder()
187 .setNodeId(new NodeIdType(nodeid))
188 .setOpticType(OpticTypes.Gray)
189 .setServiceFormat(ServiceFormat.Ethernet)
190 .setServiceRate(Uint32.valueOf(100))
191 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
192 .setPort(new PortBuilder()
193 .setPortDeviceName(txPortDeviceName)
194 .setPortName(txPortName)
195 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
197 .setPortType(TapiStringConstants.PORT_TYPE)
199 .setLgx(new LgxBuilder()
200 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
201 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
202 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
203 .setLgxPortShelf("00")
206 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
207 .setPort(new PortBuilder()
208 .setPortDeviceName(rxPortDeviceName)
209 .setPortName(rxPortName)
210 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
212 .setPortType(TapiStringConstants.PORT_TYPE)
214 .setLgx(new LgxBuilder()
215 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
216 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
217 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
218 .setLgxPortShelf("00")
224 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
225 String txPortName, String rxPortDeviceName, String rxPortName) {
226 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
227 .setOpticType(OpticTypes.Gray)
228 .setServiceFormat(ServiceFormat.Ethernet)
229 .setServiceRate(Uint32.valueOf(100))
230 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
231 .setPort(new PortBuilder()
232 .setPortDeviceName(txPortDeviceName)
233 .setPortName(txPortName)
234 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
236 .setPortType(TapiStringConstants.PORT_TYPE)
238 .setLgx(new LgxBuilder()
239 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
240 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
241 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
242 .setLgxPortShelf("00")
245 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
246 .setPort(new PortBuilder()
247 .setPortDeviceName(rxPortDeviceName)
248 .setPortName(rxPortName)
249 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
251 .setPortType(TapiStringConstants.PORT_TYPE)
253 .setLgx(new LgxBuilder()
254 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
255 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
256 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
257 .setLgxPortShelf("00")
263 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.orElseThrow();
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.rev230526.service.ServiceAEnd serviceAEnd
280 = service.getServiceAEnd();
282 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
283 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.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(pathDescription, mapServiceLayerToAend(serviceAEnd));
296 LOG.debug("connectionMap for service {} = {} ", name.toString(), connMap.toString());
297 ConnectivityConstraint conConstr =
298 new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build();
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(StandardCharsets.UTF_8))
306 .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
307 .setConnectivityConstraint(conConstr)
308 .setDirection(ForwardingDirection.BIDIRECTIONAL)
309 .setName(Map.of(name.key(), name))
310 .setConnection(connMap)
311 .setEndPoint(endPointMap)
315 public Map<ConnectionKey, Connection> createConnectionsFromService(PathDescription pathDescription,
316 LayerProtocolName lpn) {
317 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
318 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
319 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
320 // and the connections
322 List<String> xpdrClientTplist = new ArrayList<>();
323 List<String> xpdrNetworkTplist = new ArrayList<>();
324 List<String> rdmAddDropTplist = new ArrayList<>();
325 List<String> rdmDegTplist = new ArrayList<>();
326 List<String> rdmNodelist = new ArrayList<>();
327 List<String> xpdrNodelist = new ArrayList<>();
328 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
329 .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
330 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
331 switch (resourceType) {
332 case TapiStringConstants.TP:
333 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
334 String tpID = tp.getTpId();
336 if (tpID.contains("CLIENT")) {
337 tpNode = tp.getTpNodeId();
338 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
339 xpdrClientTplist.add(String.join("+", tpNode, tpID));
342 if (tpID.contains("NETWORK")) {
343 tpNode = tp.getTpNodeId();
344 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
345 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
348 if (tpID.contains("PP")) {
349 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
350 LOG.info("ROADM Node of tp = {}", tpNode);
351 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
352 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
355 if (tpID.contains("TTP")) {
356 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
357 LOG.info("ROADM Node of tp = {}", tpNode);
358 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
359 rdmDegTplist.add(String.join("+", tpNode, tpID));
363 case TapiStringConstants.NODE:
364 Node node = (Node) elem.getResource().getResource();
365 String nodeId = node.getNodeId();
366 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
367 LOG.info("Node id = {}", nodeId);
368 if (!xpdrNodelist.contains(nodeId)) {
369 xpdrNodelist.add(nodeId); // should contain only 2
372 if (nodeId.contains("ROADM")) {
373 nodeId = getIdBasedOnModelVersion(nodeId);
374 LOG.info("Node id = {}", nodeId);
375 if (!rdmNodelist.contains(nodeId)) {
376 rdmNodelist.add(nodeId);
381 LOG.warn("Resource is a {}", resourceType);
384 LOG.info("ROADM node list = {}", rdmNodelist);
385 LOG.info("ROADM degree list = {}", rdmDegTplist);
386 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
387 LOG.info("XPDR node list = {}", xpdrNodelist);
388 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
389 LOG.info("XPDR client list = {}", xpdrClientTplist);
390 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
391 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
392 // to trigger all the steps or not
393 String edgeRoadm1 = "";
394 String edgeRoadm2 = "";
395 if (!rdmNodelist.isEmpty()) {
396 edgeRoadm1 = rdmNodelist.get(0);
397 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
398 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
399 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
401 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
402 // CEPs must be included in the topology context as an augmentation for each ONEP!!
403 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
404 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
405 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
406 // this needs to be changed
407 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
408 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
411 // Identify number of ROADMs
412 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
413 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
414 // - Top Connection MC betwwen MC CEPs of different roadms
415 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
416 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
417 edgeRoadm1, edgeRoadm2));
418 if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
419 .contains("ROADM")) {
420 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
421 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
422 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
424 this.topConnRdmRdm = null;
427 // TODO: verify if this is correct
428 // - XC Connection OTSi betwwen iODU and eODU of xpdr
429 // - Top connection in the ODU layer, between xpdr eODU ports (?)
430 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
431 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
432 this.topConnXpdrXpdrPhtn = null;
436 // Check if OC, OTU and ODU are created
437 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
438 LOG.info("WDM ETH service");
439 connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
440 edgeRoadm1, edgeRoadm2));
441 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
442 this.topConnRdmRdm = null;
443 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
444 LOG.info("Associated client ports = {}", xpdrClientTplist);
445 connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
447 this.topConnXpdrXpdrPhtn = null;
451 LOG.info("OTN XGE/ODUe service");
452 // - XC connection between iODU and eODU
453 // - Top connection between eODU ports
454 // - Top connection between DSR ports
455 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
456 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
457 // - XC Connection OTSi between iODU and eODU of xpdr
458 // - Top connection in the ODU layer, between xpdr eODU ports (?)
459 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
461 this.topConnXpdrXpdrPhtn = null;
463 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
464 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
465 connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
467 this.topConnXpdrXpdrOdu = null;
471 LOG.error("Service type format not supported");
473 LOG.debug("CONNSERVERMAP = {}", connectionServMap.toString());
474 return connectionServMap;
477 public void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) {
478 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
479 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
480 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
481 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class)
482 .child(Topology.class, new TopologyKey(topoUuid))
483 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
484 new NodeKey(nodeUuid))
485 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
488 Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
489 LogicalDatastoreType.OPERATIONAL, onepIID).get();
490 if (optionalOnep.isPresent()) {
491 LOG.error("ONEP is already present in datastore");
494 // merge in datastore
495 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
497 this.networkTransactionService.commit().get();
498 LOG.info("NEP {} added successfully.", onep.getName().toString());
499 } catch (InterruptedException | ExecutionException e) {
500 LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName().toString(), e);
504 public Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
505 .connectivity.context.ConnectionKey,
506 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
507 .connectivity.context.Connection> getConnectionFullMap() {
508 return this.connectionFullMap;
511 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
512 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
513 Map<org.opendaylight.yang.gen.v1.urn
514 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
515 org.opendaylight.yang.gen.v1.urn
516 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint>
517 endPointMap = input.getEndPoint();
518 ConnectionType connType = null;
519 ServiceFormat serviceFormat = null;
520 String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
521 TapiStringConstants.XPDR);
522 String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
523 TapiStringConstants.XPDR);
524 LOG.info("NodeAid = {}", nodeAid);
525 LOG.info("NodeZid = {}", nodeZid);
526 //switch (constraint.getServiceLayer().getIntValue()) {
527 switch (input.getLayerProtocolName().getIntValue()) {
530 connType = ConnectionType.Infrastructure;
531 serviceFormat = ServiceFormat.ODU;
534 LOG.info("ETH, no need to create OTU and ODU");
535 connType = ConnectionType.Service;
536 serviceFormat = ServiceFormat.Ethernet;
539 LOG.info("DSR, need to create OTU and ODU");
540 connType = ConnectionType.Service;
541 serviceFormat = ServiceFormat.Ethernet;
544 LOG.info("PHOTONIC");
545 connType = getConnectionTypePhtnc(endPointMap.values());
546 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
547 LOG.debug("Node a photonic = {}", nodeAid);
548 LOG.debug("Node z photonic = {}", nodeZid);
551 LOG.info("Service type {} not supported", input.getLayerProtocolName().getName());
553 // Requested Capacity for connectivity service
554 Uint64 capacity = Uint64.valueOf(Math.abs(
555 input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
556 // map endpoints into service end points. Map the type of service from TAPI to OR
557 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
558 serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
559 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
560 .orElseThrow(), serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
561 if (serviceAEnd == null || serviceZEnd == null) {
562 LOG.error("Couldnt map endpoints to service end");
565 LOG.info("Service a end = {}", serviceAEnd);
566 LOG.info("Service z end = {}", serviceZEnd);
567 return new ServiceCreateInputBuilder()
568 .setServiceAEnd(serviceAEnd)
569 .setServiceZEnd(serviceZEnd)
570 .setConnectionType(connType)
571 .setServiceName(serviceUuid.getValue())
572 .setCommonId("common id")
573 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
574 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
575 .setRequestSystemId("appname")
577 .setCustomer("customer")
578 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
579 .setOperatorContact("pw1234")
583 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
584 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
585 return new ServiceAEndBuilder(sepA.getValue()).build();
587 if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
588 return new ServiceAEndBuilder(sepZ.getValue()).build();
593 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
594 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
595 return new ServiceZEndBuilder(sepA.getValue()).build();
597 if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
598 return new ServiceZEndBuilder(sepZ.getValue()).build();
603 private LayerProtocolName mapServiceLayerToAend(
604 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
606 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
607 switch (serviceFormat) {
610 return LayerProtocolName.PHOTONICMEDIA;
612 return LayerProtocolName.ODU;
614 if (getOpenroadmType(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
615 .getPortDeviceName()).equals(OpenroadmNodeType.TPDR)) {
616 return LayerProtocolName.ETH;
618 return LayerProtocolName.DSR;
620 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
625 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
626 switch (serviceFormat) {
629 return LayerProtocolName.PHOTONICMEDIA;
631 return LayerProtocolName.ODU;
633 String node1 = endPoint1.getLocalId();
634 String node2 = endPoint2.getLocalId();
635 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
636 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
637 return LayerProtocolName.ETH;
639 return LayerProtocolName.DSR;
641 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
646 private OpenroadmNodeType getOpenroadmType(String nodeName) {
647 LOG.info("Node name = {}", nodeName);
648 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.XPDR))
649 .getBytes(StandardCharsets.UTF_8)).toString());
650 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode
651 = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
652 if (tapiNode != null) {
653 return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
659 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
660 List<String> xpdrNodelist,
661 Map<ConnectionKey, Connection> lowerConn) {
662 // TODO: do we need to create cross connection between iODU and eODU??
663 // add the lower connections of the previous steps for this kind of service
664 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
665 for (Connection lowConn: lowerConn.values()) {
666 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
667 xcMap.put(conn.key(), conn);
669 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
670 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
671 ConnectionEndPoint> cepMapDsr = new HashMap<>();
672 // Create 1 cep per Xpdr in the CLIENT
673 // 1 top connection DSR between the CLIENT xpdrs
674 for (String xpdr:xpdrNodelist) {
675 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
676 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
678 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
679 LayerProtocolName.DSR);
680 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR,
681 TapiStringConstants.XPDR, netCep1);
683 cepMapDsr.put(netCep1.key(), netCep1);
685 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
686 .get(0))).findFirst().orElseThrow();
687 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
688 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
690 // DSR top connection between edge xpdr CLIENT DSR
691 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
692 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
693 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
694 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
696 // DSR top connection that will be added to the service object
697 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
698 connServMap.put(conn1.key(), conn1);
703 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
704 List<String> xpdrNetworkTplist,
705 List<String> xpdrNodelist) {
706 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
707 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
708 ConnectionEndPoint> cepMapDsr = new HashMap<>();
709 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
710 ConnectionEndPoint> cepMapOdu = new HashMap<>();
711 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
712 // be added to the lower connection of a top connection
713 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
715 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
716 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
717 for (String xpdr:xpdrNodelist) {
718 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
719 String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
721 ConnectionEndPoint clientCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR,
722 TapiStringConstants.XPDR, LayerProtocolName.DSR);
723 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
726 ConnectionEndPoint clientCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
727 TapiStringConstants.XPDR, LayerProtocolName.ODU);
728 putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR,
731 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
732 ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
734 cepMapDsr.put(clientCep1.key(), clientCep1);
735 cepMapOdu.put(clientCep2.key(), clientCep2);
736 // Create x connection between I_ODU and E_ODU within xpdr
737 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
738 connection = createXCBetweenCeps(clientCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
739 TapiStringConstants.ODU, LayerProtocolName.ODU);
740 this.connectionFullMap.put(connection.key(), connection);
742 // Create X connection that will be added to the service object
743 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
744 xcMap.put(conn.key(), conn);
747 // DSR top connection between edge xpdr CLIENT DSR
748 String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
749 .get(0))).findFirst().orElseThrow();
750 String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
751 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
753 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
754 connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
755 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
756 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
758 // ODU top connection that will be added to the service object
759 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
760 connServMap.put(conn.key(), conn);
761 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
762 xcMap.put(lowerConn.key(), lowerConn);
764 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
765 connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
766 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
767 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
769 // DSR top connection that will be added to the service object
770 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
771 connServMap.put(conn1.key(), conn1);
776 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
777 List<String> xpdrNodelist) {
778 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
779 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
780 ConnectionEndPoint> cepMap = new HashMap<>();
781 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
782 // be added to the lower connection of a top connection
783 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
785 // Create 1 cep per Xpdr in the I_ODU and a top
786 // connection iODU between the xpdrs
787 for (String xpdr:xpdrNodelist) {
788 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
789 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
791 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
792 TapiStringConstants.XPDR, LayerProtocolName.ODU);
793 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR,
796 cepMap.put(netCep1.key(), netCep1);
799 // ODU top connection between edge xpdr i_ODU
800 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
801 .get(0))).findFirst().orElseThrow();
802 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
803 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
804 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
805 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
806 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
807 this.connectionFullMap.put(connection.key(), connection);
809 // ODU top connection that will be added to the service object
810 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
811 connServMap.put(conn.key(), conn);
812 this.topConnXpdrXpdrOdu = conn;
817 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
818 List<String> xpdrNodelist) {
820 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
821 // be added to the lower connection of a top connection
822 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
823 ConnectionEndPoint> cepMap = new HashMap<>();
824 // create ceps and x connections within xpdr
825 for (String xpdr:xpdrNodelist) {
826 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
827 String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
829 // There should be 1 network tp per xpdr
830 // Just create 2 different CEPs (1 OTS + 1 OTSI_MC)
831 ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
832 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
833 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
834 TapiStringConstants.XPDR, netCep1);
835 ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.OTSI_MC,
836 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
837 putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR,
839 // ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
840 // TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
841 // putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
844 cepMap.put(netCep1.key(), netCep1);
845 cepMap.put(netCep2.key(), netCep2);
846 // cepMap.put(netCep3.key(), netCep3);
850 // OTSi top connection between edge OTSI_MC Xpdr
851 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
852 String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
853 .get(0))).findFirst().orElseThrow();
854 String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
855 .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
856 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
857 connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.OTSI_MC,
858 LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
859 this.connectionFullMap.put(connection.key(), connection);
861 // OTSi top connection that will be added to the service object
862 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
863 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
864 connServMap.put(conn.key(), conn);
865 this.topConnXpdrXpdrPhtn = conn;
870 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
871 List<String> rdmDegTplist,
872 List<String> rdmNodelist,
873 String edgeRoadm1, String edgeRoadm2) {
874 // TODO: will need to check if things exist already or not
875 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
876 ConnectionEndPoint> cepMap = new HashMap<>();
877 // create ceps and x connections within roadm
878 Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
879 for (String roadm : rdmNodelist) {
880 LOG.info("Creating ceps and xc for roadm {}", roadm);
881 if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
882 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
883 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
885 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
886 // There should be only 1 AD and 1 DEG per roadm
887 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
888 // 3 different MC CEPs giving different IDs to show that they are different
889 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
890 // created in the topology creation
891 // add CEPs to the topology to the corresponding ONEP
892 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS);
893 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS, adCep1);
894 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
895 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
896 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
897 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
898 cepMap.put(adCep1.key(), adCep1);
899 cepMap.put(adCep2.key(), adCep2);
900 cepMap.put(adCep3.key(), adCep3);
902 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
903 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
905 ConnectionEndPoint degCep0 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS);
906 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS, degCep0);
907 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS);
908 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS, degCep1);
909 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
910 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
911 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
912 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
913 cepMap.put(degCep0.key(), degCep0);
914 cepMap.put(degCep1.key(), degCep1);
915 cepMap.put(degCep2.key(), degCep2);
916 cepMap.put(degCep3.key(), degCep3);
918 LOG.info("Going to create cross connections for ROADM {}", roadm);
919 // Create X connections between MC and OTSi_MC for full map
920 org.opendaylight.yang.gen.v1.urn
921 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
922 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
923 LayerProtocolName.PHOTONICMEDIA);
924 LOG.info("Cross connection 1 created = {}", connection1.toString());
925 org.opendaylight.yang.gen.v1.urn
926 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
927 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
928 LayerProtocolName.PHOTONICMEDIA);
929 LOG.info("Cross connection 2 created = {}", connection2.toString());
930 this.connectionFullMap.put(connection1.key(), connection1);
931 this.connectionFullMap.put(connection2.key(), connection2);
933 // Create X connections that will be added to the service object
934 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
935 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
937 xcLowerMap.put(conn1.key(), conn1);
938 xcLowerMap.put(conn2.key(), conn2);
940 LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
941 String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
942 LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
944 ConnectionEndPoint deg1Cep0 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS);
945 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS, deg1Cep0);
946 ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS);
947 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS, deg1Cep1);
948 ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC);
949 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2);
950 ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC);
951 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3);
952 cepMap.put(deg1Cep0.key(), deg1Cep0);
953 cepMap.put(deg1Cep1.key(), deg1Cep1);
954 cepMap.put(deg1Cep2.key(), deg1Cep2);
955 cepMap.put(deg1Cep3.key(), deg1Cep3);
957 String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
959 LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
961 ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS);
962 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS, deg2Cep0);
963 ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS);
964 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS, deg2Cep1);
965 ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC);
966 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2);
967 ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC);
968 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3);
969 cepMap.put(deg2Cep0.key(), deg2Cep0);
970 cepMap.put(deg2Cep1.key(), deg2Cep1);
971 cepMap.put(deg2Cep2.key(), deg2Cep2);
972 cepMap.put(deg2Cep3.key(), deg2Cep3);
974 LOG.info("Going to create cross connections for ROADM {}", roadm);
975 // Create X connections between MC and OTSi_MC for full map
976 org.opendaylight.yang.gen.v1.urn
977 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
978 = createXCBetweenCeps(deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
979 TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
980 LOG.info("Cross connection 1 created = {}", connection1.toString());
981 org.opendaylight.yang.gen.v1.urn
982 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
983 = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
984 TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
985 LOG.info("Cross connection 2 created = {}", connection2.toString());
986 this.connectionFullMap.put(connection1.key(), connection1);
987 this.connectionFullMap.put(connection2.key(), connection2);
989 // Create X connections that will be added to the service object
990 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
991 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
993 xcLowerMap.put(conn1.key(), conn1);
994 xcLowerMap.put(conn2.key(), conn2);
997 LOG.info("Going to create top connections between roadms");
998 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
999 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
1000 // MC top connection between edge roadms
1001 LOG.info("Going to created top connection between MC");
1002 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
1003 connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
1004 LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
1005 this.connectionFullMap.put(connection.key(), connection);
1006 LOG.info("Top connection created = {}", connection.toString());
1008 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
1009 // OTSiMC top connections that will be added to the service object
1010 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1011 connServMap.put(conn.key(), conn);
1012 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1013 Map<LowerConnectionKey, LowerConnection> topLowerMap = new HashMap<>();
1014 topLowerMap.put(conn1.key(), conn1);
1016 // OTSiMC top connection between edge roadms
1017 LOG.info("Going to created top connection between OTSiMC");
1018 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
1019 connection1 = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
1020 LayerProtocolName.PHOTONICMEDIA, topLowerMap, null);
1021 this.connectionFullMap.put(connection1.key(), connection1);
1022 LOG.info("Top connection created = {}", connection1.toString());
1024 // OTSiMC top connections that will be added to the service object
1025 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1026 connServMap.put(conn2.key(), conn2);
1027 this.topConnRdmRdm = conn2;
1031 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
1032 createTopConnection(String tp1, String tp2,
1033 Map<org.opendaylight.yang.gen.v1.urn
1034 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
1035 ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
1036 Map<LowerConnectionKey, LowerConnection> xcMap, Connection additionalLowerConn) {
1037 // find cep for each AD MC of roadm 1 and 2
1038 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
1039 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 =
1040 cepMap.get(new org.opendaylight.yang.gen.v1.urn
1041 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
1042 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
1043 qual, tp1.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1045 LOG.info("ADCEP1 = {}", adCep1);
1046 org.opendaylight.yang.gen.v1.urn
1047 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep1 =
1048 new org.opendaylight.yang.gen.v1.urn
1049 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
1050 .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1051 .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
1052 .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
1053 .setConnectionEndPointUuid(adCep1.getUuid())
1055 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
1056 cepMap.get(new org.opendaylight.yang.gen.v1.urn
1057 .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
1058 new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
1059 qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1061 LOG.info("ADCEP2 = {}", adCep2);
1062 org.opendaylight.yang.gen.v1.urn
1063 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep2 =
1064 new org.opendaylight.yang.gen.v1.urn
1065 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
1066 .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1067 .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
1068 .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
1069 .setConnectionEndPointUuid(adCep1.getUuid())
1071 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
1072 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
1073 ceps.put(cep1.key(), cep1);
1074 ceps.put(cep2.key(), cep2);
1075 Name connName = new NameBuilder()
1076 .setValueName("Connection name")
1077 .setValue(String.join("+", "TOP", tp1, tp2, qual))
1079 // TODO: lower connection, supported link.......
1080 if (additionalLowerConn != null) {
1081 xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
1082 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
1084 return new org.opendaylight.yang.gen.v1.urn
1085 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
1086 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
1087 .getBytes(StandardCharsets.UTF_8)).toString()))
1088 .setName(Map.of(connName.key(), connName))
1089 .setConnectionEndPoint(ceps)
1090 .setOperationalState(OperationalState.ENABLED)
1091 .setLayerProtocolName(topPortocol)
1092 .setLifecycleState(LifecycleState.INSTALLED)
1093 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1094 .setLowerConnection(xcMap)
1098 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
1099 createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
1100 LayerProtocolName xcProtocol) {
1101 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
1102 LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
1103 LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint().toString());
1104 LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint().toString());
1105 org.opendaylight.yang.gen.v1.urn
1106 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ1 =
1107 new org.opendaylight.yang.gen.v1.urn
1108 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
1109 .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1110 .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
1111 .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
1112 .setConnectionEndPointUuid(cep1.getUuid())
1114 org.opendaylight.yang.gen.v1.urn
1115 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ2 =
1116 new org.opendaylight.yang.gen.v1.urn
1117 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
1118 .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1119 .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
1120 .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
1121 .setConnectionEndPointUuid(cep2.getUuid())
1123 Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
1124 .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
1125 ceps.put(cepServ1.key(), cepServ1);
1126 ceps.put(cepServ2.key(), cepServ2);
1127 Name connName = new NameBuilder()
1128 .setValueName("Connection name")
1129 .setValue(String.join("+", "XC", tp1, tp2, qual))
1131 // TODO: lower connection, supported link.......
1132 return new org.opendaylight.yang.gen.v1.urn
1133 .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
1134 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
1135 .getBytes(StandardCharsets.UTF_8)).toString()))
1136 .setName(Map.of(connName.key(), connName))
1137 .setConnectionEndPoint(ceps)
1138 .setOperationalState(OperationalState.ENABLED)
1139 .setLayerProtocolName(xcProtocol)
1140 .setLifecycleState(LifecycleState.INSTALLED)
1141 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1145 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
1146 LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1147 Name cepName = new NameBuilder()
1148 .setValueName("ConnectionEndPoint name")
1149 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1150 id.split("\\+")[1]))
1152 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1153 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1154 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1156 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1157 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
1159 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1160 .getBytes(StandardCharsets.UTF_8)).toString()))
1162 String clientQualifier = "";
1163 switch (qualifier) {
1164 case TapiStringConstants.PHTNC_MEDIA_OTS:
1165 clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS;
1167 case TapiStringConstants.PHTNC_MEDIA_OMS:
1168 clientQualifier = TapiStringConstants.MC;
1169 OwnedNodeEdgePoint onepMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1170 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1171 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], TapiStringConstants.MC, onepMC);
1173 case TapiStringConstants.MC:
1174 clientQualifier = TapiStringConstants.OTSI_MC;
1175 OwnedNodeEdgePoint onepOTSiMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1176 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1177 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1],
1178 TapiStringConstants.OTSI_MC, onepOTSiMC);
1181 LOG.debug("not currently handling client NEP for OTSiMC CEP {}",
1182 String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1185 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1186 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1187 clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1189 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1190 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
1192 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1193 .getBytes(StandardCharsets.UTF_8)).toString()))
1195 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1196 // TODO: add parent ONEP??
1197 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1198 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1199 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1201 .setParentNodeEdgePoint(pnep)
1202 .setName(Map.of(cepName.key(), cepName))
1203 .setConnectionPortRole(PortRole.SYMMETRIC)
1204 .setDirection(Direction.BIDIRECTIONAL)
1205 .setOperationalState(OperationalState.ENABLED)
1206 .setLifecycleState(LifecycleState.INSTALLED)
1207 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
1208 if (!(TapiStringConstants.OTSI_MC.equals(qualifier))) {
1209 cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
1211 return cepBldr.build();
1214 private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
1215 LayerProtocolName cepProtocol) {
1216 Name cepName = new NameBuilder()
1217 .setValueName("ConnectionEndPoint name")
1218 .setValue(String.join("+", id.split("\\+")[0], qualifier,
1219 id.split("\\+")[1]))
1221 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1222 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1223 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1225 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1226 TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
1228 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1229 .getBytes(StandardCharsets.UTF_8)).toString()))
1231 String clientQualifier = "";
1232 String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA;
1233 switch (qualifier) {
1234 case TapiStringConstants.PHTNC_MEDIA_OTS:
1235 clientQualifier = TapiStringConstants.OTSI_MC;
1237 case TapiStringConstants.OTSI_MC:
1238 clientQualifier = TapiStringConstants.E_ODU;
1239 clientNodeLayer = TapiStringConstants.ODU;
1241 case TapiStringConstants.E_ODU:
1242 clientQualifier = TapiStringConstants.DSR;
1243 clientNodeLayer = TapiStringConstants.DSR;
1246 LOG.debug("no client CEP for DSR NEP {}",
1247 String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
1250 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1251 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
1252 clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1254 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
1255 TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
1257 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1258 .getBytes(StandardCharsets.UTF_8)).toString()))
1260 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1261 // TODO: add parent ONEP??
1262 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1263 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
1264 qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
1266 .setParentNodeEdgePoint(pnep)
1267 .setName(Map.of(cepName.key(), cepName))
1268 .setConnectionPortRole(PortRole.SYMMETRIC)
1269 .setDirection(Direction.BIDIRECTIONAL)
1270 .setOperationalState(OperationalState.ENABLED)
1271 .setLifecycleState(LifecycleState.INSTALLED)
1272 .setLayerProtocolName(cepProtocol);
1273 if (!(TapiStringConstants.DSR.equals(qualifier))) {
1274 cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
1276 return cepBldr.build();
1279 private EndPoint mapServiceZEndPoint(
1280 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd
1281 serviceZEnd, PathDescription pathDescription) {
1282 EndPointBuilder endPointBuilder = new EndPointBuilder();
1283 // 1. Service Format: ODU, OTU, ETH
1284 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1285 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1286 // Identify SIP name
1287 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1288 LOG.info("Uuid of z end {}", sipUuid);
1289 LayerProtocolName layerProtocols = null;
1290 // Layer protocol name
1291 switch (serviceFormat) {
1293 layerProtocols = LayerProtocolName.DSR;
1297 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1300 layerProtocols = LayerProtocolName.ODU;
1303 LOG.error("Service Format not supported");
1305 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1306 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1307 .setValueName("OpenROADM info")
1308 .setValue(String.join("-", serviceZEnd.getClli(),
1309 serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1310 .getPortDeviceName(),
1311 serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
1313 return endPointBuilder
1314 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1315 .setServiceInterfacePointUuid(sipUuid)
1317 .setName(Map.of(name.key(), name))
1318 .setAdministrativeState(AdministrativeState.UNLOCKED)
1319 .setDirection(Direction.BIDIRECTIONAL)
1320 .setLifecycleState(LifecycleState.INSTALLED)
1321 .setOperationalState(OperationalState.ENABLED)
1322 .setLayerProtocolName(layerProtocols)
1323 .setCapacity(new CapacityBuilder()
1324 .setTotalSize(new TotalSizeBuilder()
1325 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
1326 .setUnit(CAPACITYUNITGBPS.VALUE)
1328 // .setBandwidthProfile(new BandwidthProfileBuilder().build())
1330 .setProtectionRole(ProtectionRole.WORK)
1331 .setRole(PortRole.SYMMETRIC)
1332 .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()
1333 .getPort().getPortDeviceName())
1337 private EndPoint mapServiceAEndPoint(
1338 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
1339 serviceAEnd, PathDescription pathDescription) {
1340 EndPointBuilder endPointBuilder = new EndPointBuilder();
1341 // 1. Service Format: ODU, OTU, ETH
1342 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1343 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1344 // Identify SIP name
1345 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1346 LOG.info("Uuid of a end {}", sipUuid);
1347 LayerProtocolName layerProtocols = null;
1348 // Layer protocol name
1349 switch (serviceFormat) {
1351 layerProtocols = LayerProtocolName.DSR;
1355 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1358 layerProtocols = LayerProtocolName.ODU;
1361 LOG.error("Service Format not supported");
1363 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1364 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1365 .setValueName("OpenROADM info")
1366 .setValue(String.join("-", serviceAEnd.getClli(),
1367 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1368 .getPortDeviceName(),
1369 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
1371 return endPointBuilder
1372 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1373 .setServiceInterfacePointUuid(sipUuid)
1375 .setName(Map.of(name.key(), name))
1376 .setAdministrativeState(AdministrativeState.UNLOCKED)
1377 .setDirection(Direction.BIDIRECTIONAL)
1378 .setLifecycleState(LifecycleState.INSTALLED)
1379 .setOperationalState(OperationalState.ENABLED)
1380 .setLayerProtocolName(layerProtocols)
1381 .setCapacity(new CapacityBuilder()
1382 .setTotalSize(new TotalSizeBuilder()
1383 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceAEnd.getServiceRate().doubleValue())))
1384 .setUnit(CAPACITYUNITGBPS.VALUE)
1386 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1388 .setProtectionRole(ProtectionRole.WORK)
1389 .setRole(PortRole.SYMMETRIC)
1390 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1391 .getPortDeviceName())
1395 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1396 Uuid zendUuid = null;
1397 if (serviceNodeId.contains("ROADM")) {
1398 // Service from ROADM to ROADM
1399 // AddDrop-AddDrop ports --> MC layer SIPs
1400 ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
1402 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1403 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1404 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1406 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1407 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1408 if (!sip.getUuid().equals(sipUuid)) {
1409 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1412 zendUuid = sip.getUuid();
1416 // Service from XPDR to XPDR
1418 TerminationPoint tp;
1420 switch (serviceFormat) {
1422 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
1424 tp = (TerminationPoint) firstElement.getResource().getResource();
1425 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1426 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1427 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1428 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
1432 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
1434 tp = (TerminationPoint) firstElement.getResource().getResource();
1435 // Network-Network ports --> iOTSi layer SIPs
1436 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1437 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1438 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
1442 LOG.info("Elements ZA = {}", mapztoa.values().toString());
1443 firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
1445 tp = (TerminationPoint) firstElement.getResource().getResource();
1446 // Client-client ports --> DSR layer SIPs
1447 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1448 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1449 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
1454 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1456 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1457 if (!sip.getUuid().equals(sipUuid)) {
1458 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1461 zendUuid = sip.getUuid();
1468 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1469 Uuid aendUuid = null;
1470 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1471 LOG.info("Map a to z = {}", mapatoz);
1472 if (serviceNodeId.contains("ROADM")) {
1473 // Service from ROADM to ROADM
1474 // AddDrop-AddDrop ports --> MC layer SIPs
1475 AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
1477 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1478 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1479 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
1480 tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
1482 LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
1484 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1485 if (!sip.getUuid().equals(sipUuid)) {
1486 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1489 aendUuid = sip.getUuid();
1493 // Service from XPDR to XPDR
1495 TerminationPoint tp;
1497 switch (serviceFormat) {
1499 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
1501 tp = (TerminationPoint) firstElement.getResource().getResource();
1502 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1503 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1504 TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1505 LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1506 TapiStringConstants.I_ODU, tp.getTpId()));
1509 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
1511 tp = (TerminationPoint) firstElement.getResource().getResource();
1512 // Network-Network ports --> iOTSi layer SIPs
1513 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1514 TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1515 LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1516 TapiStringConstants.I_OTSI, tp.getTpId()));
1519 LOG.info("Elements AZ = {}", mapatoz.values().toString());
1520 firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
1522 tp = (TerminationPoint) firstElement.getResource().getResource();
1523 // Client-client ports --> DSR layer SIPs
1524 sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
1525 TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
1526 LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
1527 TapiStringConstants.DSR, tp.getTpId()));
1531 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1533 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1534 if (!sip.getUuid().equals(sipUuid)) {
1535 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1538 aendUuid = sip.getUuid();
1545 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1546 LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
1547 LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
1548 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1549 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1550 .getBytes(StandardCharsets.UTF_8)).toString());
1551 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
1552 .getBytes(StandardCharsets.UTF_8)).toString());
1553 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
1554 .getBytes(StandardCharsets.UTF_8)).toString());
1555 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1558 private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
1559 ConnectionEndPoint cep) {
1560 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1561 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1562 .getBytes(StandardCharsets.UTF_8)).toString());
1563 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
1564 .getBytes(StandardCharsets.UTF_8)).toString());
1565 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
1566 .getBytes(StandardCharsets.UTF_8)).toString());
1567 this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
1571 private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
1572 LOG.info("NEP id before Merge = {}", String.join("+", orNodeId, qual, orTpId));
1573 LOG.info("Node of NEP id before Merge = {}", String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA));
1574 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1575 Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
1576 .getBytes(Charset.forName("UTF-8"))).toString());
1577 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)
1578 .getBytes(Charset.forName("UTF-8"))).toString());
1579 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, qual, orTpId)
1580 .getBytes(Charset.forName("UTF-8"))).toString());
1581 updateTopologyWithNep(topoUuid, nodeUuid, nepUuid, onep);
1584 private String getIdBasedOnModelVersion(String nodeid) {
1585 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
1586 nodeid.split("-")[1]) : nodeid.split("-")[0];
1589 private ServiceZEnd tapiEndPointToServiceZPoint(
1590 org.opendaylight.yang.gen.v1.urn
1591 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
1592 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1593 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1594 // Not the rest which is needed in the txPortDeviceName.
1595 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1596 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1597 // Todo -> need to find the NEP associated to that SIP
1598 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString());
1599 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1600 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1602 LOG.error("Node not found in datastore");
1605 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1606 // connection is between 2 CLIENT ports. Otherwise it will not work...
1607 OwnedNodeEdgePoint nep = null;
1608 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1609 if (onep.getMappedServiceInterfacePoint() == null) {
1612 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1618 LOG.error("Nep not found in datastore");
1621 String nodeName = "";
1622 for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1623 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1624 endPoint.getName().entrySet()) {
1625 if (!("Node Type").equals(entry.getValue().getValueName())) {
1626 nodeName = entry.getValue().getValue();
1629 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1630 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1631 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1632 String txPortDeviceName = nepName.split("\\+")[0];
1633 String txPortName = nepName.split("\\+")[2];
1634 String rxPortDeviceName = txPortDeviceName;
1635 String rxPortName = txPortName;
1636 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1637 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1638 // TODO --> get clli from datastore?
1639 String clli = "NodeSC";
1640 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1641 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1642 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1644 .setNodeId(new NodeIdType(nodeid))
1645 .setOpticType(OpticTypes.Gray)
1646 .setServiceFormat(serviceFormat)
1647 .setServiceRate(Uint32.valueOf(capacity))
1648 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1649 .setCommittedBurstSize(Uint16.valueOf(64))
1650 .setCommittedInfoRate(Uint32.valueOf(100000))
1653 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1654 .setPort(new PortBuilder()
1655 .setPortDeviceName(txPortDeviceName)
1656 .setPortName(txPortName)
1657 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1659 .setPortType(TapiStringConstants.PORT_TYPE)
1661 .setLgx(new LgxBuilder()
1662 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1663 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1664 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1665 .setLgxPortShelf("00")
1667 .setIndex(Uint8.ZERO)
1669 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1670 .setPort(new PortBuilder()
1671 .setPortDeviceName(rxPortDeviceName)
1672 .setPortName(rxPortName)
1673 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1675 .setPortType(TapiStringConstants.PORT_TYPE)
1677 .setLgx(new LgxBuilder()
1678 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1679 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1680 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1681 .setLgxPortShelf("00")
1683 .setIndex(Uint8.ZERO)
1685 if (serviceFormat.equals(ServiceFormat.ODU)) {
1686 serviceZEndBuilder.setOduServiceRate(ODU4.VALUE);
1688 if (serviceFormat.equals(ServiceFormat.OTU)) {
1689 serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
1691 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1693 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1694 .setCommittedBurstSize(Uint16.valueOf(64))
1695 .setCommittedInfoRate(Uint32.valueOf(100000))
1699 return serviceZEndBuilder.build();
1702 private ServiceAEnd tapiEndPointToServiceAPoint(
1703 org.opendaylight.yang.gen.v1.urn
1704 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
1705 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1706 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1707 // Not the rest which is needed in the txPortDeviceName.
1708 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1709 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1710 // Todo -> need to find the NEP associated to that SIP
1711 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString());
1712 LOG.info("NodeA {} Uuid is {}", nodeAid, nodeUuid);
1713 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1714 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1716 LOG.error("Node not found in datastore");
1719 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1720 // connection is between 2 CLIENT ports. Otherwise it will not work...
1721 OwnedNodeEdgePoint nep = null;
1722 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1723 if (onep.getMappedServiceInterfacePoint() == null) {
1726 if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1732 LOG.error("Nep not found in datastore");
1735 String nodeName = "";
1736 for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1737 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1738 endPoint.getName().entrySet()) {
1739 if (!("Node Type").equals(entry.getValue().getValueName())) {
1740 nodeName = entry.getValue().getValue();
1743 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1744 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1745 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1746 String txPortDeviceName = nepName.split("\\+")[0];
1747 String txPortName = nepName.split("\\+")[2];
1748 String rxPortDeviceName = txPortDeviceName;
1749 String rxPortName = txPortName;
1750 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1751 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1752 // TODO --> get clli from datastore?
1753 String clli = "NodeSA";
1754 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1755 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1756 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1758 .setNodeId(new NodeIdType(nodeid))
1759 .setOpticType(OpticTypes.Gray)
1760 .setServiceFormat(serviceFormat)
1761 .setServiceRate(Uint32.valueOf(capacity))
1762 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1763 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth
1764 .sla.SubrateEthSlaBuilder()
1765 .setCommittedBurstSize(Uint16.valueOf(64))
1766 .setCommittedInfoRate(Uint32.valueOf(100000))
1769 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1770 .setPort(new PortBuilder()
1771 .setPortDeviceName(txPortDeviceName)
1772 .setPortName(txPortName)
1773 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1775 .setPortType(TapiStringConstants.PORT_TYPE)
1777 .setLgx(new LgxBuilder()
1778 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1779 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1780 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1781 .setLgxPortShelf("00")
1783 .setIndex(Uint8.ZERO)
1785 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1786 .setPort(new PortBuilder()
1787 .setPortDeviceName(rxPortDeviceName)
1788 .setPortName(rxPortName)
1789 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1791 .setPortType(TapiStringConstants.PORT_TYPE)
1793 .setLgx(new LgxBuilder()
1794 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1795 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1796 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1797 .setLgxPortShelf("00")
1799 .setIndex(Uint8.ZERO)
1801 if (serviceFormat.equals(ServiceFormat.ODU)) {
1802 serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
1803 } else if (serviceFormat.equals(ServiceFormat.OTU)) {
1804 serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
1806 if (!serviceLayer.equals(LayerProtocolName.ETH)) {
1808 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1809 .setCommittedBurstSize(Uint16.valueOf(64))
1810 .setCommittedInfoRate(Uint32.valueOf(100000))
1814 return serviceAEndBuilder.build();
1817 private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1818 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
1819 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1820 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1821 // EndPoints are ROADMs
1822 return ConnectionType.RoadmLine;
1824 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1825 return ConnectionType.Infrastructure;
1828 private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
1829 .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
1830 if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
1831 .anyMatch(name -> name.getValue().contains("ROADM")))) {
1832 // EndPoints are ROADMs
1833 return ServiceFormat.OC;
1835 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1836 return ServiceFormat.OTU;
1839 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1840 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1841 TapiStringConstants.XPDR).getBytes(StandardCharsets.UTF_8))).toString());
1842 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
1843 TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8)))
1845 Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
1846 spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
1847 .getBytes(StandardCharsets.UTF_8)).toString());
1848 return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
1851 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1852 for (String networkPort:xpdrNetworkTplist) {
1853 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1860 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1861 List<String> clientPortList = new ArrayList<>();
1862 for (String networkPort:xpdrNetworkTplist) {
1863 String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
1864 networkPort.split("\\+")[0].split("-")[1]);
1865 String tpId = networkPort.split("\\+")[1];
1866 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1867 .child(Nodes.class, new NodesKey(nodeId))
1868 .child(Mapping.class, new MappingKey(tpId)).build();
1870 Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
1872 if (!optMapping.isPresent()) {
1873 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1875 Mapping mapping = optMapping.orElseThrow();
1876 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1877 String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
1878 mapping.getConnectionMapLcp());
1879 LOG.info("Key to be added to list = {}", key);
1880 if (!clientPortList.contains(key)) {
1881 clientPortList.add(key);
1883 } catch (InterruptedException | ExecutionException e) {
1884 LOG.error("Couldnt read mapping from datastore", e);
1889 return clientPortList;
1892 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1893 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1894 for (String xpdrNode:xpdrNodelist) {
1895 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.XPDR))
1896 .getBytes(StandardCharsets.UTF_8)).toString());
1897 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
1898 .onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeIID = InstanceIdentifier.builder(
1899 Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
1900 .onf.otcc.yang.tapi.topology.rev221121.Context1.class).child(TopologyContext.class)
1901 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1902 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
1903 new NodeKey(nodeUuid)).build();
1905 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode
1906 = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1907 if (optNode.isEmpty()) {
1910 OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
1911 new NameKey("Node Type")).getValue());
1912 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1913 openroadmNodeTypeList.add(openroadmNodeType);
1915 } catch (InterruptedException | ExecutionException e) {
1916 LOG.error("Couldnt read node in topology", e);
1920 // TODO for now check that there is only one type, otherwise error
1921 if (openroadmNodeTypeList.size() != 1) {
1922 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1925 return openroadmNodeTypeList.get(0);
1928 private OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId,
1929 boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
1931 //TODO : complete implementation with SIP
1932 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, nepPhotonicSublayer,
1933 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
1934 Name nepName = new NameBuilder()
1935 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
1936 .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
1938 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1939 if (TapiStringConstants.MC.equals(nepPhotonicSublayer)) {
1940 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1941 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE)
1942 .setNumberOfCepInstances(Uint64.valueOf(1))
1945 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1946 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
1947 .setNumberOfCepInstances(Uint64.valueOf(1))
1950 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
1952 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
1953 .setName(Map.of(nepName.key(), nepName))
1954 .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
1955 .setDirection(Direction.BIDIRECTIONAL)
1956 .setLinkPortRole(PortRole.SYMMETRIC)
1957 .setAdministrativeState(adminState).setOperationalState(operState)
1958 .setLifecycleState(LifecycleState.INSTALLED)