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.LowerConnection;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.Connection;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionKey;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.CapacityBuilder;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.ServiceInterfacePointBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
119 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
120 import org.opendaylight.yangtools.yang.common.Decimal64;
121 import org.opendaylight.yangtools.yang.common.Uint16;
122 import org.opendaylight.yangtools.yang.common.Uint32;
123 import org.opendaylight.yangtools.yang.common.Uint64;
124 import org.opendaylight.yangtools.yang.common.Uint8;
125 import org.slf4j.Logger;
126 import org.slf4j.LoggerFactory;
128 public final class ConnectivityUtils {
130 private final Uuid tapiTopoUuid = new Uuid(
131 UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString());
132 private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
134 private final ServiceDataStoreOperations serviceDataStoreOperations;
135 private final TapiContext tapiContext;
136 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
137 // this variable is for complete connection objects
139 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
140 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
142 private final NetworkTransactionService networkTransactionService;
143 private Connection topConnRdmRdm;
144 private Connection topConnXpdrXpdrPhtn;
145 private Connection topConnXpdrXpdrOdu;
147 // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
148 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations,
149 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap, TapiContext tapiContext,
150 NetworkTransactionService networkTransactionService) {
151 this.serviceDataStoreOperations = serviceDataStoreOperations;
152 this.tapiContext = tapiContext;
153 this.sipMap = sipMap;
154 this.connectionFullMap = new HashMap<>();
155 this.networkTransactionService = networkTransactionService;
156 this.topConnRdmRdm = null;
157 this.topConnXpdrXpdrPhtn = null;
158 this.topConnXpdrXpdrOdu = null;
161 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
162 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
163 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
164 if (serviceAEnd == null || serviceZEnd == null) {
165 LOG.warn("One of the endpoints could not be identified");
168 return new ServiceCreateInputBuilder()
169 .setCommonId("commonId")
170 .setConnectionType(ConnectionType.Service)
171 .setCustomer("Customer")
172 .setServiceName("service test")
173 .setServiceAEnd(serviceAEnd)
174 .setServiceZEnd(serviceZEnd)
175 .setSdncRequestHeader(
176 new SdncRequestHeaderBuilder()
177 .setRequestId("request-1")
178 .setRpcAction(RpcActions.ServiceCreate)
179 .setNotificationUrl("notification url")
180 .setRequestSystemId("appname")
185 public static ServiceAEnd buildServiceAEnd(
186 String nodeid, String clli, String txPortDeviceName,
187 String txPortName, String rxPortDeviceName, String rxPortName) {
188 return new ServiceAEndBuilder()
190 .setNodeId(new NodeIdType(nodeid))
191 .setOpticType(OpticTypes.Gray)
192 .setServiceFormat(ServiceFormat.Ethernet)
193 .setServiceRate(Uint32.valueOf(100))
194 .setTxDirection(Map.of(
195 new TxDirectionKey(Uint8.ZERO),
196 new TxDirectionBuilder()
197 .setPort(new PortBuilder()
198 .setPortDeviceName(txPortDeviceName)
199 .setPortName(txPortName)
200 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
202 .setPortType(TapiStringConstants.PORT_TYPE)
204 .setLgx(new LgxBuilder()
205 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
206 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
207 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
208 .setLgxPortShelf("00")
211 .setRxDirection(Map.of(
212 new RxDirectionKey(Uint8.ZERO),
213 new RxDirectionBuilder()
214 .setPort(new PortBuilder()
215 .setPortDeviceName(rxPortDeviceName)
216 .setPortName(rxPortName)
217 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
219 .setPortType(TapiStringConstants.PORT_TYPE)
221 .setLgx(new LgxBuilder()
222 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
223 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
224 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
225 .setLgxPortShelf("00")
231 public static ServiceZEnd buildServiceZEnd(
232 String nodeid, String clli, String txPortDeviceName,
233 String txPortName, String rxPortDeviceName, String rxPortName) {
234 return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
235 .setOpticType(OpticTypes.Gray)
236 .setServiceFormat(ServiceFormat.Ethernet)
237 .setServiceRate(Uint32.valueOf(100))
238 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
239 .setPort(new PortBuilder()
240 .setPortDeviceName(txPortDeviceName)
241 .setPortName(txPortName)
242 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
244 .setPortType(TapiStringConstants.PORT_TYPE)
246 .setLgx(new LgxBuilder()
247 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
248 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
249 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
250 .setLgxPortShelf("00")
253 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
254 .setPort(new PortBuilder()
255 .setPortDeviceName(rxPortDeviceName)
256 .setPortName(rxPortName)
257 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
259 .setPortType(TapiStringConstants.PORT_TYPE)
261 .setLgx(new LgxBuilder()
262 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
263 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
264 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
265 .setLgxPortShelf("00")
271 public void setSipMap(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
275 public ConnectivityService mapORServiceToTapiConnectivity(Service service) {
276 // Get service path with the description in OR based models.
277 LOG.info("Service = {}", service);
278 Optional<ServicePaths> optServicePaths =
279 this.serviceDataStoreOperations.getServicePath(service.getServiceName());
280 if (optServicePaths.isEmpty()) {
281 LOG.error("No service path found for service {}", service.getServiceName());
284 PathDescription pathDescription = optServicePaths.orElseThrow().getPathDescription();
285 LOG.info("Path description of service = {}", pathDescription);
286 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd =
287 service.getServiceAEnd();
289 EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
290 EndPoint endPoint2 = mapServiceZEndPoint(service.getServiceZEnd(), pathDescription);
291 Map<EndPointKey, EndPoint> endPointMap = new HashMap<>(Map.of(
292 endPoint1.key(), endPoint1,
293 endPoint2.key(), endPoint2));
294 LOG.info("EndPoints of connectivity services = {}", endPointMap);
297 new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName()).build();
298 // Connection creation
299 Map<ConnectionKey, Connection> connMap =
300 createConnectionsFromService(pathDescription, mapServiceLayerToAend(serviceAEnd));
301 LOG.debug("connectionMap for service {} = {} ", name, connMap);
302 ConnectivityConstraint conConstr =
303 new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build();
304 // TODO: full connectivity service?? With constraints and the rest of fields...
305 return new ConnectivityServiceBuilder()
306 .setAdministrativeState(AdministrativeState.UNLOCKED)
307 .setOperationalState(OperationalState.ENABLED)
308 .setLifecycleState(LifecycleState.INSTALLED)
310 UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8)).toString()))
311 .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
312 .setConnectivityConstraint(conConstr)
313 .setDirection(ForwardingDirection.BIDIRECTIONAL)
314 .setName(Map.of(name.key(), name))
315 .setConnection(connMap)
316 .setEndPoint(endPointMap)
320 public Map<ConnectionKey, Connection> createConnectionsFromService(
321 PathDescription pathDescription, LayerProtocolName lpn) {
322 Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
323 // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
324 // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
325 // and the connections
327 List<String> xpdrClientTplist = new ArrayList<>();
328 List<String> xpdrNetworkTplist = new ArrayList<>();
329 List<String> rdmAddDropTplist = new ArrayList<>();
330 List<String> rdmDegTplist = new ArrayList<>();
331 List<String> rdmNodelist = new ArrayList<>();
332 List<String> xpdrNodelist = new ArrayList<>();
333 for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
334 .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
335 resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
336 switch (resourceType) {
337 case TapiStringConstants.TP:
338 TerminationPoint tp = (TerminationPoint) elem.getResource().getResource();
339 String tpID = tp.getTpId();
341 if (tpID.contains("CLIENT")) {
342 tpNode = tp.getTpNodeId();
343 if (!xpdrClientTplist.contains(String.join("+", tpNode, tpID))) {
344 xpdrClientTplist.add(String.join("+", tpNode, tpID));
347 if (tpID.contains("NETWORK")) {
348 tpNode = tp.getTpNodeId();
349 if (!xpdrNetworkTplist.contains(String.join("+", tpNode, tpID))) {
350 xpdrNetworkTplist.add(String.join("+", tpNode, tpID));
353 if (tpID.contains("PP")) {
354 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
355 LOG.info("ROADM Node of tp = {}", tpNode);
356 if (!rdmAddDropTplist.contains(String.join("+", tpNode, tpID))) {
357 rdmAddDropTplist.add(String.join("+", tpNode, tpID));
360 if (tpID.contains("TTP")) {
361 tpNode = getIdBasedOnModelVersion(tp.getTpNodeId());
362 LOG.info("ROADM Node of tp = {}", tpNode);
363 if (!rdmDegTplist.contains(String.join("+", tpNode, tpID))) {
364 rdmDegTplist.add(String.join("+", tpNode, tpID));
368 case TapiStringConstants.NODE:
369 Node node = (Node) elem.getResource().getResource();
370 String nodeId = node.getNodeId();
371 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
372 LOG.info("Node id = {}", nodeId);
373 if (!xpdrNodelist.contains(nodeId)) {
374 xpdrNodelist.add(nodeId); // should contain only 2
377 if (nodeId.contains("ROADM")) {
378 nodeId = getIdBasedOnModelVersion(nodeId);
379 LOG.info("Node id = {}", nodeId);
380 if (!rdmNodelist.contains(nodeId)) {
381 rdmNodelist.add(nodeId);
386 LOG.warn("Resource is a {}", resourceType);
389 LOG.info("ROADM node list = {}", rdmNodelist);
390 LOG.info("ROADM degree list = {}", rdmDegTplist);
391 LOG.info("ROADM addrop list = {}", rdmAddDropTplist);
392 LOG.info("XPDR node list = {}", xpdrNodelist);
393 LOG.info("XPDR network list = {}", xpdrNetworkTplist);
394 LOG.info("XPDR client list = {}", xpdrClientTplist);
395 // TODO -> for 10GB eth and ODU services there are no ROADMs in path description as they use the OTU link,
396 // but for 100GB eth all is created at once. Check if the roadm list is empty to determine whether we need
397 // to trigger all the steps or not
398 String edgeRoadm1 = "";
399 String edgeRoadm2 = "";
400 if (!rdmNodelist.isEmpty()) {
401 edgeRoadm1 = rdmNodelist.get(0);
402 edgeRoadm2 = rdmNodelist.get(rdmNodelist.size() - 1);
403 LOG.info("edgeRoadm1 = {}", edgeRoadm1);
404 LOG.info("edgeRoadm2 = {}", edgeRoadm2);
406 // create corresponding CEPs and Connections. Connections should be added to the corresponding context
407 // CEPs must be included in the topology context as an augmentation for each ONEP!!
408 // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist??
409 // As mentioned above, for 100GbE service creation there are ROADMs in the path description.
410 // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed?
411 // this needs to be changed
412 // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created
413 OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist);
416 // Identify number of ROADMs
417 // - XC Connection between MC CEPs mapped from MC NEPs (within a roadm)
418 // - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
419 // - Top Connection MC betwwen MC CEPs of different roadms
420 // - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
421 connectionServMap.putAll(
422 createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
423 if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
424 .contains("ROADM")) {
425 // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
426 // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
427 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
429 this.topConnRdmRdm = null;
432 // TODO: verify if this is correct
433 // - XC Connection OTSi betwwen iODU and eODU of xpdr
434 // - Top connection in the ODU layer, between xpdr eODU ports (?)
435 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
436 connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist));
437 this.topConnXpdrXpdrPhtn = null;
441 // Check if OC, OTU and ODU are created
442 if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
443 LOG.info("WDM ETH service");
444 connectionServMap.putAll(
445 createRoadmCepsAndConnections(
446 rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
447 connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
448 this.topConnRdmRdm = null;
449 xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
450 LOG.info("Associated client ports = {}", xpdrClientTplist);
451 connectionServMap.putAll(
452 createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist, connectionServMap));
453 this.topConnXpdrXpdrPhtn = null;
457 LOG.info("OTN XGE/ODUe service");
458 // - XC connection between iODU and eODU
459 // - Top connection between eODU ports
460 // - Top connection between DSR ports
461 if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) {
462 // TODO: We create both ODU and DSR because there is no ODU service creation for the switch
463 // - XC Connection OTSi between iODU and eODU of xpdr
464 // - Top connection in the ODU layer, between xpdr eODU ports (?)
465 connectionServMap.putAll(
466 createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
467 this.topConnXpdrXpdrPhtn = null;
469 if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
470 // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
471 connectionServMap.putAll(
472 createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
473 this.topConnXpdrXpdrOdu = null;
477 LOG.error("Service type format not supported");
479 LOG.debug("CONNSERVERMAP = {}", connectionServMap);
480 return connectionServMap;
483 public void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) {
484 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
485 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
486 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
487 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class)
488 .child(Topology.class, new TopologyKey(topoUuid))
489 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
490 new NodeKey(nodeUuid))
491 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
494 Optional<OwnedNodeEdgePoint> optionalOnep =
495 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
496 if (optionalOnep.isPresent()) {
497 LOG.error("ONEP is already present in datastore");
500 // merge in datastore
501 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onep);
502 this.networkTransactionService.commit().get();
503 LOG.info("NEP {} added successfully.", onep.getName());
504 } catch (InterruptedException | ExecutionException e) {
505 LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName(), e);
509 public Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
510 .connectivity.context.ConnectionKey,
511 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
512 .connectivity.context.Connection> getConnectionFullMap() {
513 return this.connectionFullMap;
516 public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
517 // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
518 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
519 .create.connectivity.service.input.EndPointKey,
520 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
521 .create.connectivity.service.input.EndPoint> endPointMap = input.getEndPoint();
522 ConnectionType connType = null;
523 ServiceFormat serviceFormat = null;
524 String nodeAid = String.join("+",
525 endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
526 TapiStringConstants.XPDR);
527 String nodeZid = String.join("+",
528 endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
529 TapiStringConstants.XPDR);
530 LOG.info("NodeAid = {}", nodeAid);
531 LOG.info("NodeZid = {}", nodeZid);
532 //switch (constraint.getServiceLayer().getIntValue()) {
533 switch (input.getLayerProtocolName().getIntValue()) {
536 connType = ConnectionType.Infrastructure;
537 serviceFormat = ServiceFormat.ODU;
540 LOG.info("ETH, no need to create OTU and ODU");
541 connType = ConnectionType.Service;
542 serviceFormat = ServiceFormat.Ethernet;
545 LOG.info("DSR, need to create OTU and ODU");
546 connType = ConnectionType.Service;
547 serviceFormat = ServiceFormat.Ethernet;
550 LOG.info("PHOTONIC");
551 connType = getConnectionTypePhtnc(endPointMap.values());
552 serviceFormat = getServiceFormatPhtnc(endPointMap.values());
553 LOG.debug("Node a photonic = {}", nodeAid);
554 LOG.debug("Node z photonic = {}", nodeZid);
557 LOG.info("Service type {} not supported", input.getLayerProtocolName().getName());
559 // Requested Capacity for connectivity service
560 Uint64 capacity = Uint64.valueOf(Math.abs(
561 input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
562 // map endpoints into service end points. Map the type of service from TAPI to OR
563 ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(
564 endPointMap.values().stream().findFirst().orElseThrow(),
565 serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
566 ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(
567 endPointMap.values().stream().skip(1).findFirst().orElseThrow(),
568 serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
569 if (serviceAEnd == null || serviceZEnd == null) {
570 LOG.error("Couldnt map endpoints to service end");
573 LOG.info("Service a end = {}", serviceAEnd);
574 LOG.info("Service z end = {}", serviceZEnd);
575 return new ServiceCreateInputBuilder()
576 .setServiceAEnd(serviceAEnd)
577 .setServiceZEnd(serviceZEnd)
578 .setConnectionType(connType)
579 .setServiceName(serviceUuid.getValue())
580 .setCommonId("common id")
581 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
582 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
583 .setRequestSystemId("appname")
585 .setCustomer("customer")
586 .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
587 .setOperatorContact("pw1234")
591 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
592 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
593 return new ServiceAEndBuilder(sepA.getValue()).build();
595 if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
596 return new ServiceAEndBuilder(sepZ.getValue()).build();
601 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
602 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
603 return new ServiceZEndBuilder(sepA.getValue()).build();
605 if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
606 return new ServiceZEndBuilder(sepZ.getValue()).build();
611 private LayerProtocolName mapServiceLayerToAend(
612 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
613 .service.ServiceAEnd serviceAEnd) {
614 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
615 switch (serviceFormat) {
618 return LayerProtocolName.PHOTONICMEDIA;
620 return LayerProtocolName.ODU;
622 if (getOpenroadmType(
623 serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()
624 .getPort().getPortDeviceName())
625 .equals(OpenroadmNodeType.TPDR)) {
626 return LayerProtocolName.ETH;
628 return LayerProtocolName.DSR;
630 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
635 private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
636 switch (serviceFormat) {
639 return LayerProtocolName.PHOTONICMEDIA;
641 return LayerProtocolName.ODU;
643 String node1 = endPoint1.getLocalId();
644 String node2 = endPoint2.getLocalId();
645 if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
646 && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
647 return LayerProtocolName.ETH;
649 return LayerProtocolName.DSR;
651 LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
655 //TODO factorize these two similar methods
657 private OpenroadmNodeType getOpenroadmType(String nodeName) {
658 LOG.info("Node name = {}", nodeName);
659 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode =
660 this.tapiContext.getTapiNode(
662 new Uuid(UUID.nameUUIDFromBytes(
663 (String.join("+",nodeName, TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
665 return tapiNode == null
667 : OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type")).getValue());
670 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(
671 List<String> xpdrClientTplist, List<String> xpdrNodelist, Map<ConnectionKey, Connection> lowerConn) {
672 // TODO: do we need to create cross connection between iODU and eODU??
673 // add the lower connections of the previous steps for this kind of service
674 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
675 for (Connection lowConn: lowerConn.values()) {
676 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
677 xcMap.put(conn.key(), conn);
679 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
680 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
681 // Create 1 cep per Xpdr in the CLIENT
682 // 1 top connection DSR between the CLIENT xpdrs
683 for (String xpdr:xpdrNodelist) {
684 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
685 String spcXpdrClient =
686 xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
687 ConnectionEndPoint netCep1 =
688 createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
689 putXpdrCepInTopologyContext(
690 xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, netCep1);
691 cepMapDsr.put(netCep1.key(), netCep1);
693 // DSR top connection between edge xpdr CLIENT DSR
694 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
695 .connectivity.context.Connection connectionDsr =
698 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
699 .findFirst().orElseThrow(),
701 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
702 .findFirst().orElseThrow(),
703 cepMapDsr, TapiStringConstants.DSR, LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
704 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
705 // DSR top connection that will be added to the service object
706 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
707 return new HashMap<>(Map.of(conn1.key(), conn1));
710 private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(
711 List<String> xpdrClientTplist, List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
712 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
713 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
714 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
715 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
716 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapOdu = new HashMap<>();
717 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
718 // be added to the lower connection of a top connection
719 Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
721 // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE,
722 // 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
723 for (String xpdr:xpdrNodelist) {
724 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
725 String spcXpdrClient =
726 xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
727 ConnectionEndPoint clientCep1 =
728 createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
729 putXpdrCepInTopologyContext(
730 xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, clientCep1);
731 ConnectionEndPoint clientCep2 = createCepXpdr(
732 spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
733 putXpdrCepInTopologyContext(
734 xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, clientCep2);
735 cepMapDsr.put(clientCep1.key(), clientCep1);
736 cepMapOdu.put(clientCep2.key(), clientCep2);
738 String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
739 // Create x connection between I_ODU and E_ODU within xpdr
740 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
741 .connectivity.context.Connection connection =
743 clientCep2, getAssociatediODUCep(spcXpdrNetwork),
744 spcXpdrClient, spcXpdrNetwork, TapiStringConstants.ODU, LayerProtocolName.ODU);
745 this.connectionFullMap.put(connection.key(), connection);
747 // Create X connection that will be added to the service object
748 LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
749 xcMap.put(conn.key(), conn);
752 // DSR top connection between edge xpdr CLIENT DSR
754 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
755 .findFirst().orElseThrow();
757 xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
758 .findFirst().orElseThrow();
760 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
761 .connectivity.context.Connection connectionOdu =
763 spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
764 LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
765 this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
767 // ODU top connection that will be added to the service object
768 Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
769 connServMap.put(conn.key(), conn);
770 LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
771 xcMap.put(lowerConn.key(), lowerConn);
773 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
774 .connectivity.context.Connection connectionDsr =
776 spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
777 LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
778 this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
779 // DSR top connection that will be added to the service object
780 Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
781 connServMap.put(conn1.key(), conn1);
785 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(
786 List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
787 Map<ConnectionKey, Connection> connServMap = new HashMap<>();
788 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
789 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
790 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
791 // be added to the lower connection of a top connection
792 // Create 1 cep per Xpdr in the I_ODU and a top
793 // connection iODU between the xpdrs
794 for (String xpdr:xpdrNodelist) {
795 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
796 String spcXpdrNetwork =
797 xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
798 ConnectionEndPoint netCep1 =
800 spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
801 putXpdrCepInTopologyContext(
802 xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, netCep1);
803 cepMap.put(netCep1.key(), netCep1);
805 // ODU top connection between edge xpdr i_ODU
806 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
807 .connectivity.context.Connection connection =
810 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
811 .findFirst().orElseThrow(),
813 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
814 .findFirst().orElseThrow(),
815 cepMap, TapiStringConstants.I_ODU,
816 LayerProtocolName.ODU, new HashMap<>(), this.topConnXpdrXpdrPhtn);
817 this.connectionFullMap.put(connection.key(), connection);
818 // ODU top connection that will be added to the service object
819 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
820 connServMap.put(conn.key(), conn);
821 this.topConnXpdrXpdrOdu = conn;
825 private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(
826 List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
827 // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
828 // be added to the lower connection of a top connection
829 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
830 ConnectionEndPoint> cepMap = new HashMap<>();
831 // create ceps and x connections within xpdr
832 for (String xpdr:xpdrNodelist) {
833 LOG.info("Creating ceps and xc for xpdr {}", xpdr);
834 String spcXpdrNetwork =
835 xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
836 // There should be 1 network tp per xpdr
837 // Just create 2 different CEPs (1 OTS + 1 OTSI_MC)
838 ConnectionEndPoint netCep1 = createCepXpdr(
839 spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
840 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
841 putXpdrCepInTopologyContext(
842 xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, netCep1);
843 ConnectionEndPoint netCep2 = createCepXpdr(
844 spcXpdrNetwork, TapiStringConstants.OTSI_MC,
845 TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
846 putXpdrCepInTopologyContext(
847 xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, netCep2);
848 // ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
849 // TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
850 // putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
852 cepMap.put(netCep1.key(), netCep1);
853 cepMap.put(netCep2.key(), netCep2);
854 // cepMap.put(netCep3.key(), netCep3);
857 // OTSi top connection between edge OTSI_MC Xpdr
858 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
859 .connectivity.context.Connection connection =
862 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
863 .findFirst().orElseThrow(),
865 xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
866 .findFirst().orElseThrow(),
867 cepMap, TapiStringConstants.OTSI_MC,
868 LayerProtocolName.PHOTONICMEDIA, new HashMap<>(), this.topConnRdmRdm);
869 this.connectionFullMap.put(connection.key(), connection);
870 // OTSi top connection that will be added to the service object
871 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
872 this.topConnXpdrXpdrPhtn = conn;
873 return new HashMap<>(Map.of(conn.key(), conn));
876 private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(
877 List<String> rdmAddDropTplist, List<String> rdmDegTplist, List<String> rdmNodelist,
878 String edgeRoadm1, String edgeRoadm2) {
879 // TODO: will need to check if things exist already or not
880 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
881 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
882 // create ceps and x connections within roadm
883 Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
884 for (String roadm : rdmNodelist) {
885 LOG.info("Creating ceps and xc for roadm {}", roadm);
886 if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
887 LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
888 String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm))
889 .findFirst().orElseThrow();
890 LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
891 // There should be only 1 AD and 1 DEG per roadm
892 // TODO photonic media model should be updated to have the corresponding CEPs. I will just create
893 // 3 different MC CEPs giving different IDs to show that they are different
894 // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs
895 // created in the topology creation
896 // add CEPs to the topology to the corresponding ONEP
897 ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS);
898 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS, adCep1);
899 ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC);
900 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2);
901 ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC);
902 putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3);
903 cepMap.put(adCep1.key(), adCep1);
904 cepMap.put(adCep2.key(), adCep2);
905 cepMap.put(adCep3.key(), adCep3);
907 String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
908 LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG);
910 ConnectionEndPoint degCep0 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS);
911 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS, degCep0);
912 ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS);
913 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS, degCep1);
914 ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC);
915 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2);
916 ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC);
917 putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3);
918 cepMap.put(degCep0.key(), degCep0);
919 cepMap.put(degCep1.key(), degCep1);
920 cepMap.put(degCep2.key(), degCep2);
921 cepMap.put(degCep3.key(), degCep3);
923 LOG.info("Going to create cross connections for ROADM {}", roadm);
924 // Create X connections between MC and OTSi_MC for full map
925 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
926 .connectivity.context.Connection connection1 =
928 adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
929 LayerProtocolName.PHOTONICMEDIA);
930 LOG.info("Cross connection 1 created = {}", connection1);
931 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
932 .connectivity.context.Connection connection2 =
934 adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
935 LayerProtocolName.PHOTONICMEDIA);
936 LOG.info("Cross connection 2 created = {}", connection2);
937 this.connectionFullMap.put(connection1.key(), connection1);
938 this.connectionFullMap.put(connection2.key(), connection2);
940 // Create X connections that will be added to the service object
941 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
942 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
944 xcLowerMap.put(conn1.key(), conn1);
945 xcLowerMap.put(conn2.key(), conn2);
947 LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG");
948 String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow();
949 LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1);
951 ConnectionEndPoint deg1Cep0 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS);
952 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS, deg1Cep0);
953 ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS);
954 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS, deg1Cep1);
955 ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC);
956 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2);
957 ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC);
958 putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3);
959 cepMap.put(deg1Cep0.key(), deg1Cep0);
960 cepMap.put(deg1Cep1.key(), deg1Cep1);
961 cepMap.put(deg1Cep2.key(), deg1Cep2);
962 cepMap.put(deg1Cep3.key(), deg1Cep3);
965 rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().orElseThrow();
966 LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
968 ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS);
969 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS, deg2Cep0);
970 ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS);
971 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS, deg2Cep1);
972 ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC);
973 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2);
974 ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC);
975 putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3);
976 cepMap.put(deg2Cep0.key(), deg2Cep0);
977 cepMap.put(deg2Cep1.key(), deg2Cep1);
978 cepMap.put(deg2Cep2.key(), deg2Cep2);
979 cepMap.put(deg2Cep3.key(), deg2Cep3);
981 LOG.info("Going to create cross connections for ROADM {}", roadm);
982 // Create X connections between MC and OTSi_MC for full map
983 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
984 .connectivity.context.Connection connection1 =
986 deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
987 TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
988 LOG.info("Cross connection 1 created = {}", connection1);
989 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
990 .connectivity.context.Connection connection2 =
992 deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
993 TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
994 LOG.info("Cross connection 2 created = {}", connection2.toString());
995 this.connectionFullMap.put(connection1.key(), connection1);
996 this.connectionFullMap.put(connection2.key(), connection2);
998 // Create X connections that will be added to the service object
999 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1000 xcLowerMap.put(conn1.key(), conn1);
1001 LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
1002 xcLowerMap.put(conn2.key(), conn2);
1005 LOG.info("Going to create top connections between roadms");
1006 String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow();
1007 String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
1008 // MC top connection between edge roadms
1009 LOG.info("Going to created top connection between MC");
1010 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1011 .connectivity.context.Connection connection =
1012 createTopConnection(
1013 spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
1014 LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
1015 this.connectionFullMap.put(connection.key(), connection);
1016 LOG.info("Top connection created = {}", connection);
1018 LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1019 // OTSiMC top connection between edge roadms
1020 LOG.info("Going to created top connection between OTSiMC");
1021 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1022 .connectivity.context.Connection connection1 =
1023 createTopConnection(
1024 spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
1025 LayerProtocolName.PHOTONICMEDIA,
1027 new HashMap<>(Map.of(conn1.key(), conn1)),
1029 this.connectionFullMap.put(connection1.key(), connection1);
1030 LOG.info("Top connection created = {}", connection1);
1032 // OTSiMC top connections that will be added to the service object
1033 Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
1034 Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
1035 this.topConnRdmRdm = conn2;
1036 return new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2));
1039 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1040 .connectivity.context.Connection createTopConnection(
1043 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1044 .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap,
1045 String qual, LayerProtocolName topPortocol,
1046 Map<LowerConnectionKey, LowerConnection> xcMap,
1047 Connection additionalLowerConn) {
1048 // find cep for each AD MC of roadm 1 and 2
1049 String topConnName = String.join("+", "TOP", tp1, tp2, qual);
1050 LOG.info("Top connection name = {}", topConnName);
1051 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 =
1053 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1054 .cep.list.ConnectionEndPointKey(new Uuid(UUID.nameUUIDFromBytes(
1055 (String.join("+", "CEP", tp1.split("\\+")[0], qual, tp1.split("\\+")[1]))
1056 .getBytes(StandardCharsets.UTF_8)).toString())));
1057 LOG.info("ADCEP1 = {}", adCep1);
1058 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1059 .connection.ConnectionEndPoint cep1 =
1060 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1061 .connection.ConnectionEndPointBuilder()
1062 .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1063 .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
1064 .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
1065 .setConnectionEndPointUuid(adCep1.getUuid())
1067 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
1069 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1070 .cep.list.ConnectionEndPointKey(
1071 new Uuid(UUID.nameUUIDFromBytes(
1072 (String.join("+", "CEP", tp2.split("\\+")[0], qual, tp2.split("\\+")[1]))
1073 .getBytes(StandardCharsets.UTF_8)).toString())));
1074 LOG.info("ADCEP2 = {}", adCep2);
1075 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1076 .connection.ConnectionEndPoint cep2 =
1077 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1078 .connection.ConnectionEndPointBuilder()
1079 .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1080 .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
1081 .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
1082 .setConnectionEndPointUuid(adCep1.getUuid())
1084 Name connName = new NameBuilder()
1085 .setValueName("Connection name")
1086 .setValue(topConnName)
1088 // TODO: lower connection, supported link.......
1089 if (additionalLowerConn != null) {
1090 xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
1091 new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
1093 return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1094 .connectivity.context.ConnectionBuilder()
1095 .setUuid(new Uuid(UUID.nameUUIDFromBytes(topConnName.getBytes(StandardCharsets.UTF_8)).toString()))
1096 .setName(Map.of(connName.key(), connName))
1097 .setConnectionEndPoint(new HashMap<>(Map.of(cep1.key(), cep1, cep2.key(), cep2)))
1098 .setOperationalState(OperationalState.ENABLED)
1099 .setLayerProtocolName(topPortocol)
1100 .setLifecycleState(LifecycleState.INSTALLED)
1101 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1102 .setLowerConnection(xcMap)
1106 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1107 .connectivity.context.Connection createXCBetweenCeps(
1108 ConnectionEndPoint cep1, ConnectionEndPoint cep2,
1109 String tp1, String tp2, String qual, LayerProtocolName xcProtocol) {
1110 String crossConnName = String.join("+", "XC", tp1, tp2, qual);
1111 LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
1112 LOG.info("Cross connection name = {}", crossConnName);
1113 LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint());
1114 LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint());
1115 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1116 .connection.ConnectionEndPoint cepServ1 =
1117 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1118 .connection.ConnectionEndPointBuilder()
1119 .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
1120 .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
1121 .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
1122 .setConnectionEndPointUuid(cep1.getUuid())
1124 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1125 .connection.ConnectionEndPoint cepServ2 =
1126 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1127 .connection.ConnectionEndPointBuilder()
1128 .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
1129 .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
1130 .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
1131 .setConnectionEndPointUuid(cep2.getUuid())
1133 Name connName = new NameBuilder()
1134 .setValueName("Connection name")
1135 .setValue(crossConnName)
1137 // TODO: lower connection, supported link.......
1138 return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1139 .connectivity.context.ConnectionBuilder()
1140 .setUuid(new Uuid(UUID.nameUUIDFromBytes(crossConnName.getBytes(StandardCharsets.UTF_8)).toString()))
1141 .setName(Map.of(connName.key(), connName))
1142 .setConnectionEndPoint(new HashMap<>(Map.of(cepServ1.key(), cepServ1, cepServ2.key(), cepServ2)))
1143 .setOperationalState(OperationalState.ENABLED)
1144 .setLayerProtocolName(xcProtocol)
1145 .setLifecycleState(LifecycleState.INSTALLED)
1146 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1150 private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
1151 String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]);
1152 String nodeNepId = String.join("+",id.split("\\+")[0], TapiStringConstants.PHTNC_MEDIA);
1153 LOG.info("NEP = {}", nepId);
1154 Name cepName = new NameBuilder()
1155 .setValueName("ConnectionEndPoint name")
1158 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1159 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1160 nepId.getBytes(StandardCharsets.UTF_8))
1162 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1163 nodeNepId.getBytes(StandardCharsets.UTF_8))
1165 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
1166 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
1169 String clientQualifier = "";
1170 switch (qualifier) {
1171 case TapiStringConstants.PHTNC_MEDIA_OTS:
1172 clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS;
1174 case TapiStringConstants.PHTNC_MEDIA_OMS:
1175 clientQualifier = TapiStringConstants.MC;
1176 OwnedNodeEdgePoint onepMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1177 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1178 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], TapiStringConstants.MC, onepMC);
1180 case TapiStringConstants.MC:
1181 clientQualifier = TapiStringConstants.OTSI_MC;
1182 OwnedNodeEdgePoint onepOTSiMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1],
1183 false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier);
1184 putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1],
1185 TapiStringConstants.OTSI_MC, onepOTSiMC);
1188 LOG.debug("not currently handling client NEP for OTSiMC CEP {}", nepId);
1191 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1192 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1193 (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
1194 .getBytes(StandardCharsets.UTF_8))
1196 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1197 nodeNepId.getBytes(StandardCharsets.UTF_8))
1199 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
1200 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
1203 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1204 // TODO: add parent ONEP??
1205 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1206 .setUuid(new Uuid(UUID.nameUUIDFromBytes(
1207 (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1]))
1208 .getBytes(StandardCharsets.UTF_8))
1210 .setParentNodeEdgePoint(pnep)
1211 .setName(Map.of(cepName.key(), cepName))
1212 .setConnectionPortRole(PortRole.SYMMETRIC)
1213 .setDirection(Direction.BIDIRECTIONAL)
1214 .setOperationalState(OperationalState.ENABLED)
1215 .setLifecycleState(LifecycleState.INSTALLED)
1216 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
1217 return TapiStringConstants.OTSI_MC.equals(qualifier)
1219 : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
1222 private ConnectionEndPoint createCepXpdr(
1223 String id, String qualifier, String nodeLayer, LayerProtocolName cepProtocol) {
1224 String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]);
1225 String nepNodeId = String.join("+",id.split("\\+")[0], TapiStringConstants.XPDR);
1226 Name cepName = new NameBuilder()
1227 .setValueName("ConnectionEndPoint name")
1230 ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
1231 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1232 nepId.getBytes(StandardCharsets.UTF_8)).toString()))
1233 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1234 nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
1235 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
1236 TapiStringConstants.T0_FULL_MULTILAYER
1237 .getBytes(StandardCharsets.UTF_8)).toString()))
1239 String clientQualifier = "";
1240 String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA;
1241 switch (qualifier) {
1242 case TapiStringConstants.PHTNC_MEDIA_OTS:
1243 clientQualifier = TapiStringConstants.OTSI_MC;
1245 case TapiStringConstants.OTSI_MC:
1246 clientQualifier = TapiStringConstants.E_ODU;
1247 clientNodeLayer = TapiStringConstants.ODU;
1249 case TapiStringConstants.E_ODU:
1250 clientQualifier = TapiStringConstants.DSR;
1251 clientNodeLayer = TapiStringConstants.DSR;
1254 LOG.debug("no client CEP for DSR NEP {}", nepId);
1257 ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
1258 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1259 (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
1260 .getBytes(StandardCharsets.UTF_8)).toString()))
1261 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1262 nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
1263 .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
1264 TapiStringConstants.T0_FULL_MULTILAYER
1265 .getBytes(StandardCharsets.UTF_8)).toString()))
1267 // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
1268 // TODO: add parent ONEP??
1269 ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
1270 .setUuid(new Uuid(UUID.nameUUIDFromBytes(
1271 (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1]))
1272 .getBytes(StandardCharsets.UTF_8)).toString()))
1273 .setParentNodeEdgePoint(pnep)
1274 .setName(Map.of(cepName.key(), cepName))
1275 .setConnectionPortRole(PortRole.SYMMETRIC)
1276 .setDirection(Direction.BIDIRECTIONAL)
1277 .setOperationalState(OperationalState.ENABLED)
1278 .setLifecycleState(LifecycleState.INSTALLED)
1279 .setLayerProtocolName(cepProtocol);
1280 return TapiStringConstants.DSR.equals(qualifier)
1282 : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
1285 private EndPoint mapServiceZEndPoint(
1286 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
1287 .service.ServiceZEnd serviceZEnd, PathDescription pathDescription) {
1288 EndPointBuilder endPointBuilder = new EndPointBuilder();
1289 // 1. Service Format: ODU, OTU, ETH
1290 ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
1291 String serviceNodeId = serviceZEnd.getNodeId().getValue();
1292 // Identify SIP name
1293 Uuid sipUuid = getSipIdFromZend(pathDescription.getZToADirection().getZToA(), serviceNodeId, serviceFormat);
1294 LOG.info("Uuid of z end {}", sipUuid);
1295 LayerProtocolName layerProtocols = null;
1296 // Layer protocol name
1297 switch (serviceFormat) {
1299 layerProtocols = LayerProtocolName.DSR;
1303 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1306 layerProtocols = LayerProtocolName.ODU;
1309 LOG.error("Service Format not supported");
1311 var portZEnd = serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
1312 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1313 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1314 .setValueName("OpenROADM info")
1315 .setValue(String.join("-", serviceZEnd.getClli(), portZEnd.getPortDeviceName(), portZEnd.getPortName()))
1317 return endPointBuilder
1318 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1319 .setServiceInterfacePointUuid(sipUuid)
1321 .setName(Map.of(name.key(), name))
1322 .setAdministrativeState(AdministrativeState.UNLOCKED)
1323 .setDirection(Direction.BIDIRECTIONAL)
1324 .setLifecycleState(LifecycleState.INSTALLED)
1325 .setOperationalState(OperationalState.ENABLED)
1326 .setLayerProtocolName(layerProtocols)
1327 .setCapacity(new CapacityBuilder()
1328 .setTotalSize(new TotalSizeBuilder()
1329 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
1330 .setUnit(CAPACITYUNITGBPS.VALUE)
1332 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1334 .setProtectionRole(ProtectionRole.WORK)
1335 .setRole(PortRole.SYMMETRIC)
1336 .setLocalId(portZEnd.getPortDeviceName())
1340 private EndPoint mapServiceAEndPoint(
1341 org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
1342 serviceAEnd, PathDescription pathDescription) {
1343 EndPointBuilder endPointBuilder = new EndPointBuilder();
1344 // 1. Service Format: ODU, OTU, ETH
1345 ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
1346 String serviceNodeId = serviceAEnd.getNodeId().getValue();
1347 // Identify SIP name
1348 Uuid sipUuid = getSipIdFromAend(pathDescription.getAToZDirection().getAToZ(), serviceNodeId, serviceFormat);
1349 LOG.info("Uuid of a end {}", sipUuid);
1350 LayerProtocolName layerProtocols = null;
1351 // Layer protocol name
1352 switch (serviceFormat) {
1354 layerProtocols = LayerProtocolName.DSR;
1358 layerProtocols = LayerProtocolName.PHOTONICMEDIA;
1361 layerProtocols = LayerProtocolName.ODU;
1364 LOG.error("Service Format not supported");
1366 var portAEnd = serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
1367 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
1368 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
1369 .setValueName("OpenROADM info")
1370 .setValue(String.join("-", serviceAEnd.getClli(), portAEnd.getPortDeviceName(), portAEnd.getPortName()))
1372 return endPointBuilder
1373 .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
1374 .setServiceInterfacePointUuid(sipUuid)
1376 .setName(Map.of(name.key(), name))
1377 .setAdministrativeState(AdministrativeState.UNLOCKED)
1378 .setDirection(Direction.BIDIRECTIONAL)
1379 .setLifecycleState(LifecycleState.INSTALLED)
1380 .setOperationalState(OperationalState.ENABLED)
1381 .setLayerProtocolName(layerProtocols)
1382 .setCapacity(new CapacityBuilder()
1383 .setTotalSize(new TotalSizeBuilder()
1384 .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceAEnd.getServiceRate().doubleValue())))
1385 .setUnit(CAPACITYUNITGBPS.VALUE)
1387 // .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
1389 .setProtectionRole(ProtectionRole.WORK)
1390 .setRole(PortRole.SYMMETRIC)
1391 .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
1392 .getPortDeviceName())
1396 private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
1397 if (serviceNodeId.contains("ROADM")) {
1398 // Service from ROADM to ROADM
1399 // AddDrop-AddDrop ports --> MC layer SIPs
1401 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
1402 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1403 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1404 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
1405 .getBytes(StandardCharsets.UTF_8)).toString());
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 return sip.getUuid();
1411 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1415 // Service from XPDR to XPDR
1417 TerminationPoint tp;
1419 switch (serviceFormat) {
1422 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
1423 tp = (TerminationPoint) firstElement.getResource().getResource();
1424 // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
1425 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1426 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
1427 .getBytes(StandardCharsets.UTF_8)).toString());
1428 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
1432 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
1433 tp = (TerminationPoint) firstElement.getResource().getResource();
1434 // Network-Network ports --> iOTSi layer SIPs
1435 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1436 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
1437 .getBytes(StandardCharsets.UTF_8)).toString());
1438 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
1441 LOG.info("Elements ZA = {}", mapztoa.values());
1443 mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
1444 tp = (TerminationPoint) firstElement.getResource().getResource();
1445 // Client-client ports --> DSR layer SIPs
1446 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1447 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
1448 .getBytes(StandardCharsets.UTF_8)).toString());
1449 LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
1453 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1455 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1456 if (sip.getUuid().equals(sipUuid)) {
1457 return sip.getUuid();
1459 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1464 private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
1465 LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
1466 LOG.info("Map a to z = {}", mapatoz);
1467 if (serviceNodeId.contains("ROADM")) {
1468 // Service from ROADM to ROADM
1469 // AddDrop-AddDrop ports --> MC layer SIPs
1471 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
1472 LOG.info("First element of service path = {}", firstElement.getResource().getResource());
1473 TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
1474 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1475 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
1476 .getBytes(StandardCharsets.UTF_8)).toString());
1477 LOG.info("ROADM SIP name = {}",
1478 String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
1479 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1480 if (sip.getUuid().equals(sipUuid)) {
1481 return sip.getUuid();
1483 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1487 // Service from XPDR to XPDR
1489 TerminationPoint tp;
1491 switch (serviceFormat) {
1494 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
1495 tp = (TerminationPoint) firstElement.getResource().getResource();
1496 // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
1497 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1498 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
1499 .getBytes(StandardCharsets.UTF_8)).toString());
1500 LOG.info("ODU XPDR SIP name = {}",
1501 String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
1505 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
1506 tp = (TerminationPoint) firstElement.getResource().getResource();
1507 // Network-Network ports --> iOTSi layer SIPs
1508 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1509 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
1510 .getBytes(StandardCharsets.UTF_8)).toString());
1511 LOG.info("OTU XPDR SIP name = {}",
1512 String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
1515 LOG.info("Elements AZ = {}", mapatoz.values());
1517 mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
1518 tp = (TerminationPoint) firstElement.getResource().getResource();
1519 // Client-client ports --> DSR layer SIPs
1520 sipUuid = new Uuid(UUID.nameUUIDFromBytes(
1521 (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
1522 .getBytes(StandardCharsets.UTF_8)).toString());
1523 LOG.info("DSR XPDR SIP name = {}",
1524 String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
1528 LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
1530 for (ServiceInterfacePoint sip:this.sipMap.values()) {
1531 if (sip.getUuid().equals(sipUuid)) {
1532 return sip.getUuid();
1534 LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
1539 private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
1540 String nepId = String.join("+", node, qual, spcRdmAD.split("\\+")[1]);
1541 String nodeNepId = String.join("+", node, TapiStringConstants.PHTNC_MEDIA);
1542 LOG.info("NEP id before Merge = {}", nepId);
1543 LOG.info("Node of NEP id before Merge = {}", nodeNepId);
1544 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1545 this.tapiContext.updateTopologyWithCep(
1547 new Uuid(UUID.nameUUIDFromBytes(
1548 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()),
1550 new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()),
1552 new Uuid(UUID.nameUUIDFromBytes(nepId.getBytes(StandardCharsets.UTF_8)).toString()),
1556 private void putXpdrCepInTopologyContext(
1557 String node, String spcXpdrNet, String qual, String nodeLayer, ConnectionEndPoint cep) {
1558 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1559 this.tapiContext.updateTopologyWithCep(
1561 new Uuid(UUID.nameUUIDFromBytes(
1562 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
1565 new Uuid(UUID.nameUUIDFromBytes(
1566 String.join("+", node, nodeLayer).getBytes(StandardCharsets.UTF_8))
1569 new Uuid(UUID.nameUUIDFromBytes(
1570 String.join("+", node, qual, spcXpdrNet.split("\\+")[1]).getBytes(StandardCharsets.UTF_8))
1576 private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
1577 String nepId = String.join("+", orNodeId, qual, orTpId);
1578 String nepNodeId = String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA);
1579 LOG.info("NEP id before Merge = {}", nepId);
1580 LOG.info("Node of NEP id before Merge = {}", nepNodeId);
1581 // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
1582 updateTopologyWithNep(
1584 new Uuid(UUID.nameUUIDFromBytes(
1585 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
1588 new Uuid(UUID.nameUUIDFromBytes(
1589 nepNodeId.getBytes(Charset.forName("UTF-8")))
1592 new Uuid(UUID.nameUUIDFromBytes(
1593 nepId.getBytes(Charset.forName("UTF-8")))
1598 private String getIdBasedOnModelVersion(String nodeid) {
1599 return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")
1600 ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
1601 : nodeid.split("-")[0];
1604 private ServiceZEnd tapiEndPointToServiceZPoint(
1605 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1606 .create.connectivity.service.input.EndPoint endPoint,
1607 ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
1608 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1609 // Not the rest which is needed in the txPortDeviceName.
1610 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1611 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1612 // Todo -> need to find the NEP associated to that SIP
1613 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString());
1614 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1615 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1617 LOG.error("Node not found in datastore");
1620 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1621 // connection is between 2 CLIENT ports. Otherwise it will not work...
1622 OwnedNodeEdgePoint nep = null;
1623 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1624 if (onep.getMappedServiceInterfacePoint() != null
1625 && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1631 LOG.error("Nep not found in datastore");
1634 String nodeName = "";
1636 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1637 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1638 endPoint.getName().entrySet()) {
1639 if (!("Node Type").equals(entry.getValue().getValueName())) {
1640 nodeName = entry.getValue().getValue();
1643 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1644 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1645 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1646 String txPortDeviceName = nepName.split("\\+")[0];
1647 String txPortName = nepName.split("\\+")[2];
1648 String rxPortDeviceName = txPortDeviceName;
1649 String rxPortName = txPortName;
1650 LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1651 LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1652 // TODO --> get clli from datastore?
1653 String clli = "NodeSC";
1654 LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1655 LOG.info("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1656 ServiceZEndBuilder serviceZEndBuilder = new ServiceZEndBuilder()
1658 .setNodeId(new NodeIdType(nodeid))
1659 .setOpticType(OpticTypes.Gray)
1660 .setServiceFormat(serviceFormat)
1661 .setServiceRate(Uint32.valueOf(capacity))
1662 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
1663 .setCommittedBurstSize(Uint16.valueOf(64))
1664 .setCommittedInfoRate(Uint32.valueOf(100000))
1667 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1668 .setPort(new PortBuilder()
1669 .setPortDeviceName(txPortDeviceName)
1670 .setPortName(txPortName)
1671 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1673 .setPortType(TapiStringConstants.PORT_TYPE)
1675 .setLgx(new LgxBuilder()
1676 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1677 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1678 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1679 .setLgxPortShelf("00")
1681 .setIndex(Uint8.ZERO)
1683 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1684 .setPort(new PortBuilder()
1685 .setPortDeviceName(rxPortDeviceName)
1686 .setPortName(rxPortName)
1687 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1689 .setPortType(TapiStringConstants.PORT_TYPE)
1691 .setLgx(new LgxBuilder()
1692 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1693 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1694 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1695 .setLgxPortShelf("00")
1697 .setIndex(Uint8.ZERO)
1699 if (serviceFormat.equals(ServiceFormat.ODU)) {
1700 serviceZEndBuilder.setOduServiceRate(ODU4.VALUE);
1702 if (serviceFormat.equals(ServiceFormat.OTU)) {
1703 serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
1705 return serviceLayer.equals(LayerProtocolName.ETH)
1706 ? serviceZEndBuilder.build()
1707 : serviceZEndBuilder
1708 .setEthernetAttributes(new EthernetAttributesBuilder()
1709 .setSubrateEthSla(new SubrateEthSlaBuilder()
1710 .setCommittedBurstSize(Uint16.valueOf(64))
1711 .setCommittedInfoRate(Uint32.valueOf(100000))
1717 private ServiceAEnd tapiEndPointToServiceAPoint(
1718 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1719 .create.connectivity.service.input.EndPoint endPoint,
1720 ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
1721 // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
1722 // Not the rest which is needed in the txPortDeviceName.
1723 // It could be obtained from the SIP which has the NEP and includes all the OR name.
1724 Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid();
1725 // Todo -> need to find the NEP associated to that SIP
1726 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString());
1727 LOG.info("NodeA {} Uuid is {}", nodeAid, nodeUuid);
1728 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
1729 this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
1731 LOG.error("Node not found in datastore");
1734 // TODO -> in case of a DSR service, for some requests we need the NETWORK PORT and not the CLIENT although the
1735 // connection is between 2 CLIENT ports. Otherwise it will not work...
1736 OwnedNodeEdgePoint nep = null;
1737 for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
1738 if (onep.getMappedServiceInterfacePoint() != null
1739 && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
1745 LOG.error("Nep not found in datastore");
1748 String nodeName = "";
1750 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
1751 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
1752 endPoint.getName().entrySet()) {
1753 if (!("Node Type").equals(entry.getValue().getValueName())) {
1754 nodeName = entry.getValue().getValue();
1757 // String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue();
1758 String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]);
1759 String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue();
1760 String txPortDeviceName = nepName.split("\\+")[0];
1761 String txPortName = nepName.split("\\+")[2];
1762 String rxPortDeviceName = txPortDeviceName;
1763 String rxPortName = txPortName;
1764 LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1765 LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1766 // TODO --> get clli from datastore?
1767 String clli = "NodeSA";
1768 LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
1769 LOG.info("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
1770 ServiceAEndBuilder serviceAEndBuilder = new ServiceAEndBuilder()
1772 .setNodeId(new NodeIdType(nodeid))
1773 .setOpticType(OpticTypes.Gray)
1774 .setServiceFormat(serviceFormat)
1775 .setServiceRate(Uint32.valueOf(capacity))
1776 .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
1777 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
1778 .subrate.eth.sla.SubrateEthSlaBuilder()
1779 .setCommittedBurstSize(Uint16.valueOf(64))
1780 .setCommittedInfoRate(Uint32.valueOf(100000))
1783 .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
1784 .setPort(new PortBuilder()
1785 .setPortDeviceName(txPortDeviceName)
1786 .setPortName(txPortName)
1787 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1789 .setPortType(TapiStringConstants.PORT_TYPE)
1791 .setLgx(new LgxBuilder()
1792 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1793 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1794 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1795 .setLgxPortShelf("00")
1797 .setIndex(Uint8.ZERO)
1799 .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
1800 .setPort(new PortBuilder()
1801 .setPortDeviceName(rxPortDeviceName)
1802 .setPortName(rxPortName)
1803 .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
1805 .setPortType(TapiStringConstants.PORT_TYPE)
1807 .setLgx(new LgxBuilder()
1808 .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
1809 .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
1810 .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
1811 .setLgxPortShelf("00")
1813 .setIndex(Uint8.ZERO)
1815 if (serviceFormat.equals(ServiceFormat.ODU)) {
1816 serviceAEndBuilder.setOduServiceRate(ODU4.VALUE);
1817 } else if (serviceFormat.equals(ServiceFormat.OTU)) {
1818 serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
1820 return serviceLayer.equals(LayerProtocolName.ETH)
1821 ? serviceAEndBuilder.build()
1822 : serviceAEndBuilder
1823 .setEthernetAttributes(new EthernetAttributesBuilder()
1824 .setSubrateEthSla(new SubrateEthSlaBuilder()
1825 .setCommittedBurstSize(Uint16.valueOf(64))
1826 .setCommittedInfoRate(Uint32.valueOf(100000))
1832 private ConnectionType getConnectionTypePhtnc(
1833 Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1834 .create.connectivity.service.input.EndPoint> endPoints) {
1835 return endPoints.stream()
1836 .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
1837 // EndPoints are ROADMs
1838 ? ConnectionType.RoadmLine
1839 // EndPoints are not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1840 : ConnectionType.Infrastructure;
1843 private ServiceFormat getServiceFormatPhtnc(
1844 Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
1845 .create.connectivity.service.input.EndPoint> endPoints) {
1846 return endPoints.stream()
1847 .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
1848 // EndPoints are ROADMs
1850 // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
1851 : ServiceFormat.OTU;
1854 private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
1855 return this.tapiContext.getTapiCEP(
1858 new Uuid(UUID.nameUUIDFromBytes(
1860 spcXpdrNetwork.split("\\+")[0],
1861 TapiStringConstants.XPDR)
1862 .getBytes(StandardCharsets.UTF_8))).toString()),
1864 new Uuid(UUID.nameUUIDFromBytes(
1866 spcXpdrNetwork.split("\\+")[0],
1867 TapiStringConstants.I_ODU,
1868 spcXpdrNetwork.split("\\+")[1])
1869 .getBytes(StandardCharsets.UTF_8))).toString()),
1871 new Uuid(UUID.nameUUIDFromBytes(
1874 spcXpdrNetwork.split("\\+")[0],
1875 TapiStringConstants.I_ODU,
1876 spcXpdrNetwork.split("\\+")[1]))
1877 .getBytes(StandardCharsets.UTF_8)).toString()));
1880 private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
1881 for (String networkPort:xpdrNetworkTplist) {
1882 if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) {
1889 private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
1890 List<String> clientPortList = new ArrayList<>();
1891 for (String networkPort:xpdrNetworkTplist) {
1892 String nodeId = String.join("-",
1893 networkPort.split("\\+")[0].split("-")[0],
1894 networkPort.split("\\+")[0].split("-")[1]);
1895 String tpId = networkPort.split("\\+")[1];
1896 InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
1897 .child(Nodes.class, new NodesKey(nodeId))
1898 .child(Mapping.class, new MappingKey(tpId)).build();
1900 Optional<Mapping> optMapping =
1901 this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, mapIID).get();
1902 if (optMapping.isEmpty()) {
1903 LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
1905 Mapping mapping = optMapping.orElseThrow();
1906 LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
1907 String key = String.join("+",
1908 String.join("-", nodeId, tpId.split("\\-")[0]),
1909 mapping.getConnectionMapLcp());
1910 LOG.info("Key to be added to list = {}", key);
1911 if (!clientPortList.contains(key)) {
1912 clientPortList.add(key);
1914 } catch (InterruptedException | ExecutionException e) {
1915 LOG.error("Couldnt read mapping from datastore", e);
1920 return clientPortList;
1923 private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
1924 List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
1925 for (String xpdrNode:xpdrNodelist) {
1926 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1927 .topology.Node> nodeIID =
1928 InstanceIdentifier.builder(Context.class)
1929 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
1930 .child(TopologyContext.class)
1931 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1933 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
1936 new Uuid(UUID.nameUUIDFromBytes(
1937 (String.join("+",xpdrNode, TapiStringConstants.XPDR))
1938 .getBytes(StandardCharsets.UTF_8)).toString())))
1941 Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode =
1942 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
1943 if (optNode.isEmpty()) {
1946 OpenroadmNodeType openroadmNodeType =
1947 OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(new NameKey("Node Type")).getValue());
1948 if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
1949 openroadmNodeTypeList.add(openroadmNodeType);
1951 } catch (InterruptedException | ExecutionException e) {
1952 LOG.error("Couldnt read node in topology", e);
1956 // TODO for now check that there is only one type, otherwise error
1957 if (openroadmNodeTypeList.size() == 1) {
1958 return openroadmNodeTypeList.get(0);
1960 LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
1964 private OwnedNodeEdgePoint createRoadmNep(
1965 String orNodeId, String tpId, boolean withSip,
1966 OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
1967 //TODO : complete implementation with SIP
1968 Name nepName = new NameBuilder()
1969 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
1970 .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
1972 return new OwnedNodeEdgePointBuilder()
1974 new Uuid(UUID.nameUUIDFromBytes(
1975 (String.join("+", orNodeId, nepPhotonicSublayer,tpId)).getBytes(StandardCharsets.UTF_8))
1977 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
1978 .setName(Map.of(nepName.key(), nepName))
1979 .setSupportedCepLayerProtocolQualifierInstances(
1980 new ArrayList<>(List.of(
1981 new SupportedCepLayerProtocolQualifierInstancesBuilder()
1982 .setLayerProtocolQualifier(
1983 TapiStringConstants.MC.equals(nepPhotonicSublayer)
1984 ? PHOTONICLAYERQUALIFIERMC.VALUE
1985 : PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
1986 .setNumberOfCepInstances(Uint64.valueOf(1))
1988 .setDirection(Direction.BIDIRECTIONAL)
1989 .setLinkPortRole(PortRole.SYMMETRIC)
1990 .setAdministrativeState(adminState).setOperationalState(operState)
1991 .setLifecycleState(LifecycleState.INSTALLED)