2 * Copyright © 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.topology;
10 import java.nio.charset.StandardCharsets;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Collections;
14 import java.util.Comparator;
15 import java.util.HashMap;
16 import java.util.HashSet;
17 import java.util.List;
19 import java.util.Objects;
20 import java.util.Optional;
22 import java.util.UUID;
23 import java.util.concurrent.ExecutionException;
24 import java.util.stream.Collectors;
25 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
26 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
28 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
29 import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery;
30 import org.opendaylight.transportpce.tapi.TapiStringConstants;
31 import org.opendaylight.transportpce.tapi.utils.TapiLink;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.SupportedIfCapability;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
49 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
50 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ContextBuilder;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.AvailableCapacityBuilder;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.TotalPotentialCapacityBuilder;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointBuilder;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1Builder;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceKey;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.ConnectivityContext;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepList;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPEGigE;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPEATTRIBUTEVALUECHANGE;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NotificationBuilder;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributes;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributesBuilder;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributesKey;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.NodeEdgePointRef;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPENODEEDGEPOINT;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupBuilder;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPac;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePoint;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointBuilder;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleBuilder;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleKey;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkBuilder;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node;
130 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeBuilder;
131 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
132 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
133 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyBuilder;
134 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
135 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristic;
136 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristicBuilder;
137 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristic;
138 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristicBuilder;
139 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
140 import org.opendaylight.yangtools.yang.binding.Notification;
141 import org.opendaylight.yangtools.yang.common.Uint16;
142 import org.opendaylight.yangtools.yang.common.Uint32;
143 import org.opendaylight.yangtools.yang.common.Uint64;
144 import org.osgi.service.component.annotations.Activate;
145 import org.osgi.service.component.annotations.Component;
146 import org.osgi.service.component.annotations.Reference;
147 import org.slf4j.Logger;
148 import org.slf4j.LoggerFactory;
152 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
154 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
156 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
157 .getBytes(StandardCharsets.UTF_8)).toString());
158 private final NetworkTransactionService networkTransactionService;
159 private final R2RTapiLinkDiscovery linkDiscovery;
160 private final TapiLink tapiLink;
161 private final NotificationPublishService notificationPublishService;
162 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap = new HashMap<>();
165 public TapiNetworkModelServiceImpl(@Reference NetworkTransactionService networkTransactionService,
166 @Reference DeviceTransactionManager deviceTransactionManager,
167 @Reference TapiLink tapiLink,
168 @Reference final NotificationPublishService notificationPublishService) {
169 this.networkTransactionService = networkTransactionService;
170 this.linkDiscovery = new R2RTapiLinkDiscovery(networkTransactionService, deviceTransactionManager, tapiLink);
171 this.tapiLink = tapiLink;
172 this.notificationPublishService = notificationPublishService;
176 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
177 // TODO -> Implementation with PortMappingListener
178 // check if port mapping exists or not...
179 if (node.getMapping() == null) {
180 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
184 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
186 // check type of device, check version and create node mapping
187 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
189 // transform flat mapping list to per degree and per srg mapping lists
190 Map<String, List<Mapping>> mapDeg = new HashMap<>();
191 Map<String, List<Mapping>> mapSrg = new HashMap<>();
192 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
193 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
195 List<String> nodeShardList = getRoadmNodelist(mappingList);
197 // populate degree and srg LCP map
198 for (String str : nodeShardList) {
199 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
200 .collect(Collectors.toList());
201 if (str.contains("DEG")) {
202 mapDeg.put(str, interList);
203 } else if (str.contains("SRG")) {
204 mapSrg.put(str, interList);
206 LOG.error("unknown element");
209 // Transform LCPs into ONEP
210 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
211 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
212 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
215 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
216 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
217 mergeSipsinContext(this.sipMap);
218 // TODO add states corresponding to device config -> based on mapping.
219 // This should be possible after Gilles work is merged
221 // rdm to rdm link creation if neighbour roadm is mounted
222 LOG.info("checking if neighbor roadm exists");
223 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
225 if (!rdm2rdmLinks.isEmpty()) {
226 mergeLinkinTopology(rdm2rdmLinks);
228 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
229 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
230 List<Mapping> networkMappings = node.nonnullMapping().values()
231 .stream().filter(k -> k.getLogicalConnectionPoint()
232 .contains("NETWORK")).collect(Collectors.toList());
233 Map<Integer, String> xpdrMap = new HashMap<>();
234 for (Mapping mapping : networkMappings) {
235 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
236 String nodeId = node.getNodeId() + TapiStringConstants.XXPDR + xpdrNb;
237 if (!xpdrMap.containsKey(xpdrNb)) {
238 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
239 .stream().filter(k -> k.getLogicalConnectionPoint()
240 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
241 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
242 .stream().filter(k -> k.getLogicalConnectionPoint()
243 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
244 xpdrMap.put(xpdrNb, node.getNodeId());
246 // create switching pool
247 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
248 mapping.getXpdrType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
250 // node transformation
251 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
252 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXpdrType(), oorOduSwitchingPool));
253 // add nodes and sips to tapi context
254 mergeNodeinTopology(nodeMap);
255 mergeSipsinContext(this.sipMap);
258 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
260 // Device not managed yet
264 public void updateTapiTopology(String nodeId, Mapping mapping) {
265 List<Uuid> uuids = getChangedNodeUuids(nodeId, mapping);
267 List<Uuid> changedOneps = updateNeps(mapping, uuids);
268 updateLinks(changedOneps, mapping);
269 sendNotification(changedOneps, mapping);
271 LOG.info("Updated TAPI topology successfully.");
274 @SuppressWarnings("rawtypes")
275 private void sendNotification(List<Uuid> changedOneps, Mapping mapping) {
276 Notification notification = new NotificationBuilder()
277 .setNotificationType(NOTIFICATIONTYPEATTRIBUTEVALUECHANGE.VALUE)
278 // .setTargetObjectType(ObjectType.NODEEDGEPOINT)
279 //TODO: Change this : modification in Models 2.4 does not provide for Object type Node EdgePoint
280 .setTargetObjectType(TOPOLOGYOBJECTTYPENODEEDGEPOINT.VALUE)
281 .setChangedAttributes(getChangedAttributes(changedOneps, mapping))
282 .setUuid(tapiTopoUuid)
285 notificationPublishService.putNotification(notification);
286 } catch (InterruptedException e) {
287 LOG.error("Could not send notification");
291 private Map<ChangedAttributesKey, ChangedAttributes> getChangedAttributes(List<Uuid> changedOneps,
293 Map<ChangedAttributesKey, ChangedAttributes> changedAttributes = new HashMap<>();
294 for (Uuid nep : changedOneps) {
295 changedAttributes.put(new ChangedAttributesKey(nep.getValue()),
296 new ChangedAttributesBuilder().setValueName(nep.getValue())
297 .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService")
298 .setNewValue(mapping.getPortOperState())
301 return changedAttributes;
304 private void updateLinks(List<Uuid> changedOneps, Mapping mapping) {
306 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
307 .augmentation(Context1.class).child(TopologyContext.class)
308 .child(Topology.class, new TopologyKey(tapiTopoUuid))
310 Optional<Topology> optTopology = this.networkTransactionService
311 .read(LogicalDatastoreType.OPERATIONAL, topoIID).get();
312 if (optTopology.isEmpty()) {
313 LOG.error("Could not update TAPI links");
316 int nbAffectedLinks = 0;
317 LOG.info("UUIDofAffectedONEPS = {} ", changedOneps.toString());
318 for (Link link : optTopology.orElseThrow().nonnullLink().values()) {
319 List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
320 .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
321 LOG.info("LinkEndPointsUUID = {} for link Name {}", linkNeps.toString(), link.getName().toString());
322 if (!Collections.disjoint(changedOneps, linkNeps)) {
323 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
324 .augmentation(Context1.class).child(TopologyContext.class)
325 .child(Topology.class, new TopologyKey(tapiTopoUuid))
326 .child(Link.class, new LinkKey(link.getUuid())).build();
327 Link linkblr = new LinkBuilder().setUuid(link.getUuid())
328 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
329 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
330 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr);
334 LOG.info("AffectedLinksNb = {} ", nbAffectedLinks);
335 this.networkTransactionService.commit().get();
336 } catch (InterruptedException | ExecutionException e) {
337 LOG.error("Could not update TAPI links");
341 private List<Uuid> updateNeps(Mapping mapping, List<Uuid> uuids) {
342 List<Uuid> changedOneps = new ArrayList<>();
343 for (Uuid nodeUuid : uuids) {
345 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
346 .augmentation(Context1.class).child(TopologyContext.class)
347 .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
349 Optional<Node> optionalNode = this.networkTransactionService.read(
350 LogicalDatastoreType.OPERATIONAL, nodeIID).get();
351 if (optionalNode.isPresent()) {
352 Node node = optionalNode.orElseThrow();
353 List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
354 .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
355 .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
356 for (OwnedNodeEdgePoint onep : oneps) {
357 changedOneps.add(onep.getUuid());
358 updateSips(mapping, onep);
359 CepList cepList = getUpdatedCeps(mapping, onep);
360 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
361 .augmentation(Context1.class).child(TopologyContext.class)
362 .child(Topology.class, new TopologyKey(tapiTopoUuid))
363 .child(Node.class, new NodeKey(nodeUuid))
364 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid()))
366 OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid())
367 .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build())
368 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
369 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
370 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr);
371 LOG.info("UpdatedNEP {} of UUID {} to ADMIN {} OPER {}",
372 onep.getName().toString(), onep.getUuid(),
373 transformAdminState(mapping.getPortAdminState()),
374 transformOperState(mapping.getPortOperState()));
376 this.networkTransactionService.commit().get();
378 } catch (InterruptedException | ExecutionException e) {
379 LOG.error("Could not update TAPI NEP");
385 private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) {
386 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
387 Map<ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
388 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) {
389 for (Map.Entry<ConnectionEndPointKey, ConnectionEndPoint> entry : onep1.getCepList().getConnectionEndPoint()
391 ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue())
392 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
393 cepMap.put(entry.getKey(), cep);
396 return new CepListBuilder().setConnectionEndPoint(cepMap).build();
399 private List<Uuid> getChangedNodeUuids(String nodeId, Mapping mapping) {
400 List<Uuid> uuids = new ArrayList<>();
401 if (nodeId.contains("ROADM")) {
402 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA))
403 .getBytes(StandardCharsets.UTF_8)).toString()));
404 } else if (nodeId.contains("PDR")) {
405 LOG.debug("ANALYSING change in {}", nodeId);
406 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
407 String xpdrNodeId = nodeId + TapiStringConstants.XXPDR + xpdrNb;
408 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.XPDR))
409 .getBytes(StandardCharsets.UTF_8)).toString()));
411 LOG.error("Updating this device is currently not supported");
417 private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) {
418 if (onep.getMappedServiceInterfacePoint() == null
419 || onep.getMappedServiceInterfacePoint().size() == 0) {
422 for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) {
423 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier
424 .builder(Context.class)
425 .child(ServiceInterfacePoint.class,
426 new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid()))
428 ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder()
429 .setUuid(msip.getServiceInterfacePointUuid())
430 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
431 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
432 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr);
437 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
438 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
439 OduSwitchingPools oorOduSwitchingPool) {
440 Map<NodeKey, Node> nodeMap = new HashMap<>();
441 LOG.info("creation of a DSR/ODU node for {}", nodeId);
442 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.XPDR))
443 .getBytes(StandardCharsets.UTF_8)).toString());
444 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
445 String.join("+", nodeId, TapiStringConstants.XPDR)).build();
446 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
447 String.join("+", nodeId, TapiStringConstants.XPDR)).build();
448 Name nameNodeType = new NameBuilder().setValueName("Node Type")
449 .setValue(getNodeType(xponderType)).build();
450 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
451 LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA);
452 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameOtsi.key(), nameOtsi, nameNodeType.key(),
453 nameNodeType), dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType,
454 oorOduSwitchingPool);
456 nodeMap.put(dsrNode.key(), dsrNode);
460 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
462 // todo: are switching pool correct here??
466 return createTpdrSwitchPool(xpdrNetMaps);
469 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
472 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
474 LOG.warn("Xpdr type {} not supported", xpdrType);
479 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
480 Map<String, List<Mapping>> mapSrg) {
481 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
482 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
483 // For each srg node. Loop through the LCPs and create neps and sips for PP
484 for (Mapping m:entry.getValue()) {
485 if (!m.getLogicalConnectionPoint().contains("PP")) {
486 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
489 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
490 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
491 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()),
492 TapiStringConstants.PHTNC_MEDIA_OTS);
493 onepMap.putAll(srgNeps);
499 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
500 Map<String, List<Mapping>> mapDeg) {
501 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
502 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
503 // For each degree node. Loop through the LCPs and create neps and sips for TTP
504 for (Mapping m:entry.getValue()) {
505 if (!m.getLogicalConnectionPoint().contains("TTP")) {
506 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
509 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
510 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
511 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()),
512 TapiStringConstants.PHTNC_MEDIA_OTS);
513 degNeps.putAll(createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
514 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()),
515 TapiStringConstants.PHTNC_MEDIA_OMS));
516 onepMap.putAll(degNeps);
522 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
523 List<String> nodeShardList = new ArrayList<>();
524 for (Mapping mapping : mappingList) {
525 // TODO -> maybe we need to check the id based on the version
526 String str = mapping.getLogicalConnectionPoint().split("-")[0];
527 LOG.info("LCP = {}", str);
528 if (!nodeShardList.contains(str)) {
529 nodeShardList.add(str);
532 return nodeShardList;
536 public void deleteTapinode(String nodeId) {
537 // TODO: check for null objects
538 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
539 // This will delete NEPs. Then check for links that have this node and delete them.
540 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
541 LOG.info("Deleting node {} from TAPI topology", nodeId);
542 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
543 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
544 new TopologyKey(tapiTopoUuid)).build();
545 Topology topology = null;
547 Optional<Topology> optTopology =
548 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
549 if (!optTopology.isPresent()) {
550 LOG.error("No topology object present. Error deleting node {}", nodeId);
553 topology = optTopology.orElseThrow();
554 } catch (InterruptedException | ExecutionException e) {
555 LOG.error("Couldnt read tapi topology from datastore", e);
557 if (topology == null) {
558 LOG.error("Topology is null, nothing to delete");
561 if (topology.getNode() == null) {
562 LOG.error("No nodes in topology");
565 if (nodeId.contains("ROADM")) {
566 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
567 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
568 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
569 deleteNodeFromTopo(nodeUuid);
571 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
572 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
573 for (Node tapiNode:topology.getNode().values()) {
574 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
575 // Found node we need to delete
576 deleteNodeFromTopo(tapiNode.getUuid());
580 // Delete links of topology
581 Map<LinkKey, Link> linkMap = topology.getLink();
582 if (linkMap != null) {
583 for (Link link:linkMap.values()) {
584 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
585 deleteLinkFromTopo(link.getUuid());
589 // Delete sips of sip map
590 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
591 Context context = null;
593 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
595 if (!optContext.isPresent()) {
596 LOG.error("No context object present in datastore.");
599 context = optContext.orElseThrow();
600 } catch (InterruptedException | ExecutionException e) {
601 LOG.error("Couldnt read tapi context from datastore", e);
603 if (context == null) {
604 LOG.error("Context is null, nothing to delete");
607 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
609 for (ServiceInterfacePoint sip:sips.values()) {
610 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
611 // Update state of services that have this sip as an endpoint and also connections
612 updateConnectivityServicesState(sip.getUuid(), nodeId);
613 deleteSipFromTopo(sip.getUuid());
619 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
620 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
621 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
623 Map<RuleKey, Rule> ruleList = new HashMap<>();
624 Set<RuleType> ruleTypes = new HashSet<>();
625 ruleTypes.add(RuleType.FORWARDING);
626 Rule rule = new RuleBuilder()
627 .setLocalId("forward")
628 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
629 .setRuleType(ruleTypes)
631 ruleList.put(rule.key(), rule);
632 if (!(layerProtocols.contains(LayerProtocolName.DSR)
633 && layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA))) {
634 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
635 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
637 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
638 onepl.putAll(createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType));
639 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = createNodeRuleGroupForDsrNode(
640 nodeId, oorOduSwitchingPool, ruleList, onepl);
641 onepl.putAll(createXpdrPhtnMdNeps(nodeId, xpdrNetMaps));
643 // Empty random creation of mandatory fields for avoiding errors....
644 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
645 .setCostAlgorithm("Restricted Shortest Path - RSP")
646 .setCostName("HOP_COUNT")
647 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
649 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
650 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
651 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
652 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
653 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
654 .setTrafficPropertyName("FIXED_LATENCY")
656 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
657 .setRiskCharacteristicName("risk characteristic")
658 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
660 RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
661 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
663 return new NodeBuilder()
666 .setLayerProtocolName(layerProtocols)
667 .setAdministrativeState(AdministrativeState.UNLOCKED)
668 .setOperationalState(OperationalState.ENABLED)
669 .setLifecycleState(LifecycleState.INSTALLED)
670 .setOwnedNodeEdgePoint(onepl)
671 .setNodeRuleGroup(nodeRuleGroupList)
672 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
673 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
674 .setErrorCharacteristic("error")
675 .setLossCharacteristic("loss")
676 .setRepeatDeliveryCharacteristic("repeat delivery")
677 .setDeliveryOrderCharacteristic("delivery order")
678 .setUnavailableTimeCharacteristic("unavailable time")
679 .setServerIntegrityProcessCharacteristic("server integrity process")
680 .setRiskParameterPac(riskParamPac)
684 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
685 List<Mapping> xpdrNetMaps) {
686 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
688 // eNep creation on otsi node
689 for (int i = 0; i < xpdrNetMaps.size(); i++) {
690 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
691 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
692 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
693 Name onedName = new NameBuilder()
694 .setValueName("eNodeEdgePoint")
695 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
696 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
699 List<SupportedIfCapability> newSupIfCapList =
700 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
702 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
703 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
704 true, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS), newSupIfCapList,
705 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
706 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
707 onepl.put(onep.key(), onep);
709 // OTSi_MC Nep creation on otsi node
710 for (int i = 0; i < xpdrNetMaps.size(); i++) {
711 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
712 (String.join("+", nodeId, TapiStringConstants.OTSI_MC,
713 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
714 Name onedName = new NameBuilder()
715 .setValueName("PhotMedNodeEdgePoint")
716 .setValue(String.join("+", nodeId, TapiStringConstants.OTSI_MC,
717 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
720 List<SupportedIfCapability> newSupIfCapList =
721 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
723 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
724 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
725 false, String.join("+", nodeId, TapiStringConstants.OTSI_MC), newSupIfCapList,
726 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
727 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
728 onepl.put(onep.key(), onep);
733 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
734 List<Mapping> xpdrNetMaps,
735 XpdrNodeTypes xponderType) {
736 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
737 // client nep creation on DSR node
738 for (int i = 0; i < xpdrClMaps.size(); i++) {
739 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
740 xpdrClMaps.get(i).getLogicalConnectionPoint()));
741 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
742 (String.join("+", nodeId, TapiStringConstants.DSR,
743 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
744 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
745 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
747 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
748 name = nameBldr.setValueName("100G-tpdr").build();
750 name = nameBldr.setValueName("NodeEdgePoint_C").build();
753 List<SupportedIfCapability> newSupIfCapList =
754 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
756 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
757 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
758 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
759 transformOperState(xpdrClMaps.get(i).getPortOperState()),
760 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
761 onepl.put(onep.key(), onep);
763 // network nep creation on I_ODU node
764 for (int i = 0; i < xpdrNetMaps.size(); i++) {
765 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
766 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
767 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
768 (String.join("+", nodeId, TapiStringConstants.I_ODU,
769 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
770 Name onedName = new NameBuilder()
771 .setValueName("iNodeEdgePoint_N")
772 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
773 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
776 List<SupportedIfCapability> newSupIfCapList =
777 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
779 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
780 Map.of(onedName.key(), onedName),
781 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
782 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
783 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
784 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
785 onepl.put(onep.key(), onep);
787 // network nep creation on E_ODU node
788 for (int i = 0; i < xpdrClMaps.size(); i++) {
789 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
790 xpdrClMaps.get(i).getLogicalConnectionPoint()));
791 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
792 (String.join("+", nodeId, TapiStringConstants.E_ODU,
793 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
794 Name onedName = new NameBuilder()
795 .setValueName("eNodeEdgePoint_N")
796 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
797 xpdrClMaps.get(i).getLogicalConnectionPoint()))
800 List<SupportedIfCapability> newSupIfCapList =
801 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
803 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
804 Map.of(onedName.key(), onedName),
805 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
806 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
807 transformOperState(xpdrClMaps.get(i).getPortOperState()),
808 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
809 onepl.put(onep.key(), onep);
814 private OperationalState transformOperState(String operString) {
815 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
816 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
819 private AdministrativeState transformAdminState(String adminString) {
820 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
821 .setNetworkAdminState(adminString);
822 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
825 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
826 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
828 List<SupportedIfCapability> supportedInterfaceCapability,
829 OperationalState operState, AdministrativeState adminState) {
830 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
832 .setLayerProtocolName(nepProtocol)
835 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
836 supportedInterfaceCapability, operState, adminState));
838 LOG.debug("Node layer {}", nodeProtocol.getName());
839 onepBldr.setSupportedCepLayerProtocolQualifierInstances(createSupportedLayerProtocolQualifier(
840 supportedInterfaceCapability, nepProtocol));
841 onepBldr.setDirection(Direction.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
842 .setAdministrativeState(adminState).setOperationalState(operState)
843 .setLifecycleState(LifecycleState.INSTALLED);
844 return onepBldr.build();
847 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
848 boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
849 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
850 // PHOTONIC MEDIA nep
851 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
852 nepPhotonicSublayer, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
853 Name nepName = new NameBuilder()
854 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
855 .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
857 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
859 new SupportedCepLayerProtocolQualifierInstancesBuilder()
860 .setLayerProtocolQualifier(
861 TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
862 ? PHOTONICLAYERQUALIFIEROMS.VALUE
863 : PHOTONICLAYERQUALIFIEROTS.VALUE)
864 .setNumberOfCepInstances(Uint64.valueOf(1))
866 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
868 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
869 .setName(Map.of(nepName.key(), nepName))
870 .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
871 .setDirection(Direction.BIDIRECTIONAL)
872 .setLinkPortRole(PortRole.SYMMETRIC)
873 .setAdministrativeState(adminState).setOperationalState(operState)
874 .setLifecycleState(LifecycleState.INSTALLED)
876 onepMap.put(onep.key(), onep);
880 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
881 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
882 List<SupportedIfCapability> supportedInterfaceCapability,
883 OperationalState operState, AdministrativeState adminState) {
884 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
885 for (int i = 0; i < nb; i++) {
886 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
887 tpid)).getBytes(StandardCharsets.UTF_8)).toString());
888 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
889 .setServiceInterfacePointUuid(sipUuid).build();
890 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
891 operState, adminState);
892 this.sipMap.put(sip.key(), sip);
893 // this.tapiSips.put(sip.key(), sip);
894 msipl.put(msip.key(), msip);
895 LOG.info("SIP created {}", sip.getUuid());
896 LOG.info("This SIP corresponds to SIP+nodeId {} + TpId {}", nodeid, tpid);
901 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
902 List<SupportedIfCapability> supportedInterfaceCapability,
903 OperationalState operState, AdministrativeState adminState) {
904 // TODO: what value should be set in total capacity and available capacity
905 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
906 Name sipName = new NameBuilder()
907 .setValueName("SIP name")
908 .setValue(String.join("+", nodeid, tpid))
910 return new ServiceInterfacePointBuilder()
912 .setName(Map.of(sipName.key(), sipName))
913 .setLayerProtocolName(layerProtocol)
914 .setAdministrativeState(adminState)
915 .setOperationalState(operState)
916 .setLifecycleState(LifecycleState.INSTALLED)
917 .setAvailableCapacity(new AvailableCapacityBuilder().build())
918 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
919 .setSupportedCepLayerProtocolQualifierInstances(createSipSupportedLayerProtocolQualifier(
920 supportedInterfaceCapability, layerProtocol))
924 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
926 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
927 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
929 Name nodeNames = new NameBuilder().setValueName("roadm node name")
930 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
931 Name nameNodeType = new NameBuilder().setValueName("Node Type")
932 .setValue(OpenroadmNodeType.ROADM.getName()).build();
934 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
935 // Empty random creation of mandatory fields for avoiding errors....
936 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
937 .setCostAlgorithm("Restricted Shortest Path - RSP")
938 .setCostName("HOP_COUNT")
939 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
941 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
942 .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE)
943 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
944 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
945 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
946 .setTrafficPropertyName("FIXED_LATENCY")
948 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
949 .setRiskCharacteristicName("risk characteristic")
950 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
952 RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
953 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
955 return new NodeBuilder()
957 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
958 .setLayerProtocolName(layerProtocols)
959 .setAdministrativeState(AdministrativeState.UNLOCKED)
960 .setOperationalState(OperationalState.ENABLED)
961 .setLifecycleState(LifecycleState.INSTALLED)
962 .setOwnedNodeEdgePoint(oneplist)
963 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
964 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
965 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
966 .setErrorCharacteristic("error")
967 .setLossCharacteristic("loss")
968 .setRepeatDeliveryCharacteristic("repeat delivery")
969 .setDeliveryOrderCharacteristic("delivery order")
970 .setUnavailableTimeCharacteristic("unavailable time")
971 .setServerIntegrityProcessCharacteristic("server integrity process")
972 .setRiskParameterPac(riskParamPac)
976 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
977 Collection<OwnedNodeEdgePoint> onepl) {
978 Map<NodeEdgePointKey, NodeEdgePoint>
979 nepMap = new HashMap<>();
980 for (OwnedNodeEdgePoint onep : onepl) {
981 NodeEdgePoint nep = new NodeEdgePointBuilder()
982 .setTopologyUuid(this.tapiTopoUuid)
983 .setNodeUuid(nodeUuid)
984 .setNodeEdgePointUuid(onep.key().getUuid())
986 nepMap.put(nep.key(), nep);
988 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
989 Map<RuleKey, Rule> ruleList = new HashMap<>();
990 Set<RuleType> ruleTypes = new HashSet<>();
991 ruleTypes.add(RuleType.FORWARDING);
992 Rule rule = new RuleBuilder()
993 .setLocalId("forward")
994 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
995 .setRuleType(ruleTypes)
997 ruleList.put(rule.key(), rule);
998 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
999 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
1000 .getBytes(StandardCharsets.UTF_8)).toString()))
1002 .setNodeEdgePoint(nepMap)
1004 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1005 return nodeRuleGroupMap;
1008 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
1009 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
1011 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1012 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1013 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1014 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1015 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1016 Set<TpId> tpList = new HashSet<>();
1019 NonBlockingList nbl = new NonBlockingListBuilder()
1020 .setNblNumber(Uint16.valueOf(count))
1023 nblMap.put(nbl.key(), nbl);
1026 return new OduSwitchingPoolsBuilder()
1027 .setNonBlockingList(nblMap)
1028 .setSwitchingPoolNumber(Uint16.valueOf(1))
1032 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
1034 Set<TpId> tpl = new HashSet<>();
1036 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1037 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1040 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1041 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
1044 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1045 NonBlockingList nbl = new NonBlockingListBuilder()
1046 .setNblNumber(Uint16.valueOf(1))
1049 nbMap.put(nbl.key(),nbl);
1051 return new OduSwitchingPoolsBuilder()
1052 .setSwitchingPoolNumber(Uint16.valueOf(1))
1053 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1054 .setNonBlockingList(nbMap)
1058 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
1059 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1060 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1061 Set<TpId> tpList = new HashSet<>();
1062 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1064 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
1066 NonBlockingList nbl = new NonBlockingListBuilder()
1067 .setNblNumber(Uint16.valueOf(i))
1069 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
1070 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
1072 nbMap.put(nbl.key(),nbl);
1074 return new OduSwitchingPoolsBuilder()
1075 .setSwitchingPoolNumber(Uint16.valueOf(1))
1076 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1077 .setNonBlockingList(nbMap)
1081 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1082 OduSwitchingPools oorOduSwitchingPool,
1083 Map<RuleKey, Rule> ruleList,
1084 Map<OwnedNodeEdgePointKey,
1085 OwnedNodeEdgePoint> onepl) {
1086 // create NodeRuleGroup
1087 if (oorOduSwitchingPool == null) {
1088 LOG.info("No switching pool created for node = {}", nodeId);
1089 return new HashMap<>();
1091 LOG.info("ONEPL = {}", onepl.values());
1092 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1094 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1095 LOG.info("Non blocking list = {}", nbl);
1096 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1097 for (TpId tp : nbl.getTpList()) {
1098 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1099 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1100 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1101 TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1102 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1103 TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1104 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1105 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1106 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1107 .setTopologyUuid(this.tapiTopoUuid)
1108 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1109 (String.join("+", nodeId,TapiStringConstants. DSR))
1110 .getBytes(StandardCharsets.UTF_8)).toString()))
1111 .setNodeEdgePointUuid(tp1Uuid)
1113 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1114 .setTopologyUuid(this.tapiTopoUuid)
1115 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1116 (String.join("+", nodeId,TapiStringConstants. DSR))
1117 .getBytes(StandardCharsets.UTF_8)).toString()))
1118 .setNodeEdgePointUuid(tpUuid)
1120 nepList.put(nep1.key(), nep1);
1121 nepList.put(nep2.key(), nep2);
1124 // Empty random creation of mandatory fields for avoiding errors....
1125 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1126 .setCostAlgorithm("Restricted Shortest Path - RSP")
1127 .setCostName("HOP_COUNT")
1128 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1130 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1131 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1132 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1133 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1134 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1135 .setTrafficPropertyName("FIXED_LATENCY")
1137 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1138 .setRiskCharacteristicName("risk characteristic")
1139 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1141 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1143 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8))
1146 .setNodeEdgePoint(nepList)
1147 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1148 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1149 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1151 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1154 return nodeRuleGroupMap;
1157 private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1158 .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
1159 createSipSupportedLayerProtocolQualifier(List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1160 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1161 .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1162 if (sicList == null) {
1163 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1164 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1165 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROMS.VALUE)
1166 .setNumberOfCepInstances(Uint64.valueOf(1))
1170 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1171 LOG.info("SIC list = {}", sicList);
1172 for (SupportedIfCapability supInterCapa : sicList) {
1173 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1174 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1175 .setIfCapType(supInterCapa)
1177 supIfMap.put(supIfCapa.key(), supIfCapa);
1179 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1180 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1181 switch (lpn.getName()) {
1183 switch (ifCapType) {
1184 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1185 // port are extended in the config file
1187 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1188 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1189 .setLayerProtocolQualifier(ODUTYPEODU0.VALUE)
1190 .setNumberOfCepInstances(Uint64.valueOf(0))
1192 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1193 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1194 .setLayerProtocolQualifier(DIGITALSIGNALTYPEGigE.VALUE)
1195 .setNumberOfCepInstances(Uint64.valueOf(0))
1199 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1200 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1201 .setLayerProtocolQualifier(ODUTYPEODU2E.VALUE)
1202 .setNumberOfCepInstances(Uint64.valueOf(0))
1204 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1205 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1206 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1207 .setNumberOfCepInstances(Uint64.valueOf(0))
1211 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1212 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1213 .setLayerProtocolQualifier(ODUTYPEODU2.VALUE)
1214 .setNumberOfCepInstances(Uint64.valueOf(0))
1216 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1217 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1218 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1219 .setNumberOfCepInstances(Uint64.valueOf(0))
1223 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1224 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1225 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1226 .setNumberOfCepInstances(Uint64.valueOf(0))
1230 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1231 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1232 .setLayerProtocolQualifier(DIGITALSIGNALTYPE100GigE.VALUE)
1233 .setNumberOfCepInstances(Uint64.valueOf(0))
1235 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1236 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1237 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1238 .setNumberOfCepInstances(Uint64.valueOf(0))
1242 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1243 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1244 .setLayerProtocolQualifier(DIGITALSIGNALTYPE100GigE.VALUE)
1245 .setNumberOfCepInstances(Uint64.valueOf(0))
1248 case "IfOCHOTU4ODU4":
1250 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1251 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1252 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1253 .setNumberOfCepInstances(Uint64.valueOf(0))
1257 LOG.error("IfCapability type not managed");
1262 switch (ifCapType) {
1263 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1264 // port are extended in the config file
1266 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1267 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1268 .setLayerProtocolQualifier(ODUTYPEODU0.VALUE)
1269 .setNumberOfCepInstances(Uint64.valueOf(0))
1273 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1274 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1275 .setLayerProtocolQualifier(ODUTYPEODU2E.VALUE)
1276 .setNumberOfCepInstances(Uint64.valueOf(0))
1281 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1282 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1283 .setLayerProtocolQualifier(ODUTYPEODU2.VALUE)
1284 .setNumberOfCepInstances(Uint64.valueOf(0))
1289 case "IfOCHOTU4ODU4":
1291 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1292 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1293 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1294 .setNumberOfCepInstances(Uint64.valueOf(0))
1298 LOG.error("IfCapability type not managed");
1302 case "PHOTONIC_MEDIA":
1303 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1304 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1305 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1306 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
1307 .setNumberOfCepInstances(Uint64.valueOf(0))
1309 sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1310 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1311 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
1312 .setNumberOfCepInstances(Uint64.valueOf(0))
1317 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1324 private List<SupportedCepLayerProtocolQualifierInstances> createSupportedLayerProtocolQualifier(
1325 List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1326 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1327 if (sicList == null) {
1328 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1329 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROMS.VALUE)
1330 .setNumberOfCepInstances(Uint64.valueOf(1))
1334 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1335 LOG.info("SIC list = {}", sicList);
1336 for (SupportedIfCapability supInterCapa : sicList) {
1337 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1338 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1339 .setIfCapType(supInterCapa)
1341 supIfMap.put(supIfCapa.key(), supIfCapa);
1343 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1344 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1345 switch (lpn.getName()) {
1347 switch (ifCapType) {
1348 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1349 // port are extended in the config file
1351 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1352 .setLayerProtocolQualifier(ODUTYPEODU0.VALUE)
1353 .setNumberOfCepInstances(Uint64.valueOf(0))
1355 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1356 .setLayerProtocolQualifier(DIGITALSIGNALTYPEGigE.VALUE)
1357 .setNumberOfCepInstances(Uint64.valueOf(0))
1361 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1362 .setLayerProtocolQualifier(ODUTYPEODU2E.VALUE)
1363 .setNumberOfCepInstances(Uint64.valueOf(0))
1365 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1366 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1367 .setNumberOfCepInstances(Uint64.valueOf(0))
1371 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1372 .setLayerProtocolQualifier(ODUTYPEODU2.VALUE)
1373 .setNumberOfCepInstances(Uint64.valueOf(0))
1375 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1376 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1377 .setNumberOfCepInstances(Uint64.valueOf(0))
1381 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1382 .setLayerProtocolQualifier(DIGITALSIGNALTYPE10GigELAN.VALUE)
1383 .setNumberOfCepInstances(Uint64.valueOf(0))
1387 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1388 .setLayerProtocolQualifier(DIGITALSIGNALTYPE100GigE.VALUE)
1389 .setNumberOfCepInstances(Uint64.valueOf(0))
1391 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1392 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1393 .setNumberOfCepInstances(Uint64.valueOf(0))
1397 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1398 .setLayerProtocolQualifier(DIGITALSIGNALTYPE100GigE.VALUE)
1399 .setNumberOfCepInstances(Uint64.valueOf(0))
1402 case "IfOCHOTU4ODU4":
1404 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1405 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1406 .setNumberOfCepInstances(Uint64.valueOf(0))
1410 LOG.error("IfCapability type not managed");
1415 switch (ifCapType) {
1416 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1417 // port are extended in the config file
1419 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1420 .setLayerProtocolQualifier(ODUTYPEODU0.VALUE)
1421 .setNumberOfCepInstances(Uint64.valueOf(0))
1425 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1426 .setLayerProtocolQualifier(ODUTYPEODU2E.VALUE)
1427 .setNumberOfCepInstances(Uint64.valueOf(0))
1432 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1433 .setLayerProtocolQualifier(ODUTYPEODU2.VALUE)
1434 .setNumberOfCepInstances(Uint64.valueOf(0))
1439 case "IfOCHOTU4ODU4":
1441 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1442 .setLayerProtocolQualifier(ODUTYPEODU4.VALUE)
1443 .setNumberOfCepInstances(Uint64.valueOf(0))
1447 LOG.error("IfCapability type not managed");
1451 case "PHOTONIC_MEDIA":
1452 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1453 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1454 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
1455 .setNumberOfCepInstances(Uint64.valueOf(0))
1457 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
1458 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
1459 .setNumberOfCepInstances(Uint64.valueOf(0))
1464 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1471 private String getNodeType(XpdrNodeTypes xponderType) {
1472 switch (xponderType.getIntValue()) {
1474 return OpenroadmNodeType.TPDR.getName();
1476 return OpenroadmNodeType.MUXPDR.getName();
1478 return OpenroadmNodeType.SWITCH.getName();
1480 LOG.info("XpdrType {} not supported", xponderType);
1486 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1487 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1488 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1489 LOG.info("Creating tapi node in TAPI topology context");
1490 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1491 .augmentation(Context1.class).child(TopologyContext.class)
1492 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1495 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1497 // merge in datastore
1498 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1501 this.networkTransactionService.commit().get();
1502 } catch (InterruptedException | ExecutionException e) {
1503 LOG.error("Error populating TAPI topology: ", e);
1505 LOG.info("Node added succesfully.");
1508 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1509 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1510 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1511 LOG.info("Creating tapi node in TAPI topology context");
1512 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1513 .augmentation(Context1.class).child(TopologyContext.class)
1514 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1517 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1519 // merge in datastore
1520 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1523 this.networkTransactionService.commit().get();
1524 } catch (InterruptedException | ExecutionException e) {
1525 LOG.error("Error populating TAPI topology: ", e);
1527 LOG.info("Roadm Link added succesfully.");
1530 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1531 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1532 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1534 ContextBuilder contextBuilder = new ContextBuilder();
1535 contextBuilder.setServiceInterfacePoint(sips);
1536 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1537 // merge in datastore
1538 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1539 contextBuilder.build());
1540 this.networkTransactionService.commit().get();
1541 LOG.info("TAPI SIPs merged successfully.");
1542 } catch (InterruptedException | ExecutionException e) {
1543 LOG.error("Failed to merge TAPI Sips", e);
1547 private void deleteLinkFromTopo(Uuid linkUuid) {
1548 // TODO: check if this IID is correct
1550 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1551 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1552 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1553 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1554 this.networkTransactionService.commit().get();
1555 LOG.info("TAPI link deleted successfully.");
1556 } catch (InterruptedException | ExecutionException e) {
1557 LOG.error("Failed to delete TAPI link", e);
1561 private void deleteNodeFromTopo(Uuid nodeUuid) {
1562 // TODO: check if this IID is correct
1564 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1565 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1566 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1567 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1568 this.networkTransactionService.commit().get();
1569 LOG.info("TAPI Node deleted successfully.");
1570 } catch (InterruptedException | ExecutionException e) {
1571 LOG.error("Failed to delete TAPI Node", e);
1575 private void deleteSipFromTopo(Uuid sipUuid) {
1576 // TODO: check if this IID is correct
1578 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1579 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1580 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1581 this.networkTransactionService.commit().get();
1582 LOG.info("TAPI SIP deleted successfully.");
1583 } catch (InterruptedException | ExecutionException e) {
1584 LOG.error("Failed to delete TAPI SIP", e);
1588 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1589 // TODO: check if this IID is correct
1590 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1591 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class)
1592 .child(ConnectivityContext.class)
1594 ConnectivityContext connContext = null;
1596 Optional<ConnectivityContext> optConnContext =
1597 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1599 if (!optConnContext.isPresent()) {
1600 LOG.error("Couldnt retrieve connectivity context from datastore");
1603 connContext = optConnContext.orElseThrow();
1604 } catch (InterruptedException | ExecutionException e) {
1605 LOG.error("Couldnt read connectivity context from datastore", e);
1607 if (connContext == null) {
1608 LOG.error("Connectivity context is empty");
1611 // Loop through services, check if the endpoint uuid is equal to the sip.
1612 // If so update state.
1613 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1614 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1615 if (connServMap != null) {
1616 for (ConnectivityService service:connServMap.values()) {
1617 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1618 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1619 .getServiceInterfacePointUuid().equals(sipUuid))) {
1620 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1621 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1622 .setAdministrativeState(AdministrativeState.LOCKED)
1623 .setOperationalState(OperationalState.DISABLED)
1624 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1626 updateConnectivityService(updService);
1630 // Update state of connections
1631 if (connMap != null) {
1632 for (Connection connection:connMap.values()) {
1633 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1634 Connection updConn = new ConnectionBuilder(connection)
1635 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1636 .setOperationalState(OperationalState.DISABLED)
1638 updateConnection(updConn);
1644 private void updateConnection(Connection updConn) {
1645 // TODO: check if this IID is correct
1646 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1647 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class)
1648 .child(ConnectivityContext.class).child(Connection.class,
1649 new ConnectionKey(updConn.getUuid())).build();
1650 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1652 this.networkTransactionService.commit().get();
1653 } catch (InterruptedException | ExecutionException e) {
1654 LOG.error("Error committing into datastore", e);
1658 private void updateConnectivityService(ConnectivityService updService) {
1659 // TODO: check if this IID is correct
1660 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1661 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class)
1662 .child(ConnectivityContext.class).child(ConnectivityService.class,
1663 new ConnectivityServiceKey(updService.getUuid())).build();
1664 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1666 this.networkTransactionService.commit().get();
1667 } catch (InterruptedException | ExecutionException e) {
1668 LOG.error("Error committing into datastore", e);