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.Arrays;
13 import java.util.Collection;
14 import java.util.Comparator;
15 import java.util.HashMap;
16 import java.util.List;
18 import java.util.Optional;
19 import java.util.UUID;
20 import java.util.concurrent.ExecutionException;
21 import java.util.stream.Collectors;
22 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
23 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
24 import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery;
25 import org.opendaylight.transportpce.tapi.TapiStringConstants;
26 import org.opendaylight.transportpce.tapi.utils.TapiLink;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
117 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
118 import org.opendaylight.yangtools.yang.common.Uint16;
119 import org.opendaylight.yangtools.yang.common.Uint32;
120 import org.slf4j.Logger;
121 import org.slf4j.LoggerFactory;
123 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
125 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
126 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
127 .getBytes(Charset.forName("UTF-8"))).toString());
128 private final NetworkTransactionService networkTransactionService;
129 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
130 private final R2RTapiLinkDiscovery linkDiscovery;
131 private final TapiLink tapiLink;
133 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
134 NetworkTransactionService networkTransactionService, TapiLink tapiLink) {
135 this.networkTransactionService = networkTransactionService;
136 this.sipMap = new HashMap<>();
137 this.linkDiscovery = linkDiscovery;
138 this.tapiLink = tapiLink;
142 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
143 // TODO -> Implementation with PortMappingListener
144 // check if port mapping exists or not...
145 if (node.getMapping() == null) {
146 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
150 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
152 // check type of device, check version and create node mapping
153 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
155 // transform flat mapping list to per degree and per srg mapping lists
156 Map<String, List<Mapping>> mapDeg = new HashMap<>();
157 Map<String, List<Mapping>> mapSrg = new HashMap<>();
158 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
159 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
161 List<String> nodeShardList = getRoadmNodelist(mappingList);
163 // populate degree and srg LCP map
164 for (String str : nodeShardList) {
165 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
166 .collect(Collectors.toList());
167 if (str.contains("DEG")) {
168 mapDeg.put(str, interList);
169 } else if (str.contains("SRG")) {
170 mapSrg.put(str, interList);
172 LOG.error("unknown element");
175 // Transform LCPs into ONEP
176 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
177 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
178 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
181 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
182 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
183 mergeSipsinContext(this.sipMap);
184 // TODO add states corresponding to device config -> based on mapping.
185 // This should be possible after Gilles work is merged
187 // rdm to rdm link creation if neighbour roadm is mounted
188 LOG.info("checking if neighbor roadm exists");
189 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
191 if (!rdm2rdmLinks.isEmpty()) {
192 mergeLinkinTopology(rdm2rdmLinks);
194 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
195 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
196 List<Mapping> networkMappings = node.nonnullMapping().values()
197 .stream().filter(k -> k.getLogicalConnectionPoint()
198 .contains("NETWORK")).collect(Collectors.toList());
199 Map<Integer, String> xpdrMap = new HashMap<>();
200 for (Mapping mapping : networkMappings) {
201 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
202 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
203 if (!xpdrMap.containsKey(xpdrNb)) {
204 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
205 .stream().filter(k -> k.getLogicalConnectionPoint()
206 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
207 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
208 .stream().filter(k -> k.getLogicalConnectionPoint()
209 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
210 xpdrMap.put(xpdrNb, node.getNodeId());
212 // create switching pool
213 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
214 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
216 // node transformation
217 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
218 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool));
219 // add nodes and sips to tapi context
220 mergeNodeinTopology(nodeMap);
221 mergeSipsinContext(this.sipMap);
224 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
226 // Device not managed yet
229 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
230 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
231 OduSwitchingPools oorOduSwitchingPool) {
232 Map<NodeKey, Node> nodeMap = new HashMap<>();
233 LOG.info("creation of a DSR/ODU node for {}", nodeId);
234 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
235 .getBytes(Charset.forName("UTF-8"))).toString());
236 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
237 String.join("+", nodeId, TapiStringConstants.DSR)).build();
238 Name nameNodeType = new NameBuilder().setValueName("Node Type")
239 .setValue(getNodeType(xponderType)).build();
240 List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR,
241 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 List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(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, List<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 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
499 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
500 true, String.join("+", nodeId, TapiStringConstants.I_OTSI),
501 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
502 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
503 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
504 onepl.put(onep.key(), onep);
506 // eNep creation on otsi node
507 for (int i = 0; i < xpdrNetMaps.size(); i++) {
508 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
509 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
510 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
511 Name onedName = new NameBuilder()
512 .setValueName("eNodeEdgePoint")
513 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
514 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
517 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
518 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
519 false, String.join("+", nodeId, TapiStringConstants.E_OTSI),
520 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
521 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
522 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
523 onepl.put(onep.key(), onep);
525 // Photonic Media Nep creation on otsi node
526 for (int i = 0; i < xpdrNetMaps.size(); i++) {
527 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
528 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
529 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
530 Name onedName = new NameBuilder()
531 .setValueName("PhotMedNodeEdgePoint")
532 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
533 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
536 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
537 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
538 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA),
539 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
540 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
541 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
542 onepl.put(onep.key(), onep);
547 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
548 List<Mapping> xpdrNetMaps,
549 XpdrNodeTypes xponderType) {
550 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
551 // client nep creation on DSR node
552 for (int i = 0; i < xpdrClMaps.size(); i++) {
553 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
554 xpdrClMaps.get(i).getLogicalConnectionPoint()));
555 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
556 (String.join("+", nodeId, TapiStringConstants.DSR,
557 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
558 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
559 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
561 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
562 name = nameBldr.setValueName("100G-tpdr").build();
564 name = nameBldr.setValueName("NodeEdgePoint_C").build();
567 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
568 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
569 String.join("+", nodeId, TapiStringConstants.DSR),
570 xpdrClMaps.get(i).getSupportedInterfaceCapability(),
571 transformOperState(xpdrClMaps.get(i).getPortOperState()),
572 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
573 onepl.put(onep.key(), onep);
575 // network nep creation on I_ODU node
576 for (int i = 0; i < xpdrNetMaps.size(); i++) {
577 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
578 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
579 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
580 (String.join("+", nodeId, TapiStringConstants.I_ODU,
581 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
582 Name onedName = new NameBuilder()
583 .setValueName("iNodeEdgePoint_N")
584 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
585 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
588 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
589 xpdrNetMaps.get(i).getSupportedInterfaceCapability();
591 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
592 Map.of(onedName.key(), onedName),
593 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
594 String.join("+", nodeId, TapiStringConstants.I_ODU),
595 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
596 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
597 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
598 onepl.put(onep.key(), onep);
600 // network nep creation on E_ODU node
601 for (int i = 0; i < xpdrClMaps.size(); i++) {
602 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
603 xpdrClMaps.get(i).getLogicalConnectionPoint()));
604 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
605 (String.join("+", nodeId, TapiStringConstants.E_ODU,
606 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
607 Name onedName = new NameBuilder()
608 .setValueName("eNodeEdgePoint_N")
609 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
610 xpdrClMaps.get(i).getLogicalConnectionPoint()))
613 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
614 xpdrClMaps.get(i).getSupportedInterfaceCapability();
616 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
617 Map.of(onedName.key(), onedName),
618 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
619 String.join("+", nodeId, TapiStringConstants.E_ODU),
620 xpdrClMaps.get(i).getSupportedInterfaceCapability(),
621 transformOperState(xpdrClMaps.get(i).getPortOperState()),
622 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
623 onepl.put(onep.key(), onep);
628 private OperationalState transformOperState(String operString) {
629 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
630 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
633 private AdministrativeState transformAdminState(String adminString) {
634 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
635 .setNetworkAdminState(adminString);
636 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
639 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
640 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
642 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
643 OperationalState operState, AdministrativeState adminState) {
644 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
646 .setLayerProtocolName(nepProtocol)
649 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
650 supportedInterfaceCapability, operState, adminState));
652 LOG.debug("Node layer {}", nodeProtocol.getName());
653 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
654 supportedInterfaceCapability, nepProtocol));
655 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
656 .setAdministrativeState(adminState).setOperationalState(operState)
657 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
658 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
659 return onepBldr.build();
662 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
663 boolean withSip, OperationalState operState,
664 AdministrativeState adminState) {
665 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
666 // PHOTONIC MEDIA nep
667 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
668 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
669 Name nepName = new NameBuilder()
670 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
671 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
673 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
675 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
676 .setName(Map.of(nepName.key(), nepName))
677 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
678 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
679 .setAdministrativeState(adminState).setOperationalState(operState)
680 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
681 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
683 onepMap.put(onep.key(), onep);
686 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
687 TapiStringConstants.MC, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
688 Name nepName1 = new NameBuilder()
689 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
690 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
692 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
694 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
695 .setName(Map.of(nepName1.key(), nepName1))
696 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
697 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
698 .setAdministrativeState(adminState).setOperationalState(operState)
699 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
700 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
702 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
703 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
704 operState, adminState));
706 OwnedNodeEdgePoint onep1 = onepBldr1.build();
707 onepMap.put(onep1.key(), onep1);
710 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
711 tpId)).getBytes(Charset.forName("UTF-8"))).toString());
712 Name nepName2 = new NameBuilder()
713 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
714 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
717 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
719 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
720 .setName(Map.of(nepName2.key(), nepName2))
721 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
722 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
723 .setAdministrativeState(adminState).setOperationalState(operState)
724 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
725 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
727 onepMap.put(onep2.key(), onep2);
731 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
732 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
733 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
734 OperationalState operState, AdministrativeState adminState) {
735 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
736 for (int i = 0; i < nb; i++) {
737 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
738 tpid)).getBytes(Charset.forName("UTF-8"))).toString());
739 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
740 .setServiceInterfacePointUuid(sipUuid).build();
741 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
742 operState, adminState);
743 this.sipMap.put(sip.key(), sip);
744 LOG.info("SIP created {}", sip.getUuid());
745 // this.tapiSips.put(sip.key(), sip);
746 msipl.put(msip.key(), msip);
751 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
752 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
753 OperationalState operState, AdministrativeState adminState) {
754 // TODO: what value should be set in total capacity and available capacity
755 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
756 Name sipName = new NameBuilder()
757 .setValueName("SIP name")
758 .setValue(String.join("+", nodeid, tpid))
760 return new ServiceInterfacePointBuilder()
762 .setName(Map.of(sipName.key(), sipName))
763 .setLayerProtocolName(layerProtocol)
764 .setAdministrativeState(adminState)
765 .setOperationalState(operState)
766 .setLifecycleState(LifecycleState.INSTALLED)
767 .setAvailableCapacity(new AvailableCapacityBuilder().build())
768 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
769 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
774 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
776 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
777 TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
779 Name nodeNames = new NameBuilder().setValueName("roadm node name")
780 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
781 Name nameNodeType = new NameBuilder().setValueName("Node Type")
782 .setValue(OpenroadmNodeType.ROADM.getName()).build();
784 List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
785 // Empty random creation of mandatory fields for avoiding errors....
786 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
787 .setCostAlgorithm("Restricted Shortest Path - RSP")
788 .setCostName("HOP_COUNT")
789 .setCostValue("12345678")
791 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
792 .setFixedLatencyCharacteristic("12345678")
793 .setQueingLatencyCharacteristic("12345678")
794 .setJitterCharacteristic("12345678")
795 .setWanderCharacteristic("12345678")
796 .setTrafficPropertyName("FIXED_LATENCY")
798 return new NodeBuilder()
800 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
801 .setLayerProtocolName(layerProtocols)
802 .setAdministrativeState(AdministrativeState.UNLOCKED)
803 .setOperationalState(OperationalState.ENABLED)
804 .setLifecycleState(LifecycleState.INSTALLED)
805 .setOwnedNodeEdgePoint(oneplist)
806 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
807 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
808 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
809 .setErrorCharacteristic("error")
810 .setLossCharacteristic("loss")
811 .setRepeatDeliveryCharacteristic("repeat delivery")
812 .setDeliveryOrderCharacteristic("delivery order")
813 .setUnavailableTimeCharacteristic("unavailable time")
814 .setServerIntegrityProcessCharacteristic("server integrity process")
818 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
819 Collection<OwnedNodeEdgePoint> onepl) {
820 Map<NodeEdgePointKey, NodeEdgePoint>
821 nepMap = new HashMap<>();
822 for (OwnedNodeEdgePoint onep : onepl) {
823 NodeEdgePoint nep = new NodeEdgePointBuilder()
824 .setTopologyUuid(this.tapiTopoUuid)
825 .setNodeUuid(nodeUuid)
826 .setNodeEdgePointUuid(onep.key().getUuid())
828 nepMap.put(nep.key(), nep);
830 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
831 Map<RuleKey, Rule> ruleList = new HashMap<>();
832 Rule rule = new RuleBuilder()
833 .setLocalId("forward")
834 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
835 .setRuleType(RuleType.FORWARDING)
837 ruleList.put(rule.key(), rule);
838 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
839 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
840 .getBytes(Charset.forName("UTF-8"))).toString()))
842 .setNodeEdgePoint(nepMap)
844 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
845 return nodeRuleGroupMap;
848 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps, Uuid nodeUuidDsr,
850 Map<LinkKey, Link> linkMap = new HashMap<>();
851 for (Mapping mapping : xpdrNetMaps) {
852 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
853 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
854 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
855 "inService", "inService", Arrays.asList(LayerProtocolName.ODU,
856 LayerProtocolName.PHOTONICMEDIA),
857 Arrays.asList(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
859 linkMap.put(transiLink.key(), transiLink);
861 // return a map of links and then we can do merge the corresponding link map into the topology context
865 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
866 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
868 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
869 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
870 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
871 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
872 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
873 List<TpId> tpList = new ArrayList<>();
876 NonBlockingList nbl = new NonBlockingListBuilder()
877 .setNblNumber(Uint16.valueOf(count))
880 nblMap.put(nbl.key(), nbl);
883 return new OduSwitchingPoolsBuilder()
884 .setNonBlockingList(nblMap)
885 .setSwitchingPoolNumber(Uint16.valueOf(1))
889 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
891 List<TpId> tpl = new ArrayList<>();
893 for (int i = 1; i <= xpdrClMaps.size(); i++) {
894 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
897 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
898 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
901 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
902 NonBlockingList nbl = new NonBlockingListBuilder()
903 .setNblNumber(Uint16.valueOf(1))
906 nbMap.put(nbl.key(),nbl);
908 return new OduSwitchingPoolsBuilder()
909 .setSwitchingPoolNumber(Uint16.valueOf(1))
910 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
911 .setNonBlockingList(nbMap)
915 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
916 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
917 for (int i = 1; i <= xpdrClMaps.size(); i++) {
918 List<TpId> tpList = new ArrayList<>();
919 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
921 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
923 NonBlockingList nbl = new NonBlockingListBuilder()
924 .setNblNumber(Uint16.valueOf(i))
926 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
927 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
929 nbMap.put(nbl.key(),nbl);
931 return new OduSwitchingPoolsBuilder()
932 .setSwitchingPoolNumber(Uint16.valueOf(1))
933 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
934 .setNonBlockingList(nbMap)
938 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
939 List<Mapping> xpdrNetMaps,
940 Map<RuleKey, Rule> ruleList) {
941 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
942 // create NodeRuleGroup
944 for (Mapping tpMapping : xpdrNetMaps) {
945 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
946 NodeEdgePoint inep = new NodeEdgePointBuilder()
947 .setTopologyUuid(this.tapiTopoUuid)
948 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
949 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
950 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
951 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
952 .getBytes(Charset.forName("UTF-8"))).toString()))
954 NodeEdgePoint enep = new NodeEdgePointBuilder()
955 .setTopologyUuid(this.tapiTopoUuid)
956 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
957 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
958 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
959 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
960 tpMapping.getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString()))
962 nepList.put(inep.key(), inep);
963 nepList.put(enep.key(), enep);
964 // Empty random creation of mandatory fields for avoiding errors....
965 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
966 .setCostAlgorithm("Restricted Shortest Path - RSP")
967 .setCostName("HOP_COUNT")
968 .setCostValue("12345678")
970 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
971 .setFixedLatencyCharacteristic("12345678")
972 .setQueingLatencyCharacteristic("12345678")
973 .setJitterCharacteristic("12345678")
974 .setWanderCharacteristic("12345678")
975 .setTrafficPropertyName("FIXED_LATENCY")
977 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
978 .setRiskCharacteristicName("risk characteristic")
979 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
981 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
983 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
986 .setNodeEdgePoint(nepList)
987 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
988 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
989 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
991 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
994 return nodeRuleGroupMap;
997 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
998 OduSwitchingPools oorOduSwitchingPool,
999 Map<RuleKey, Rule> ruleList,
1000 Map<OwnedNodeEdgePointKey,
1001 OwnedNodeEdgePoint> onepl) {
1002 // create NodeRuleGroup
1003 if (oorOduSwitchingPool == null) {
1004 LOG.info("No switching pool created for node = {}", nodeId);
1005 return new HashMap<>();
1007 LOG.info("ONEPL = {}", onepl.values());
1008 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1010 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1011 LOG.info("Non blocking list = {}", nbl);
1012 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1013 for (TpId tp : nbl.getTpList()) {
1014 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1015 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1016 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1017 TapiStringConstants.E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1018 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1019 TapiStringConstants.DSR, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1020 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1021 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1022 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1023 .setTopologyUuid(this.tapiTopoUuid)
1024 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1025 (String.join("+", nodeId,TapiStringConstants. DSR))
1026 .getBytes(Charset.forName("UTF-8"))).toString()))
1027 .setNodeEdgePointUuid(tp1Uuid)
1029 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1030 .setTopologyUuid(this.tapiTopoUuid)
1031 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1032 (String.join("+", nodeId,TapiStringConstants. DSR))
1033 .getBytes(Charset.forName("UTF-8"))).toString()))
1034 .setNodeEdgePointUuid(tpUuid)
1036 nepList.put(nep1.key(), nep1);
1037 nepList.put(nep2.key(), nep2);
1040 // Empty random creation of mandatory fields for avoiding errors....
1041 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1042 .setCostAlgorithm("Restricted Shortest Path - RSP")
1043 .setCostName("HOP_COUNT")
1044 .setCostValue("12345678")
1046 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1047 .setFixedLatencyCharacteristic("12345678")
1048 .setQueingLatencyCharacteristic("12345678")
1049 .setJitterCharacteristic("12345678")
1050 .setWanderCharacteristic("12345678")
1051 .setTrafficPropertyName("FIXED_LATENCY")
1053 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1054 .setRiskCharacteristicName("risk characteristic")
1055 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1057 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1059 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1062 .setNodeEdgePoint(nepList)
1063 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1064 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1065 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1067 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1070 return nodeRuleGroupMap;
1073 private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1074 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1075 if (sicList == null) {
1076 return List.of(PHOTONICLAYERQUALIFIEROMS.class);
1078 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1079 LOG.info("SIC list = {}", sicList);
1080 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1081 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1082 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1083 .setIfCapType(supInterCapa)
1085 supIfMap.put(supIfCapa.key(), supIfCapa);
1087 List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
1088 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1089 switch (lpn.getName()) {
1091 switch (sic.getIfCapType().getSimpleName()) {
1092 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1093 // port are extended in the config file
1095 sclpqList.add(ODUTYPEODU0.class);
1096 sclpqList.add(DIGITALSIGNALTYPEGigE.class);
1099 sclpqList.add(ODUTYPEODU2E.class);
1100 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1103 sclpqList.add(ODUTYPEODU2.class);
1104 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1107 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1110 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1111 sclpqList.add(ODUTYPEODU4.class);
1114 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1116 case "IfOCHOTU4ODU4":
1118 sclpqList.add(ODUTYPEODU4.class);
1121 LOG.error("IfCapability type not managed");
1126 switch (sic.getIfCapType().getSimpleName()) {
1127 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1128 // port are extended in the config file
1130 sclpqList.add(ODUTYPEODU0.class);
1133 sclpqList.add(ODUTYPEODU2E.class);
1137 sclpqList.add(ODUTYPEODU2.class);
1141 case "IfOCHOTU4ODU4":
1143 sclpqList.add(ODUTYPEODU4.class);
1146 LOG.error("IfCapability type not managed");
1150 case "PHOTONIC_MEDIA":
1151 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1152 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1153 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1154 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1158 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1165 private String getNodeType(XpdrNodeTypes xponderType) {
1166 switch (xponderType.getIntValue()) {
1168 return OpenroadmNodeType.TPDR.getName();
1170 return OpenroadmNodeType.MUXPDR.getName();
1172 return OpenroadmNodeType.SWITCH.getName();
1174 LOG.info("XpdrType {} not supported", xponderType);
1180 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1181 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1182 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1183 LOG.info("Creating tapi node in TAPI topology context");
1184 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1185 .augmentation(Context1.class).child(TopologyContext.class)
1186 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1189 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1191 // merge in datastore
1192 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1195 this.networkTransactionService.commit().get();
1196 } catch (InterruptedException | ExecutionException e) {
1197 LOG.error("Error populating TAPI topology: ", e);
1199 LOG.info("Node added succesfully.");
1202 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1203 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1204 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1205 LOG.info("Creating tapi node in TAPI topology context");
1206 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1207 .augmentation(Context1.class).child(TopologyContext.class)
1208 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1211 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1213 // merge in datastore
1214 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1217 this.networkTransactionService.commit().get();
1218 } catch (InterruptedException | ExecutionException e) {
1219 LOG.error("Error populating TAPI topology: ", e);
1221 LOG.info("Roadm Link added succesfully.");
1224 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1225 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1226 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1228 ContextBuilder contextBuilder = new ContextBuilder();
1229 contextBuilder.setServiceInterfacePoint(sips);
1230 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1231 // merge in datastore
1232 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1233 contextBuilder.build());
1234 this.networkTransactionService.commit().get();
1235 LOG.info("TAPI SIPs merged successfully.");
1236 } catch (InterruptedException | ExecutionException e) {
1237 LOG.error("Failed to merge TAPI Sips", e);
1241 private void deleteLinkFromTopo(Uuid linkUuid) {
1242 // TODO: check if this IID is correct
1244 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1245 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1246 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1247 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1248 this.networkTransactionService.commit().get();
1249 LOG.info("TAPI link deleted successfully.");
1250 } catch (InterruptedException | ExecutionException e) {
1251 LOG.error("Failed to delete TAPI link", e);
1255 private void deleteNodeFromTopo(Uuid nodeUuid) {
1256 // TODO: check if this IID is correct
1258 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1259 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1260 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1261 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1262 this.networkTransactionService.commit().get();
1263 LOG.info("TAPI Node deleted successfully.");
1264 } catch (InterruptedException | ExecutionException e) {
1265 LOG.error("Failed to delete TAPI Node", e);
1269 private void deleteSipFromTopo(Uuid sipUuid) {
1270 // TODO: check if this IID is correct
1272 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1273 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1274 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1275 this.networkTransactionService.commit().get();
1276 LOG.info("TAPI SIP deleted successfully.");
1277 } catch (InterruptedException | ExecutionException e) {
1278 LOG.error("Failed to delete TAPI SIP", e);
1282 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1283 // TODO: check if this IID is correct
1284 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1285 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1286 .child(ConnectivityContext.class)
1288 ConnectivityContext connContext = null;
1290 Optional<ConnectivityContext> optConnContext =
1291 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1293 if (!optConnContext.isPresent()) {
1294 LOG.error("Couldnt retrieve connectivity context from datastore");
1297 connContext = optConnContext.get();
1298 } catch (InterruptedException | ExecutionException e) {
1299 LOG.error("Couldnt read connectivity context from datastore", e);
1301 if (connContext == null) {
1302 LOG.error("Connectivity context is empty");
1305 // Loop through services, check if the endpoint uuid is equal to the sip.
1306 // If so update state.
1307 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1308 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1309 if (connServMap != null) {
1310 for (ConnectivityService service:connServMap.values()) {
1311 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1312 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1313 .getServiceInterfacePointUuid().equals(sipUuid))) {
1314 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1315 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1316 .setAdministrativeState(AdministrativeState.LOCKED)
1317 .setOperationalState(OperationalState.DISABLED)
1318 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1320 updateConnectivityService(updService);
1324 // Update state of connections
1325 if (connMap != null) {
1326 for (Connection connection:connMap.values()) {
1327 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1328 Connection updConn = new ConnectionBuilder(connection)
1329 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1330 .setOperationalState(OperationalState.DISABLED)
1332 updateConnection(updConn);
1338 private void updateConnection(Connection updConn) {
1339 // TODO: check if this IID is correct
1340 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1341 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1342 .child(ConnectivityContext.class).child(Connection.class,
1343 new ConnectionKey(updConn.getUuid())).build();
1344 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1346 this.networkTransactionService.commit().get();
1347 } catch (InterruptedException | ExecutionException e) {
1348 LOG.error("Error committing into datastore", e);
1352 private void updateConnectivityService(ConnectivityService updService) {
1353 // TODO: check if this IID is correct
1354 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1355 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1356 .child(ConnectivityContext.class).child(ConnectivityService.class,
1357 new ConnectivityServiceKey(updService.getUuid())).build();
1358 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1360 this.networkTransactionService.commit().get();
1361 } catch (InterruptedException | ExecutionException e) {
1362 LOG.error("Error committing into datastore", e);