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.rev220316.mapping.Mapping;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.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.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.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 List<Class<? extends SupportedIfCapability>> newSupIfCapList =
499 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 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 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 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 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 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(List.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(List.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(List.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 List<LayerProtocolName> layerProtocols = Arrays.asList(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", Arrays.asList(LayerProtocolName.ODU,
862 LayerProtocolName.PHOTONICMEDIA),
863 Arrays.asList(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
865 linkMap.put(transiLink.key(), transiLink);
867 // return a map of links and then we can do merge the corresponding link map into the topology context
871 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
872 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
874 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
875 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
876 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
877 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
878 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
879 List<TpId> tpList = new ArrayList<>();
882 NonBlockingList nbl = new NonBlockingListBuilder()
883 .setNblNumber(Uint16.valueOf(count))
886 nblMap.put(nbl.key(), nbl);
889 return new OduSwitchingPoolsBuilder()
890 .setNonBlockingList(nblMap)
891 .setSwitchingPoolNumber(Uint16.valueOf(1))
895 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
897 List<TpId> tpl = new ArrayList<>();
899 for (int i = 1; i <= xpdrClMaps.size(); i++) {
900 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
903 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
904 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
907 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
908 NonBlockingList nbl = new NonBlockingListBuilder()
909 .setNblNumber(Uint16.valueOf(1))
912 nbMap.put(nbl.key(),nbl);
914 return new OduSwitchingPoolsBuilder()
915 .setSwitchingPoolNumber(Uint16.valueOf(1))
916 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
917 .setNonBlockingList(nbMap)
921 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
922 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
923 for (int i = 1; i <= xpdrClMaps.size(); i++) {
924 List<TpId> tpList = new ArrayList<>();
925 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
927 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
929 NonBlockingList nbl = new NonBlockingListBuilder()
930 .setNblNumber(Uint16.valueOf(i))
932 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
933 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
935 nbMap.put(nbl.key(),nbl);
937 return new OduSwitchingPoolsBuilder()
938 .setSwitchingPoolNumber(Uint16.valueOf(1))
939 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
940 .setNonBlockingList(nbMap)
944 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
945 List<Mapping> xpdrNetMaps,
946 Map<RuleKey, Rule> ruleList) {
947 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
948 // create NodeRuleGroup
950 for (Mapping tpMapping : xpdrNetMaps) {
951 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
952 NodeEdgePoint inep = new NodeEdgePointBuilder()
953 .setTopologyUuid(this.tapiTopoUuid)
954 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
955 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
956 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
957 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
958 .getBytes(Charset.forName("UTF-8"))).toString()))
960 NodeEdgePoint enep = new NodeEdgePointBuilder()
961 .setTopologyUuid(this.tapiTopoUuid)
962 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
963 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
964 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
965 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
966 tpMapping.getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString()))
968 nepList.put(inep.key(), inep);
969 nepList.put(enep.key(), enep);
970 // Empty random creation of mandatory fields for avoiding errors....
971 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
972 .setCostAlgorithm("Restricted Shortest Path - RSP")
973 .setCostName("HOP_COUNT")
974 .setCostValue("12345678")
976 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
977 .setFixedLatencyCharacteristic("12345678")
978 .setQueingLatencyCharacteristic("12345678")
979 .setJitterCharacteristic("12345678")
980 .setWanderCharacteristic("12345678")
981 .setTrafficPropertyName("FIXED_LATENCY")
983 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
984 .setRiskCharacteristicName("risk characteristic")
985 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
987 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
989 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
992 .setNodeEdgePoint(nepList)
993 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
994 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
995 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
997 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1000 return nodeRuleGroupMap;
1003 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1004 OduSwitchingPools oorOduSwitchingPool,
1005 Map<RuleKey, Rule> ruleList,
1006 Map<OwnedNodeEdgePointKey,
1007 OwnedNodeEdgePoint> onepl) {
1008 // create NodeRuleGroup
1009 if (oorOduSwitchingPool == null) {
1010 LOG.info("No switching pool created for node = {}", nodeId);
1011 return new HashMap<>();
1013 LOG.info("ONEPL = {}", onepl.values());
1014 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1016 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1017 LOG.info("Non blocking list = {}", nbl);
1018 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1019 for (TpId tp : nbl.getTpList()) {
1020 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1021 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1022 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1023 TapiStringConstants.E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1024 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1025 TapiStringConstants.DSR, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1026 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1027 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1028 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1029 .setTopologyUuid(this.tapiTopoUuid)
1030 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1031 (String.join("+", nodeId,TapiStringConstants. DSR))
1032 .getBytes(Charset.forName("UTF-8"))).toString()))
1033 .setNodeEdgePointUuid(tp1Uuid)
1035 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1036 .setTopologyUuid(this.tapiTopoUuid)
1037 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1038 (String.join("+", nodeId,TapiStringConstants. DSR))
1039 .getBytes(Charset.forName("UTF-8"))).toString()))
1040 .setNodeEdgePointUuid(tpUuid)
1042 nepList.put(nep1.key(), nep1);
1043 nepList.put(nep2.key(), nep2);
1046 // Empty random creation of mandatory fields for avoiding errors....
1047 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1048 .setCostAlgorithm("Restricted Shortest Path - RSP")
1049 .setCostName("HOP_COUNT")
1050 .setCostValue("12345678")
1052 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1053 .setFixedLatencyCharacteristic("12345678")
1054 .setQueingLatencyCharacteristic("12345678")
1055 .setJitterCharacteristic("12345678")
1056 .setWanderCharacteristic("12345678")
1057 .setTrafficPropertyName("FIXED_LATENCY")
1059 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1060 .setRiskCharacteristicName("risk characteristic")
1061 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1063 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1065 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1068 .setNodeEdgePoint(nepList)
1069 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1070 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1071 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1073 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1076 return nodeRuleGroupMap;
1079 private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1080 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1081 if (sicList == null) {
1082 return List.of(PHOTONICLAYERQUALIFIEROMS.class);
1084 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1085 LOG.info("SIC list = {}", sicList);
1086 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1087 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1088 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1089 .setIfCapType(supInterCapa)
1091 supIfMap.put(supIfCapa.key(), supIfCapa);
1093 List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
1094 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1095 switch (lpn.getName()) {
1097 switch (sic.getIfCapType().getSimpleName()) {
1098 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1099 // port are extended in the config file
1101 sclpqList.add(ODUTYPEODU0.class);
1102 sclpqList.add(DIGITALSIGNALTYPEGigE.class);
1105 sclpqList.add(ODUTYPEODU2E.class);
1106 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1109 sclpqList.add(ODUTYPEODU2.class);
1110 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1113 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1116 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1117 sclpqList.add(ODUTYPEODU4.class);
1120 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1122 case "IfOCHOTU4ODU4":
1124 sclpqList.add(ODUTYPEODU4.class);
1127 LOG.error("IfCapability type not managed");
1132 switch (sic.getIfCapType().getSimpleName()) {
1133 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1134 // port are extended in the config file
1136 sclpqList.add(ODUTYPEODU0.class);
1139 sclpqList.add(ODUTYPEODU2E.class);
1143 sclpqList.add(ODUTYPEODU2.class);
1147 case "IfOCHOTU4ODU4":
1149 sclpqList.add(ODUTYPEODU4.class);
1152 LOG.error("IfCapability type not managed");
1156 case "PHOTONIC_MEDIA":
1157 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1158 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1159 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1160 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1164 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1171 private String getNodeType(XpdrNodeTypes xponderType) {
1172 switch (xponderType.getIntValue()) {
1174 return OpenroadmNodeType.TPDR.getName();
1176 return OpenroadmNodeType.MUXPDR.getName();
1178 return OpenroadmNodeType.SWITCH.getName();
1180 LOG.info("XpdrType {} not supported", xponderType);
1186 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1187 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1188 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1189 LOG.info("Creating tapi node in TAPI topology context");
1190 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1191 .augmentation(Context1.class).child(TopologyContext.class)
1192 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1195 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1197 // merge in datastore
1198 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1201 this.networkTransactionService.commit().get();
1202 } catch (InterruptedException | ExecutionException e) {
1203 LOG.error("Error populating TAPI topology: ", e);
1205 LOG.info("Node added succesfully.");
1208 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1209 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1210 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1211 LOG.info("Creating tapi node in TAPI topology context");
1212 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1213 .augmentation(Context1.class).child(TopologyContext.class)
1214 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1217 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1219 // merge in datastore
1220 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1223 this.networkTransactionService.commit().get();
1224 } catch (InterruptedException | ExecutionException e) {
1225 LOG.error("Error populating TAPI topology: ", e);
1227 LOG.info("Roadm Link added succesfully.");
1230 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1231 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1232 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1234 ContextBuilder contextBuilder = new ContextBuilder();
1235 contextBuilder.setServiceInterfacePoint(sips);
1236 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1237 // merge in datastore
1238 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1239 contextBuilder.build());
1240 this.networkTransactionService.commit().get();
1241 LOG.info("TAPI SIPs merged successfully.");
1242 } catch (InterruptedException | ExecutionException e) {
1243 LOG.error("Failed to merge TAPI Sips", e);
1247 private void deleteLinkFromTopo(Uuid linkUuid) {
1248 // TODO: check if this IID is correct
1250 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1251 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1252 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1253 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1254 this.networkTransactionService.commit().get();
1255 LOG.info("TAPI link deleted successfully.");
1256 } catch (InterruptedException | ExecutionException e) {
1257 LOG.error("Failed to delete TAPI link", e);
1261 private void deleteNodeFromTopo(Uuid nodeUuid) {
1262 // TODO: check if this IID is correct
1264 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1265 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1266 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1267 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1268 this.networkTransactionService.commit().get();
1269 LOG.info("TAPI Node deleted successfully.");
1270 } catch (InterruptedException | ExecutionException e) {
1271 LOG.error("Failed to delete TAPI Node", e);
1275 private void deleteSipFromTopo(Uuid sipUuid) {
1276 // TODO: check if this IID is correct
1278 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1279 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1280 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1281 this.networkTransactionService.commit().get();
1282 LOG.info("TAPI SIP deleted successfully.");
1283 } catch (InterruptedException | ExecutionException e) {
1284 LOG.error("Failed to delete TAPI SIP", e);
1288 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1289 // TODO: check if this IID is correct
1290 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1291 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1292 .child(ConnectivityContext.class)
1294 ConnectivityContext connContext = null;
1296 Optional<ConnectivityContext> optConnContext =
1297 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1299 if (!optConnContext.isPresent()) {
1300 LOG.error("Couldnt retrieve connectivity context from datastore");
1303 connContext = optConnContext.get();
1304 } catch (InterruptedException | ExecutionException e) {
1305 LOG.error("Couldnt read connectivity context from datastore", e);
1307 if (connContext == null) {
1308 LOG.error("Connectivity context is empty");
1311 // Loop through services, check if the endpoint uuid is equal to the sip.
1312 // If so update state.
1313 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1314 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1315 if (connServMap != null) {
1316 for (ConnectivityService service:connServMap.values()) {
1317 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1318 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1319 .getServiceInterfacePointUuid().equals(sipUuid))) {
1320 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1321 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1322 .setAdministrativeState(AdministrativeState.LOCKED)
1323 .setOperationalState(OperationalState.DISABLED)
1324 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1326 updateConnectivityService(updService);
1330 // Update state of connections
1331 if (connMap != null) {
1332 for (Connection connection:connMap.values()) {
1333 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1334 Connection updConn = new ConnectionBuilder(connection)
1335 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1336 .setOperationalState(OperationalState.DISABLED)
1338 updateConnection(updConn);
1344 private void updateConnection(Connection updConn) {
1345 // TODO: check if this IID is correct
1346 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1347 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1348 .child(ConnectivityContext.class).child(Connection.class,
1349 new ConnectionKey(updConn.getUuid())).build();
1350 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1352 this.networkTransactionService.commit().get();
1353 } catch (InterruptedException | ExecutionException e) {
1354 LOG.error("Error committing into datastore", e);
1358 private void updateConnectivityService(ConnectivityService updService) {
1359 // TODO: check if this IID is correct
1360 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1361 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1362 .child(ConnectivityContext.class).child(ConnectivityService.class,
1363 new ConnectivityServiceKey(updService.getUuid())).build();
1364 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1366 this.networkTransactionService.commit().get();
1367 } catch (InterruptedException | ExecutionException e) {
1368 LOG.error("Error committing into datastore", e);