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.Charset;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Comparator;
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.List;
18 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.tapi.R2RTapiLinkDiscovery;
26 import org.opendaylight.transportpce.tapi.TapiStringConstants;
27 import org.opendaylight.transportpce.tapi.utils.TapiLink;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
118 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
119 import org.opendaylight.yangtools.yang.common.Uint16;
120 import org.opendaylight.yangtools.yang.common.Uint32;
121 import org.slf4j.Logger;
122 import org.slf4j.LoggerFactory;
124 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
126 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
127 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
128 .getBytes(Charset.forName("UTF-8"))).toString());
129 private final NetworkTransactionService networkTransactionService;
130 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
131 private final R2RTapiLinkDiscovery linkDiscovery;
132 private final TapiLink tapiLink;
134 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
135 NetworkTransactionService networkTransactionService, TapiLink tapiLink) {
136 this.networkTransactionService = networkTransactionService;
137 this.sipMap = new HashMap<>();
138 this.linkDiscovery = linkDiscovery;
139 this.tapiLink = tapiLink;
143 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
144 // TODO -> Implementation with PortMappingListener
145 // check if port mapping exists or not...
146 if (node.getMapping() == null) {
147 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
151 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
153 // check type of device, check version and create node mapping
154 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
156 // transform flat mapping list to per degree and per srg mapping lists
157 Map<String, List<Mapping>> mapDeg = new HashMap<>();
158 Map<String, List<Mapping>> mapSrg = new HashMap<>();
159 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
160 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
162 List<String> nodeShardList = getRoadmNodelist(mappingList);
164 // populate degree and srg LCP map
165 for (String str : nodeShardList) {
166 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
167 .collect(Collectors.toList());
168 if (str.contains("DEG")) {
169 mapDeg.put(str, interList);
170 } else if (str.contains("SRG")) {
171 mapSrg.put(str, interList);
173 LOG.error("unknown element");
176 // Transform LCPs into ONEP
177 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
178 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
179 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
182 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
183 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
184 mergeSipsinContext(this.sipMap);
185 // TODO add states corresponding to device config -> based on mapping.
186 // This should be possible after Gilles work is merged
188 // rdm to rdm link creation if neighbour roadm is mounted
189 LOG.info("checking if neighbor roadm exists");
190 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
192 if (!rdm2rdmLinks.isEmpty()) {
193 mergeLinkinTopology(rdm2rdmLinks);
195 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
196 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
197 List<Mapping> networkMappings = node.nonnullMapping().values()
198 .stream().filter(k -> k.getLogicalConnectionPoint()
199 .contains("NETWORK")).collect(Collectors.toList());
200 Map<Integer, String> xpdrMap = new HashMap<>();
201 for (Mapping mapping : networkMappings) {
202 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
203 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
204 if (!xpdrMap.containsKey(xpdrNb)) {
205 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
206 .stream().filter(k -> k.getLogicalConnectionPoint()
207 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
208 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
209 .stream().filter(k -> k.getLogicalConnectionPoint()
210 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
211 xpdrMap.put(xpdrNb, node.getNodeId());
213 // create switching pool
214 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
215 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
217 // node transformation
218 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
219 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool));
220 // add nodes and sips to tapi context
221 mergeNodeinTopology(nodeMap);
222 mergeSipsinContext(this.sipMap);
225 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
227 // Device not managed yet
230 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
231 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
232 OduSwitchingPools oorOduSwitchingPool) {
233 Map<NodeKey, Node> nodeMap = new HashMap<>();
234 LOG.info("creation of a DSR/ODU node for {}", nodeId);
235 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
236 .getBytes(Charset.forName("UTF-8"))).toString());
237 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
238 String.join("+", nodeId, TapiStringConstants.DSR)).build();
239 Name nameNodeType = new NameBuilder().setValueName("Node Type")
240 .setValue(getNodeType(xponderType)).build();
241 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
242 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
243 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
245 nodeMap.put(dsrNode.key(), dsrNode);
247 // node creation [otsi]
248 LOG.info("creation of an OTSi node for {}", nodeId);
249 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
250 .getBytes(Charset.forName("UTF-8"))).toString());
251 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
252 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
253 Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
254 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
255 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
257 nodeMap.put(otsiNode.key(), otsiNode);
259 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
260 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
261 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps, nodeUuidDsr,
263 mergeLinkinTopology(linkMap);
268 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
270 // todo: are switching pool correct here??
274 return createTpdrSwitchPool(xpdrNetMaps);
277 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
280 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
282 LOG.warn("Xpdr type {} not supported", xpdrType);
287 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
288 Map<String, List<Mapping>> mapSrg) {
289 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
290 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
291 // For each srg node. Loop through the LCPs and create neps and sips for PP
292 for (Mapping m:entry.getValue()) {
293 if (!m.getLogicalConnectionPoint().contains("PP")) {
294 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
297 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
298 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
299 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
300 onepMap.putAll(srgNeps);
306 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
307 Map<String, List<Mapping>> mapDeg) {
308 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
309 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
310 // For each degree node. Loop through the LCPs and create neps and sips for TTP
311 for (Mapping m:entry.getValue()) {
312 if (!m.getLogicalConnectionPoint().contains("TTP")) {
313 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
316 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
317 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
318 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
319 onepMap.putAll(degNeps);
325 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
326 List<String> nodeShardList = new ArrayList<>();
327 for (Mapping mapping : mappingList) {
328 // TODO -> maybe we need to check the id based on the version
329 String str = mapping.getLogicalConnectionPoint().split("-")[0];
330 LOG.info("LCP = {}", str);
331 if (!nodeShardList.contains(str)) {
332 nodeShardList.add(str);
335 return nodeShardList;
339 public void deleteTapinode(String nodeId) {
340 // TODO: check for null objects
341 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
342 // This will delete NEPs. Then check for links that have this node and delete them.
343 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
344 LOG.info("Deleting node {} from TAPI topology", nodeId);
345 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
346 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
347 new TopologyKey(tapiTopoUuid)).build();
348 Topology topology = null;
350 Optional<Topology> optTopology =
351 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
352 if (!optTopology.isPresent()) {
353 LOG.error("No topology object present. Error deleting node {}", nodeId);
356 topology = optTopology.get();
357 } catch (InterruptedException | ExecutionException e) {
358 LOG.error("Couldnt read tapi topology from datastore", e);
360 if (topology == null) {
361 LOG.error("Topology is null, nothing to delete");
364 if (topology.getNode() == null) {
365 LOG.error("No nodes in topology");
368 if (nodeId.contains("ROADM")) {
369 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
370 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
371 TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
372 deleteNodeFromTopo(nodeUuid);
374 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
375 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
376 for (Node tapiNode:topology.getNode().values()) {
377 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
378 // Found node we need to delete
379 deleteNodeFromTopo(tapiNode.getUuid());
383 // Delete links of topology
384 Map<LinkKey, Link> linkMap = topology.getLink();
385 if (linkMap != null) {
386 for (Link link:linkMap.values()) {
387 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
388 deleteLinkFromTopo(link.getUuid());
392 // Delete sips of sip map
393 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
394 Context context = null;
396 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
398 if (!optContext.isPresent()) {
399 LOG.error("No context object present in datastore.");
402 context = optContext.get();
403 } catch (InterruptedException | ExecutionException e) {
404 LOG.error("Couldnt read tapi context from datastore", e);
406 if (context == null) {
407 LOG.error("Context is null, nothing to delete");
410 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
412 for (ServiceInterfacePoint sip:sips.values()) {
413 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
414 // Update state of services that have this sip as an endpoint and also connections
415 updateConnectivityServicesState(sip.getUuid(), nodeId);
416 deleteSipFromTopo(sip.getUuid());
422 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
423 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
424 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
425 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
426 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
427 Map<RuleKey, Rule> ruleList = new HashMap<>();
428 Rule rule = new RuleBuilder()
429 .setLocalId("forward")
430 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
431 .setRuleType(RuleType.FORWARDING)
433 ruleList.put(rule.key(), rule);
434 if (layerProtocols.contains(LayerProtocolName.DSR)) {
435 // neps for dsr/odu layer
436 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
437 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
438 onepl.putAll(dsroduNeps);
439 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
440 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
441 // neps for photonic layer
442 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
443 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
444 onepl.putAll(phtmdNeps);
445 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
447 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
448 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
450 // Empty random creation of mandatory fields for avoiding errors....
451 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
452 .setCostAlgorithm("Restricted Shortest Path - RSP")
453 .setCostName("HOP_COUNT")
454 .setCostValue("12345678")
456 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
457 .setFixedLatencyCharacteristic("12345678")
458 .setQueingLatencyCharacteristic("12345678")
459 .setJitterCharacteristic("12345678")
460 .setWanderCharacteristic("12345678")
461 .setTrafficPropertyName("FIXED_LATENCY")
463 return new NodeBuilder()
466 .setLayerProtocolName(layerProtocols)
467 .setAdministrativeState(AdministrativeState.UNLOCKED)
468 .setOperationalState(OperationalState.ENABLED)
469 .setLifecycleState(LifecycleState.INSTALLED)
470 .setOwnedNodeEdgePoint(onepl)
471 .setNodeRuleGroup(nodeRuleGroupList)
472 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
473 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
474 .setErrorCharacteristic("error")
475 .setLossCharacteristic("loss")
476 .setRepeatDeliveryCharacteristic("repeat delivery")
477 .setDeliveryOrderCharacteristic("delivery order")
478 .setUnavailableTimeCharacteristic("unavailable time")
479 .setServerIntegrityProcessCharacteristic("server integrity process")
483 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
484 List<Mapping> xpdrNetMaps) {
485 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
487 // iNep creation on otsi node
488 for (int i = 0; i < xpdrNetMaps.size(); i++) {
489 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
490 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
491 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
492 Name onedName = new NameBuilder()
493 .setValueName("iNodeEdgePoint")
494 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
495 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
498 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
499 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
501 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
502 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
503 true, String.join("+", nodeId, TapiStringConstants.I_OTSI), newSupIfCapList,
504 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
505 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
506 onepl.put(onep.key(), onep);
508 // eNep creation on otsi node
509 for (int i = 0; i < xpdrNetMaps.size(); i++) {
510 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
511 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
512 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
513 Name onedName = new NameBuilder()
514 .setValueName("eNodeEdgePoint")
515 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
516 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
519 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
520 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
522 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
523 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
524 false, String.join("+", nodeId, TapiStringConstants.E_OTSI), newSupIfCapList,
525 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
526 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
527 onepl.put(onep.key(), onep);
529 // Photonic Media Nep creation on otsi node
530 for (int i = 0; i < xpdrNetMaps.size(); i++) {
531 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
532 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
533 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
534 Name onedName = new NameBuilder()
535 .setValueName("PhotMedNodeEdgePoint")
536 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
537 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
540 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
541 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
543 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
544 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
545 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA), newSupIfCapList,
546 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
547 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
548 onepl.put(onep.key(), onep);
553 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
554 List<Mapping> xpdrNetMaps,
555 XpdrNodeTypes xponderType) {
556 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
557 // client nep creation on DSR node
558 for (int i = 0; i < xpdrClMaps.size(); i++) {
559 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
560 xpdrClMaps.get(i).getLogicalConnectionPoint()));
561 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
562 (String.join("+", nodeId, TapiStringConstants.DSR,
563 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
564 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
565 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
567 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
568 name = nameBldr.setValueName("100G-tpdr").build();
570 name = nameBldr.setValueName("NodeEdgePoint_C").build();
573 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
574 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
576 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
577 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
578 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
579 transformOperState(xpdrClMaps.get(i).getPortOperState()),
580 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
581 onepl.put(onep.key(), onep);
583 // network nep creation on I_ODU node
584 for (int i = 0; i < xpdrNetMaps.size(); i++) {
585 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
586 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
587 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
588 (String.join("+", nodeId, TapiStringConstants.I_ODU,
589 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
590 Name onedName = new NameBuilder()
591 .setValueName("iNodeEdgePoint_N")
592 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
593 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
596 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
597 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
599 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
600 Map.of(onedName.key(), onedName),
601 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
602 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
603 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
604 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
605 onepl.put(onep.key(), onep);
607 // network nep creation on E_ODU node
608 for (int i = 0; i < xpdrClMaps.size(); i++) {
609 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
610 xpdrClMaps.get(i).getLogicalConnectionPoint()));
611 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
612 (String.join("+", nodeId, TapiStringConstants.E_ODU,
613 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
614 Name onedName = new NameBuilder()
615 .setValueName("eNodeEdgePoint_N")
616 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
617 xpdrClMaps.get(i).getLogicalConnectionPoint()))
620 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
621 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
623 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
624 Map.of(onedName.key(), onedName),
625 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
626 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
627 transformOperState(xpdrClMaps.get(i).getPortOperState()),
628 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
629 onepl.put(onep.key(), onep);
634 private OperationalState transformOperState(String operString) {
635 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
636 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
639 private AdministrativeState transformAdminState(String adminString) {
640 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
641 .setNetworkAdminState(adminString);
642 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
645 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
646 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
648 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
649 OperationalState operState, AdministrativeState adminState) {
650 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
652 .setLayerProtocolName(nepProtocol)
655 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
656 supportedInterfaceCapability, operState, adminState));
658 LOG.debug("Node layer {}", nodeProtocol.getName());
659 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
660 supportedInterfaceCapability, nepProtocol));
661 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
662 .setAdministrativeState(adminState).setOperationalState(operState)
663 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
664 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
665 return onepBldr.build();
668 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
669 boolean withSip, OperationalState operState,
670 AdministrativeState adminState) {
671 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
672 // PHOTONIC MEDIA nep
673 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
674 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
675 Name nepName = new NameBuilder()
676 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
677 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
679 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
681 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
682 .setName(Map.of(nepName.key(), nepName))
683 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.class))
684 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
685 .setAdministrativeState(adminState).setOperationalState(operState)
686 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
687 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
689 onepMap.put(onep.key(), onep);
692 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
693 TapiStringConstants.MC, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
694 Name nepName1 = new NameBuilder()
695 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
696 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
698 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
700 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
701 .setName(Map.of(nepName1.key(), nepName1))
702 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.class))
703 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
704 .setAdministrativeState(adminState).setOperationalState(operState)
705 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
706 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
708 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
709 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
710 operState, adminState));
712 OwnedNodeEdgePoint onep1 = onepBldr1.build();
713 onepMap.put(onep1.key(), onep1);
716 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
717 tpId)).getBytes(Charset.forName("UTF-8"))).toString());
718 Name nepName2 = new NameBuilder()
719 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
720 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
723 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
725 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
726 .setName(Map.of(nepName2.key(), nepName2))
727 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.class))
728 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
729 .setAdministrativeState(adminState).setOperationalState(operState)
730 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
731 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
733 onepMap.put(onep2.key(), onep2);
737 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
738 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
739 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
740 OperationalState operState, AdministrativeState adminState) {
741 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
742 for (int i = 0; i < nb; i++) {
743 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
744 tpid)).getBytes(Charset.forName("UTF-8"))).toString());
745 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
746 .setServiceInterfacePointUuid(sipUuid).build();
747 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
748 operState, adminState);
749 this.sipMap.put(sip.key(), sip);
750 LOG.info("SIP created {}", sip.getUuid());
751 // this.tapiSips.put(sip.key(), sip);
752 msipl.put(msip.key(), msip);
757 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
758 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
759 OperationalState operState, AdministrativeState adminState) {
760 // TODO: what value should be set in total capacity and available capacity
761 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
762 Name sipName = new NameBuilder()
763 .setValueName("SIP name")
764 .setValue(String.join("+", nodeid, tpid))
766 return new ServiceInterfacePointBuilder()
768 .setName(Map.of(sipName.key(), sipName))
769 .setLayerProtocolName(layerProtocol)
770 .setAdministrativeState(adminState)
771 .setOperationalState(operState)
772 .setLifecycleState(LifecycleState.INSTALLED)
773 .setAvailableCapacity(new AvailableCapacityBuilder().build())
774 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
775 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
780 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
782 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
783 TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
785 Name nodeNames = new NameBuilder().setValueName("roadm node name")
786 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
787 Name nameNodeType = new NameBuilder().setValueName("Node Type")
788 .setValue(OpenroadmNodeType.ROADM.getName()).build();
790 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
791 // Empty random creation of mandatory fields for avoiding errors....
792 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
793 .setCostAlgorithm("Restricted Shortest Path - RSP")
794 .setCostName("HOP_COUNT")
795 .setCostValue("12345678")
797 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
798 .setFixedLatencyCharacteristic("12345678")
799 .setQueingLatencyCharacteristic("12345678")
800 .setJitterCharacteristic("12345678")
801 .setWanderCharacteristic("12345678")
802 .setTrafficPropertyName("FIXED_LATENCY")
804 return new NodeBuilder()
806 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
807 .setLayerProtocolName(layerProtocols)
808 .setAdministrativeState(AdministrativeState.UNLOCKED)
809 .setOperationalState(OperationalState.ENABLED)
810 .setLifecycleState(LifecycleState.INSTALLED)
811 .setOwnedNodeEdgePoint(oneplist)
812 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
813 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
814 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
815 .setErrorCharacteristic("error")
816 .setLossCharacteristic("loss")
817 .setRepeatDeliveryCharacteristic("repeat delivery")
818 .setDeliveryOrderCharacteristic("delivery order")
819 .setUnavailableTimeCharacteristic("unavailable time")
820 .setServerIntegrityProcessCharacteristic("server integrity process")
824 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
825 Collection<OwnedNodeEdgePoint> onepl) {
826 Map<NodeEdgePointKey, NodeEdgePoint>
827 nepMap = new HashMap<>();
828 for (OwnedNodeEdgePoint onep : onepl) {
829 NodeEdgePoint nep = new NodeEdgePointBuilder()
830 .setTopologyUuid(this.tapiTopoUuid)
831 .setNodeUuid(nodeUuid)
832 .setNodeEdgePointUuid(onep.key().getUuid())
834 nepMap.put(nep.key(), nep);
836 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
837 Map<RuleKey, Rule> ruleList = new HashMap<>();
838 Rule rule = new RuleBuilder()
839 .setLocalId("forward")
840 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
841 .setRuleType(RuleType.FORWARDING)
843 ruleList.put(rule.key(), rule);
844 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
845 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
846 .getBytes(Charset.forName("UTF-8"))).toString()))
848 .setNodeEdgePoint(nepMap)
850 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
851 return nodeRuleGroupMap;
854 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps, Uuid nodeUuidDsr,
856 Map<LinkKey, Link> linkMap = new HashMap<>();
857 for (Mapping mapping : xpdrNetMaps) {
858 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
859 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
860 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
861 "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
862 Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
864 linkMap.put(transiLink.key(), transiLink);
866 // return a map of links and then we can do merge the corresponding link map into the topology context
870 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
871 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
873 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
874 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
875 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
876 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
877 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
878 Set<TpId> tpList = new HashSet<>();
881 NonBlockingList nbl = new NonBlockingListBuilder()
882 .setNblNumber(Uint16.valueOf(count))
885 nblMap.put(nbl.key(), nbl);
888 return new OduSwitchingPoolsBuilder()
889 .setNonBlockingList(nblMap)
890 .setSwitchingPoolNumber(Uint16.valueOf(1))
894 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
896 Set<TpId> tpl = new HashSet<>();
898 for (int i = 1; i <= xpdrClMaps.size(); i++) {
899 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
902 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
903 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
906 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
907 NonBlockingList nbl = new NonBlockingListBuilder()
908 .setNblNumber(Uint16.valueOf(1))
911 nbMap.put(nbl.key(),nbl);
913 return new OduSwitchingPoolsBuilder()
914 .setSwitchingPoolNumber(Uint16.valueOf(1))
915 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
916 .setNonBlockingList(nbMap)
920 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
921 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
922 for (int i = 1; i <= xpdrClMaps.size(); i++) {
923 Set<TpId> tpList = new HashSet<>();
924 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
926 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
928 NonBlockingList nbl = new NonBlockingListBuilder()
929 .setNblNumber(Uint16.valueOf(i))
931 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
932 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
934 nbMap.put(nbl.key(),nbl);
936 return new OduSwitchingPoolsBuilder()
937 .setSwitchingPoolNumber(Uint16.valueOf(1))
938 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
939 .setNonBlockingList(nbMap)
943 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
944 List<Mapping> xpdrNetMaps,
945 Map<RuleKey, Rule> ruleList) {
946 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
947 // create NodeRuleGroup
949 for (Mapping tpMapping : xpdrNetMaps) {
950 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
951 NodeEdgePoint inep = new NodeEdgePointBuilder()
952 .setTopologyUuid(this.tapiTopoUuid)
953 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
954 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
955 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
956 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
957 .getBytes(Charset.forName("UTF-8"))).toString()))
959 NodeEdgePoint enep = new NodeEdgePointBuilder()
960 .setTopologyUuid(this.tapiTopoUuid)
961 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
962 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
963 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
964 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
965 tpMapping.getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString()))
967 nepList.put(inep.key(), inep);
968 nepList.put(enep.key(), enep);
969 // Empty random creation of mandatory fields for avoiding errors....
970 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
971 .setCostAlgorithm("Restricted Shortest Path - RSP")
972 .setCostName("HOP_COUNT")
973 .setCostValue("12345678")
975 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
976 .setFixedLatencyCharacteristic("12345678")
977 .setQueingLatencyCharacteristic("12345678")
978 .setJitterCharacteristic("12345678")
979 .setWanderCharacteristic("12345678")
980 .setTrafficPropertyName("FIXED_LATENCY")
982 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
983 .setRiskCharacteristicName("risk characteristic")
984 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
986 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
988 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
991 .setNodeEdgePoint(nepList)
992 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
993 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
994 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
996 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
999 return nodeRuleGroupMap;
1002 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1003 OduSwitchingPools oorOduSwitchingPool,
1004 Map<RuleKey, Rule> ruleList,
1005 Map<OwnedNodeEdgePointKey,
1006 OwnedNodeEdgePoint> onepl) {
1007 // create NodeRuleGroup
1008 if (oorOduSwitchingPool == null) {
1009 LOG.info("No switching pool created for node = {}", nodeId);
1010 return new HashMap<>();
1012 LOG.info("ONEPL = {}", onepl.values());
1013 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1015 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1016 LOG.info("Non blocking list = {}", nbl);
1017 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1018 for (TpId tp : nbl.getTpList()) {
1019 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1020 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1021 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1022 TapiStringConstants.E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1023 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1024 TapiStringConstants.DSR, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1025 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1026 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1027 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1028 .setTopologyUuid(this.tapiTopoUuid)
1029 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1030 (String.join("+", nodeId,TapiStringConstants. DSR))
1031 .getBytes(Charset.forName("UTF-8"))).toString()))
1032 .setNodeEdgePointUuid(tp1Uuid)
1034 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1035 .setTopologyUuid(this.tapiTopoUuid)
1036 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1037 (String.join("+", nodeId,TapiStringConstants. DSR))
1038 .getBytes(Charset.forName("UTF-8"))).toString()))
1039 .setNodeEdgePointUuid(tpUuid)
1041 nepList.put(nep1.key(), nep1);
1042 nepList.put(nep2.key(), nep2);
1045 // Empty random creation of mandatory fields for avoiding errors....
1046 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1047 .setCostAlgorithm("Restricted Shortest Path - RSP")
1048 .setCostName("HOP_COUNT")
1049 .setCostValue("12345678")
1051 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1052 .setFixedLatencyCharacteristic("12345678")
1053 .setQueingLatencyCharacteristic("12345678")
1054 .setJitterCharacteristic("12345678")
1055 .setWanderCharacteristic("12345678")
1056 .setTrafficPropertyName("FIXED_LATENCY")
1058 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1059 .setRiskCharacteristicName("risk characteristic")
1060 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1062 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1064 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1067 .setNodeEdgePoint(nepList)
1068 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1069 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1070 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1072 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1075 return nodeRuleGroupMap;
1078 private Set<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1079 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1080 if (sicList == null) {
1081 return Set.of(PHOTONICLAYERQUALIFIEROMS.class);
1083 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1084 LOG.info("SIC list = {}", sicList);
1085 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1086 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1087 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1088 .setIfCapType(supInterCapa)
1090 supIfMap.put(supIfCapa.key(), supIfCapa);
1092 Set<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new HashSet<>();
1093 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1094 switch (lpn.getName()) {
1096 switch (sic.getIfCapType().getSimpleName()) {
1097 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1098 // port are extended in the config file
1100 sclpqList.add(ODUTYPEODU0.class);
1101 sclpqList.add(DIGITALSIGNALTYPEGigE.class);
1104 sclpqList.add(ODUTYPEODU2E.class);
1105 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1108 sclpqList.add(ODUTYPEODU2.class);
1109 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1112 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1115 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1116 sclpqList.add(ODUTYPEODU4.class);
1119 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1121 case "IfOCHOTU4ODU4":
1123 sclpqList.add(ODUTYPEODU4.class);
1126 LOG.error("IfCapability type not managed");
1131 switch (sic.getIfCapType().getSimpleName()) {
1132 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1133 // port are extended in the config file
1135 sclpqList.add(ODUTYPEODU0.class);
1138 sclpqList.add(ODUTYPEODU2E.class);
1142 sclpqList.add(ODUTYPEODU2.class);
1146 case "IfOCHOTU4ODU4":
1148 sclpqList.add(ODUTYPEODU4.class);
1151 LOG.error("IfCapability type not managed");
1155 case "PHOTONIC_MEDIA":
1156 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1157 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1158 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1159 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1163 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1170 private String getNodeType(XpdrNodeTypes xponderType) {
1171 switch (xponderType.getIntValue()) {
1173 return OpenroadmNodeType.TPDR.getName();
1175 return OpenroadmNodeType.MUXPDR.getName();
1177 return OpenroadmNodeType.SWITCH.getName();
1179 LOG.info("XpdrType {} not supported", xponderType);
1185 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1186 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1187 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1188 LOG.info("Creating tapi node in TAPI topology context");
1189 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1190 .augmentation(Context1.class).child(TopologyContext.class)
1191 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1194 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1196 // merge in datastore
1197 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1200 this.networkTransactionService.commit().get();
1201 } catch (InterruptedException | ExecutionException e) {
1202 LOG.error("Error populating TAPI topology: ", e);
1204 LOG.info("Node added succesfully.");
1207 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1208 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1209 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1210 LOG.info("Creating tapi node in TAPI topology context");
1211 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1212 .augmentation(Context1.class).child(TopologyContext.class)
1213 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1216 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1218 // merge in datastore
1219 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1222 this.networkTransactionService.commit().get();
1223 } catch (InterruptedException | ExecutionException e) {
1224 LOG.error("Error populating TAPI topology: ", e);
1226 LOG.info("Roadm Link added succesfully.");
1229 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1230 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1231 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1233 ContextBuilder contextBuilder = new ContextBuilder();
1234 contextBuilder.setServiceInterfacePoint(sips);
1235 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1236 // merge in datastore
1237 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1238 contextBuilder.build());
1239 this.networkTransactionService.commit().get();
1240 LOG.info("TAPI SIPs merged successfully.");
1241 } catch (InterruptedException | ExecutionException e) {
1242 LOG.error("Failed to merge TAPI Sips", e);
1246 private void deleteLinkFromTopo(Uuid linkUuid) {
1247 // TODO: check if this IID is correct
1249 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1250 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1251 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1252 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1253 this.networkTransactionService.commit().get();
1254 LOG.info("TAPI link deleted successfully.");
1255 } catch (InterruptedException | ExecutionException e) {
1256 LOG.error("Failed to delete TAPI link", e);
1260 private void deleteNodeFromTopo(Uuid nodeUuid) {
1261 // TODO: check if this IID is correct
1263 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1264 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1265 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1266 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1267 this.networkTransactionService.commit().get();
1268 LOG.info("TAPI Node deleted successfully.");
1269 } catch (InterruptedException | ExecutionException e) {
1270 LOG.error("Failed to delete TAPI Node", e);
1274 private void deleteSipFromTopo(Uuid sipUuid) {
1275 // TODO: check if this IID is correct
1277 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1278 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1279 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1280 this.networkTransactionService.commit().get();
1281 LOG.info("TAPI SIP deleted successfully.");
1282 } catch (InterruptedException | ExecutionException e) {
1283 LOG.error("Failed to delete TAPI SIP", e);
1287 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1288 // TODO: check if this IID is correct
1289 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1290 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1291 .child(ConnectivityContext.class)
1293 ConnectivityContext connContext = null;
1295 Optional<ConnectivityContext> optConnContext =
1296 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1298 if (!optConnContext.isPresent()) {
1299 LOG.error("Couldnt retrieve connectivity context from datastore");
1302 connContext = optConnContext.get();
1303 } catch (InterruptedException | ExecutionException e) {
1304 LOG.error("Couldnt read connectivity context from datastore", e);
1306 if (connContext == null) {
1307 LOG.error("Connectivity context is empty");
1310 // Loop through services, check if the endpoint uuid is equal to the sip.
1311 // If so update state.
1312 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1313 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1314 if (connServMap != null) {
1315 for (ConnectivityService service:connServMap.values()) {
1316 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1317 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1318 .getServiceInterfacePointUuid().equals(sipUuid))) {
1319 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1320 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1321 .setAdministrativeState(AdministrativeState.LOCKED)
1322 .setOperationalState(OperationalState.DISABLED)
1323 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1325 updateConnectivityService(updService);
1329 // Update state of connections
1330 if (connMap != null) {
1331 for (Connection connection:connMap.values()) {
1332 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1333 Connection updConn = new ConnectionBuilder(connection)
1334 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1335 .setOperationalState(OperationalState.DISABLED)
1337 updateConnection(updConn);
1343 private void updateConnection(Connection updConn) {
1344 // TODO: check if this IID is correct
1345 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1346 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1347 .child(ConnectivityContext.class).child(Connection.class,
1348 new ConnectionKey(updConn.getUuid())).build();
1349 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1351 this.networkTransactionService.commit().get();
1352 } catch (InterruptedException | ExecutionException e) {
1353 LOG.error("Error committing into datastore", e);
1357 private void updateConnectivityService(ConnectivityService updService) {
1358 // TODO: check if this IID is correct
1359 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1360 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1361 .child(ConnectivityContext.class).child(ConnectivityService.class,
1362 new ConnectivityServiceKey(updService.getUuid())).build();
1363 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1365 this.networkTransactionService.commit().get();
1366 } catch (InterruptedException | ExecutionException e) {
1367 LOG.error("Error committing into datastore", e);