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.rev210927.mapping.Mapping;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.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.If100GE;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GE;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
126 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
127 import org.opendaylight.yangtools.yang.common.Uint16;
128 import org.opendaylight.yangtools.yang.common.Uint32;
129 import org.slf4j.Logger;
130 import org.slf4j.LoggerFactory;
132 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
134 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
135 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
136 .getBytes(Charset.forName("UTF-8"))).toString());
137 private final NetworkTransactionService networkTransactionService;
138 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
139 private final R2RTapiLinkDiscovery linkDiscovery;
140 private final TapiLink tapiLink;
142 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
143 NetworkTransactionService networkTransactionService, TapiLink tapiLink) {
144 this.networkTransactionService = networkTransactionService;
145 this.sipMap = new HashMap<>();
146 this.linkDiscovery = linkDiscovery;
147 this.tapiLink = tapiLink;
151 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
152 // TODO -> Implementation with PortMappingListener
153 // check if port mapping exists or not...
154 if (node.getMapping() == null) {
155 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
159 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
161 // check type of device, check version and create node mapping
162 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
164 // transform flat mapping list to per degree and per srg mapping lists
165 Map<String, List<Mapping>> mapDeg = new HashMap<>();
166 Map<String, List<Mapping>> mapSrg = new HashMap<>();
167 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
168 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
170 List<String> nodeShardList = getRoadmNodelist(mappingList);
172 // populate degree and srg LCP map
173 for (String str : nodeShardList) {
174 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
175 .collect(Collectors.toList());
176 if (str.contains("DEG")) {
177 mapDeg.put(str, interList);
178 } else if (str.contains("SRG")) {
179 mapSrg.put(str, interList);
181 LOG.error("unknown element");
184 // Transform LCPs into ONEP
185 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
186 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
187 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
190 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
191 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
192 mergeSipsinContext(this.sipMap);
193 // TODO add states corresponding to device config -> based on mapping.
194 // This should be possible after Gilles work is merged
196 // rdm to rdm link creation if neighbour roadm is mounted
197 LOG.info("checking if neighbor roadm exists");
198 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
200 if (!rdm2rdmLinks.isEmpty()) {
201 mergeLinkinTopology(rdm2rdmLinks);
203 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
204 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
205 List<Mapping> networkMappings = node.nonnullMapping().values()
206 .stream().filter(k -> k.getLogicalConnectionPoint()
207 .contains("NETWORK")).collect(Collectors.toList());
208 Map<Integer, String> xpdrMap = new HashMap<>();
209 for (Mapping mapping : networkMappings) {
210 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
211 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
212 if (!xpdrMap.containsKey(xpdrNb)) {
213 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
214 .stream().filter(k -> k.getLogicalConnectionPoint()
215 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
216 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
217 .stream().filter(k -> k.getLogicalConnectionPoint()
218 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
219 xpdrMap.put(xpdrNb, node.getNodeId());
221 // create switching pool
222 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
223 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
225 // node transformation
226 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
227 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool));
228 // add nodes and sips to tapi context
229 mergeNodeinTopology(nodeMap);
230 mergeSipsinContext(this.sipMap);
233 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
235 // Device not managed yet
238 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
239 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
240 OduSwitchingPools oorOduSwitchingPool) {
241 Map<NodeKey, Node> nodeMap = new HashMap<>();
242 LOG.info("creation of a DSR/ODU node for {}", nodeId);
243 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
244 .getBytes(Charset.forName("UTF-8"))).toString());
245 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
246 String.join("+", nodeId, TapiStringConstants.DSR)).build();
247 Name nameNodeType = new NameBuilder().setValueName("Node Type")
248 .setValue(getNodeType(xponderType)).build();
249 List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR,
250 LayerProtocolName.ODU);
251 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
252 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
254 nodeMap.put(dsrNode.key(), dsrNode);
256 // node creation [otsi]
257 LOG.info("creation of an OTSi node for {}", nodeId);
258 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
259 .getBytes(Charset.forName("UTF-8"))).toString());
260 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
261 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
262 List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
263 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
264 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
266 nodeMap.put(otsiNode.key(), otsiNode);
268 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
269 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
270 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps, nodeUuidDsr,
272 mergeLinkinTopology(linkMap);
277 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
279 // todo: are switching pool correct here??
283 return createTpdrSwitchPool(xpdrNetMaps);
286 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
289 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
291 LOG.warn("Xpdr type {} not supported", xpdrType);
296 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
297 Map<String, List<Mapping>> mapSrg) {
298 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
299 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
300 // For each srg node. Loop through the LCPs and create neps and sips for PP
301 for (Mapping m:entry.getValue()) {
302 if (!m.getLogicalConnectionPoint().contains("PP")) {
303 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
306 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
307 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
308 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
309 onepMap.putAll(srgNeps);
315 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
316 Map<String, List<Mapping>> mapDeg) {
317 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
318 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
319 // For each degree node. Loop through the LCPs and create neps and sips for TTP
320 for (Mapping m:entry.getValue()) {
321 if (!m.getLogicalConnectionPoint().contains("TTP")) {
322 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
325 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
326 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
327 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
328 onepMap.putAll(degNeps);
334 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
335 List<String> nodeShardList = new ArrayList<>();
336 for (Mapping mapping : mappingList) {
337 // TODO -> maybe we need to check the id based on the version
338 String str = mapping.getLogicalConnectionPoint().split("-")[0];
339 LOG.info("LCP = {}", str);
340 if (!nodeShardList.contains(str)) {
341 nodeShardList.add(str);
344 return nodeShardList;
348 public void deleteTapinode(String nodeId) {
349 // TODO: check for null objects
350 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
351 // This will delete NEPs. Then check for links that have this node and delete them.
352 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
353 LOG.info("Deleting node {} from TAPI topology", nodeId);
354 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
355 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
356 new TopologyKey(tapiTopoUuid)).build();
357 Topology topology = null;
359 Optional<Topology> optTopology =
360 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
361 if (!optTopology.isPresent()) {
362 LOG.error("No topology object present. Error deleting node {}", nodeId);
365 topology = optTopology.get();
366 } catch (InterruptedException | ExecutionException e) {
367 LOG.error("Couldnt read tapi topology from datastore", e);
369 if (topology == null) {
370 LOG.error("Topology is null, nothing to delete");
373 if (topology.getNode() == null) {
374 LOG.error("No nodes in topology");
377 if (nodeId.contains("ROADM")) {
378 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
379 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
380 TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
381 deleteNodeFromTopo(nodeUuid);
383 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
384 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
385 for (Node tapiNode:topology.getNode().values()) {
386 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
387 // Found node we need to delete
388 deleteNodeFromTopo(tapiNode.getUuid());
392 // Delete links of topology
393 Map<LinkKey, Link> linkMap = topology.getLink();
394 if (linkMap != null) {
395 for (Link link:linkMap.values()) {
396 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
397 deleteLinkFromTopo(link.getUuid());
401 // Delete sips of sip map
402 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
403 Context context = null;
405 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
407 if (!optContext.isPresent()) {
408 LOG.error("No context object present in datastore.");
411 context = optContext.get();
412 } catch (InterruptedException | ExecutionException e) {
413 LOG.error("Couldnt read tapi context from datastore", e);
415 if (context == null) {
416 LOG.error("Context is null, nothing to delete");
419 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
421 for (ServiceInterfacePoint sip:sips.values()) {
422 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
423 // Update state of services that have this sip as an endpoint and also connections
424 updateConnectivityServicesState(sip.getUuid(), nodeId);
425 deleteSipFromTopo(sip.getUuid());
431 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, List<LayerProtocolName> layerProtocols,
432 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
433 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
434 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
435 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
436 Map<RuleKey, Rule> ruleList = new HashMap<>();
437 Rule rule = new RuleBuilder()
438 .setLocalId("forward")
439 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
440 .setRuleType(RuleType.FORWARDING)
442 ruleList.put(rule.key(), rule);
443 if (layerProtocols.contains(LayerProtocolName.DSR)) {
444 // neps for dsr/odu layer
445 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
446 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
447 onepl.putAll(dsroduNeps);
448 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
449 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
450 // neps for photonic layer
451 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
452 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
453 onepl.putAll(phtmdNeps);
454 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
456 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
457 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
459 // Empty random creation of mandatory fields for avoiding errors....
460 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
461 .setCostAlgorithm("Restricted Shortest Path - RSP")
462 .setCostName("HOP_COUNT")
463 .setCostValue("12345678")
465 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
466 .setFixedLatencyCharacteristic("12345678")
467 .setQueingLatencyCharacteristic("12345678")
468 .setJitterCharacteristic("12345678")
469 .setWanderCharacteristic("12345678")
470 .setTrafficPropertyName("FIXED_LATENCY")
472 return new NodeBuilder()
475 .setLayerProtocolName(layerProtocols)
476 .setAdministrativeState(AdministrativeState.UNLOCKED)
477 .setOperationalState(OperationalState.ENABLED)
478 .setLifecycleState(LifecycleState.INSTALLED)
479 .setOwnedNodeEdgePoint(onepl)
480 .setNodeRuleGroup(nodeRuleGroupList)
481 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
482 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
483 .setErrorCharacteristic("error")
484 .setLossCharacteristic("loss")
485 .setRepeatDeliveryCharacteristic("repeat delivery")
486 .setDeliveryOrderCharacteristic("delivery order")
487 .setUnavailableTimeCharacteristic("unavailable time")
488 .setServerIntegrityProcessCharacteristic("server integrity process")
492 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
493 List<Mapping> xpdrNetMaps) {
494 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
496 // iNep creation on otsi node
497 for (int i = 0; i < xpdrNetMaps.size(); i++) {
498 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
499 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
500 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
501 Name onedName = new NameBuilder()
502 .setValueName("iNodeEdgePoint")
503 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
504 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
507 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
508 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
509 true, String.join("+", nodeId, TapiStringConstants.I_OTSI),
510 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
511 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
512 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
513 onepl.put(onep.key(), onep);
515 // eNep creation on otsi node
516 for (int i = 0; i < xpdrNetMaps.size(); i++) {
517 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
518 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
519 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
520 Name onedName = new NameBuilder()
521 .setValueName("eNodeEdgePoint")
522 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
523 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
526 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
527 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
528 false, String.join("+", nodeId, TapiStringConstants.E_OTSI),
529 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
530 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
531 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
532 onepl.put(onep.key(), onep);
534 // Photonic Media Nep creation on otsi node
535 for (int i = 0; i < xpdrNetMaps.size(); i++) {
536 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
537 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
538 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
539 Name onedName = new NameBuilder()
540 .setValueName("PhotMedNodeEdgePoint")
541 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
542 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
545 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
546 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
547 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA),
548 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
549 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
550 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
551 onepl.put(onep.key(), onep);
556 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
557 List<Mapping> xpdrNetMaps,
558 XpdrNodeTypes xponderType) {
559 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
560 // client nep creation on DSR node
561 for (int i = 0; i < xpdrClMaps.size(); i++) {
562 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
563 xpdrClMaps.get(i).getLogicalConnectionPoint()));
564 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
565 (String.join("+", nodeId, TapiStringConstants.DSR,
566 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
567 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
568 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
570 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
571 name = nameBldr.setValueName("100G-tpdr").build();
573 name = nameBldr.setValueName("NodeEdgePoint_C").build();
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),
579 xpdrClMaps.get(i).getSupportedInterfaceCapability(),
580 transformOperState(xpdrClMaps.get(i).getPortOperState()),
581 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
582 onepl.put(onep.key(), onep);
584 // network nep creation on I_ODU node
585 for (int i = 0; i < xpdrNetMaps.size(); i++) {
586 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
587 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
588 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
589 (String.join("+", nodeId, TapiStringConstants.I_ODU,
590 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
591 Name onedName = new NameBuilder()
592 .setValueName("iNodeEdgePoint_N")
593 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
594 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
597 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
598 Map.of(onedName.key(), onedName),
599 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
600 String.join("+", nodeId, TapiStringConstants.I_ODU),
601 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
602 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
603 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
604 onepl.put(onep.key(), onep);
606 // network nep creation on E_ODU node
607 for (int i = 0; i < xpdrClMaps.size(); i++) {
608 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
609 xpdrClMaps.get(i).getLogicalConnectionPoint()));
610 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
611 (String.join("+", nodeId, TapiStringConstants.E_ODU,
612 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString());
613 Name onedName = new NameBuilder()
614 .setValueName("eNodeEdgePoint_N")
615 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
616 xpdrClMaps.get(i).getLogicalConnectionPoint()))
619 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
620 Map.of(onedName.key(), onedName),
621 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
622 String.join("+", nodeId, TapiStringConstants.E_ODU),
623 xpdrClMaps.get(i).getSupportedInterfaceCapability(),
624 transformOperState(xpdrClMaps.get(i).getPortOperState()),
625 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
626 onepl.put(onep.key(), onep);
631 private OperationalState transformOperState(String operString) {
632 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
633 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
636 private AdministrativeState transformAdminState(String adminString) {
637 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
638 .setNetworkAdminState(adminString);
639 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
642 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
643 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
645 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
646 OperationalState operState, AdministrativeState adminState) {
647 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
649 .setLayerProtocolName(nepProtocol)
652 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
653 supportedInterfaceCapability, operState, adminState));
655 LOG.debug("Node layer {}", nodeProtocol.getName());
656 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
657 supportedInterfaceCapability, nepProtocol));
658 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
659 .setAdministrativeState(adminState).setOperationalState(operState)
660 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
661 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
662 return onepBldr.build();
665 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
666 boolean withSip, OperationalState operState,
667 AdministrativeState adminState) {
668 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
669 // PHOTONIC MEDIA nep
670 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
671 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
672 Name nepName = new NameBuilder()
673 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
674 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
676 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
678 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
679 .setName(Map.of(nepName.key(), nepName))
680 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
681 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
682 .setAdministrativeState(adminState).setOperationalState(operState)
683 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
684 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
686 onepMap.put(onep.key(), onep);
689 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
690 TapiStringConstants.MC, tpId)).getBytes(Charset.forName("UTF-8"))).toString());
691 Name nepName1 = new NameBuilder()
692 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
693 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
695 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
697 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
698 .setName(Map.of(nepName1.key(), nepName1))
699 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
700 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
701 .setAdministrativeState(adminState).setOperationalState(operState)
702 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
703 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
705 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
706 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
707 operState, adminState));
709 OwnedNodeEdgePoint onep1 = onepBldr1.build();
710 onepMap.put(onep1.key(), onep1);
713 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
714 tpId)).getBytes(Charset.forName("UTF-8"))).toString());
715 Name nepName2 = new NameBuilder()
716 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
717 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
720 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
722 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
723 .setName(Map.of(nepName2.key(), nepName2))
724 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
725 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
726 .setAdministrativeState(adminState).setOperationalState(operState)
727 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
728 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
730 onepMap.put(onep2.key(), onep2);
734 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
735 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
736 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
737 OperationalState operState, AdministrativeState adminState) {
738 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
739 for (int i = 0; i < nb; i++) {
740 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
741 tpid)).getBytes(Charset.forName("UTF-8"))).toString());
742 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
743 .setServiceInterfacePointUuid(sipUuid).build();
744 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
745 operState, adminState);
746 this.sipMap.put(sip.key(), sip);
747 LOG.info("SIP created {}", sip.getUuid());
748 // this.tapiSips.put(sip.key(), sip);
749 msipl.put(msip.key(), msip);
754 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
755 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
756 OperationalState operState, AdministrativeState adminState) {
757 // TODO: what value should be set in total capacity and available capacity
758 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
759 Name sipName = new NameBuilder()
760 .setValueName("SIP name")
761 .setValue(String.join("+", nodeid, tpid))
763 return new ServiceInterfacePointBuilder()
765 .setName(Map.of(sipName.key(), sipName))
766 .setLayerProtocolName(layerProtocol)
767 .setAdministrativeState(adminState)
768 .setOperationalState(operState)
769 .setLifecycleState(LifecycleState.INSTALLED)
770 .setAvailableCapacity(new AvailableCapacityBuilder().build())
771 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
772 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
777 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
779 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
780 TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
782 Name nodeNames = new NameBuilder().setValueName("roadm node name")
783 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
784 Name nameNodeType = new NameBuilder().setValueName("Node Type")
785 .setValue(OpenroadmNodeType.ROADM.getName()).build();
787 List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
788 // Empty random creation of mandatory fields for avoiding errors....
789 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
790 .setCostAlgorithm("Restricted Shortest Path - RSP")
791 .setCostName("HOP_COUNT")
792 .setCostValue("12345678")
794 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
795 .setFixedLatencyCharacteristic("12345678")
796 .setQueingLatencyCharacteristic("12345678")
797 .setJitterCharacteristic("12345678")
798 .setWanderCharacteristic("12345678")
799 .setTrafficPropertyName("FIXED_LATENCY")
801 return new NodeBuilder()
803 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
804 .setLayerProtocolName(layerProtocols)
805 .setAdministrativeState(AdministrativeState.UNLOCKED)
806 .setOperationalState(OperationalState.ENABLED)
807 .setLifecycleState(LifecycleState.INSTALLED)
808 .setOwnedNodeEdgePoint(oneplist)
809 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
810 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
811 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
812 .setErrorCharacteristic("error")
813 .setLossCharacteristic("loss")
814 .setRepeatDeliveryCharacteristic("repeat delivery")
815 .setDeliveryOrderCharacteristic("delivery order")
816 .setUnavailableTimeCharacteristic("unavailable time")
817 .setServerIntegrityProcessCharacteristic("server integrity process")
821 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
822 Collection<OwnedNodeEdgePoint> onepl) {
823 Map<NodeEdgePointKey, NodeEdgePoint>
824 nepMap = new HashMap<>();
825 for (OwnedNodeEdgePoint onep : onepl) {
826 NodeEdgePoint nep = new NodeEdgePointBuilder()
827 .setTopologyUuid(this.tapiTopoUuid)
828 .setNodeUuid(nodeUuid)
829 .setNodeEdgePointUuid(onep.key().getUuid())
831 nepMap.put(nep.key(), nep);
833 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
834 Map<RuleKey, Rule> ruleList = new HashMap<>();
835 Rule rule = new RuleBuilder()
836 .setLocalId("forward")
837 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
838 .setRuleType(RuleType.FORWARDING)
840 ruleList.put(rule.key(), rule);
841 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
842 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
843 .getBytes(Charset.forName("UTF-8"))).toString()))
845 .setNodeEdgePoint(nepMap)
847 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
848 return nodeRuleGroupMap;
851 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps, Uuid nodeUuidDsr,
853 Map<LinkKey, Link> linkMap = new HashMap<>();
854 for (Mapping mapping : xpdrNetMaps) {
855 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
856 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
857 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
858 "inService", "inService", Arrays.asList(LayerProtocolName.ODU,
859 LayerProtocolName.PHOTONICMEDIA),
860 Arrays.asList(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
862 linkMap.put(transiLink.key(), transiLink);
864 // return a map of links and then we can do merge the corresponding link map into the topology context
868 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
869 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
871 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
872 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
873 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
874 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
875 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
876 List<TpId> tpList = new ArrayList<>();
879 NonBlockingList nbl = new NonBlockingListBuilder()
880 .setNblNumber(Uint16.valueOf(count))
883 nblMap.put(nbl.key(), nbl);
886 return new OduSwitchingPoolsBuilder()
887 .setNonBlockingList(nblMap)
888 .setSwitchingPoolNumber(Uint16.valueOf(1))
892 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
894 List<TpId> tpl = new ArrayList<>();
896 for (int i = 1; i <= xpdrClMaps.size(); i++) {
897 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
900 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
901 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
904 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
905 NonBlockingList nbl = new NonBlockingListBuilder()
906 .setNblNumber(Uint16.valueOf(1))
909 nbMap.put(nbl.key(),nbl);
911 return new OduSwitchingPoolsBuilder()
912 .setSwitchingPoolNumber(Uint16.valueOf(1))
913 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
914 .setNonBlockingList(nbMap)
918 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
919 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
920 for (int i = 1; i <= xpdrClMaps.size(); i++) {
921 List<TpId> tpList = new ArrayList<>();
922 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
924 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
926 NonBlockingList nbl = new NonBlockingListBuilder()
927 .setNblNumber(Uint16.valueOf(i))
929 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
930 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
932 nbMap.put(nbl.key(),nbl);
934 return new OduSwitchingPoolsBuilder()
935 .setSwitchingPoolNumber(Uint16.valueOf(1))
936 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
937 .setNonBlockingList(nbMap)
941 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
942 List<Mapping> xpdrNetMaps,
943 Map<RuleKey, Rule> ruleList) {
944 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
945 // create NodeRuleGroup
947 for (Mapping tpMapping : xpdrNetMaps) {
948 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
949 NodeEdgePoint inep = new NodeEdgePointBuilder()
950 .setTopologyUuid(this.tapiTopoUuid)
951 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
952 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
953 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
954 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
955 .getBytes(Charset.forName("UTF-8"))).toString()))
957 NodeEdgePoint enep = new NodeEdgePointBuilder()
958 .setTopologyUuid(this.tapiTopoUuid)
959 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
960 TapiStringConstants.OTSI)).getBytes(Charset.forName("UTF-8"))).toString()))
961 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
962 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
963 tpMapping.getLogicalConnectionPoint())).getBytes(Charset.forName("UTF-8"))).toString()))
965 nepList.put(inep.key(), inep);
966 nepList.put(enep.key(), enep);
967 // Empty random creation of mandatory fields for avoiding errors....
968 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
969 .setCostAlgorithm("Restricted Shortest Path - RSP")
970 .setCostName("HOP_COUNT")
971 .setCostValue("12345678")
973 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
974 .setFixedLatencyCharacteristic("12345678")
975 .setQueingLatencyCharacteristic("12345678")
976 .setJitterCharacteristic("12345678")
977 .setWanderCharacteristic("12345678")
978 .setTrafficPropertyName("FIXED_LATENCY")
980 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
981 .setRiskCharacteristicName("risk characteristic")
982 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
984 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
986 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
989 .setNodeEdgePoint(nepList)
990 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
991 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
992 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
994 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
997 return nodeRuleGroupMap;
1000 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1001 OduSwitchingPools oorOduSwitchingPool,
1002 Map<RuleKey, Rule> ruleList,
1003 Map<OwnedNodeEdgePointKey,
1004 OwnedNodeEdgePoint> onepl) {
1005 // create NodeRuleGroup
1006 if (oorOduSwitchingPool == null) {
1007 LOG.info("No switching pool created for node = {}", nodeId);
1008 return new HashMap<>();
1010 LOG.info("ONEPL = {}", onepl.values());
1011 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1013 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1014 LOG.info("Non blocking list = {}", nbl);
1015 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1016 for (TpId tp : nbl.getTpList()) {
1017 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1018 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1019 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1020 TapiStringConstants.E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1021 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1022 TapiStringConstants.DSR, tp.getValue())).getBytes(Charset.forName("UTF-8"))).toString());
1023 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1024 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1025 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1026 .setTopologyUuid(this.tapiTopoUuid)
1027 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1028 (String.join("+", nodeId,TapiStringConstants. DSR))
1029 .getBytes(Charset.forName("UTF-8"))).toString()))
1030 .setNodeEdgePointUuid(tp1Uuid)
1032 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1033 .setTopologyUuid(this.tapiTopoUuid)
1034 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1035 (String.join("+", nodeId,TapiStringConstants. DSR))
1036 .getBytes(Charset.forName("UTF-8"))).toString()))
1037 .setNodeEdgePointUuid(tpUuid)
1039 nepList.put(nep1.key(), nep1);
1040 nepList.put(nep2.key(), nep2);
1043 // Empty random creation of mandatory fields for avoiding errors....
1044 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1045 .setCostAlgorithm("Restricted Shortest Path - RSP")
1046 .setCostName("HOP_COUNT")
1047 .setCostValue("12345678")
1049 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1050 .setFixedLatencyCharacteristic("12345678")
1051 .setQueingLatencyCharacteristic("12345678")
1052 .setJitterCharacteristic("12345678")
1053 .setWanderCharacteristic("12345678")
1054 .setTrafficPropertyName("FIXED_LATENCY")
1056 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1057 .setRiskCharacteristicName("risk characteristic")
1058 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1060 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1062 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1065 .setNodeEdgePoint(nepList)
1066 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1067 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1068 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1070 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1073 return nodeRuleGroupMap;
1076 private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1077 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1078 if (sicList == null) {
1079 return List.of(PHOTONICLAYERQUALIFIEROMS.class);
1081 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1082 LOG.info("SIC list = {}", sicList);
1083 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1084 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1085 .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa)))
1086 .setIfCapType(convertSupIfCapa(supInterCapa))
1088 supIfMap.put(supIfCapa.key(), supIfCapa);
1090 List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
1091 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1092 switch (lpn.getName()) {
1094 switch (sic.getIfCapType().getSimpleName()) {
1095 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1096 // port are extended in the config file
1098 sclpqList.add(ODUTYPEODU0.class);
1099 sclpqList.add(DIGITALSIGNALTYPEGigE.class);
1102 sclpqList.add(ODUTYPEODU2E.class);
1103 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1106 sclpqList.add(ODUTYPEODU2.class);
1107 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1110 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1113 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1114 sclpqList.add(ODUTYPEODU4.class);
1117 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1119 case "IfOCHOTU4ODU4":
1121 sclpqList.add(ODUTYPEODU4.class);
1124 LOG.error("IfCapability type not managed");
1129 switch (sic.getIfCapType().getSimpleName()) {
1130 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1131 // port are extended in the config file
1133 sclpqList.add(ODUTYPEODU0.class);
1136 sclpqList.add(ODUTYPEODU2E.class);
1140 sclpqList.add(ODUTYPEODU2.class);
1144 case "IfOCHOTU4ODU4":
1146 sclpqList.add(ODUTYPEODU4.class);
1149 LOG.error("IfCapability type not managed");
1153 case "PHOTONIC_MEDIA":
1154 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1155 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1156 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1157 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1161 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1168 private static Class<? extends SupportedIfCapability> convertSupIfCapa(Class<? extends
1169 SupportedIfCapability> ifCapType) {
1170 LOG.info("Interface Capability type = {}", ifCapType.getSimpleName());
1171 switch (ifCapType.getSimpleName()) {
1173 return If100GEODU4.class;
1174 case "IfOCHOTU4ODU4":
1175 return IfOCHOTU4ODU4.class;
1177 return If1GEODU0.class;
1179 return If10GEODU2e.class;
1181 return If10GEODU2.class;
1183 return If100GE.class;
1185 return If10GE.class;
1195 private String getNodeType(XpdrNodeTypes xponderType) {
1196 switch (xponderType.getIntValue()) {
1198 return OpenroadmNodeType.TPDR.getName();
1200 return OpenroadmNodeType.MUXPDR.getName();
1202 return OpenroadmNodeType.SWITCH.getName();
1204 LOG.info("XpdrType {} not supported", xponderType);
1210 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1211 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1212 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1213 LOG.info("Creating tapi node in TAPI topology context");
1214 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1215 .augmentation(Context1.class).child(TopologyContext.class)
1216 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1219 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1221 // merge in datastore
1222 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1225 this.networkTransactionService.commit().get();
1226 } catch (InterruptedException | ExecutionException e) {
1227 LOG.error("Error populating TAPI topology: ", e);
1229 LOG.info("Node added succesfully.");
1232 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1233 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1234 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1235 LOG.info("Creating tapi node in TAPI topology context");
1236 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1237 .augmentation(Context1.class).child(TopologyContext.class)
1238 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1241 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1243 // merge in datastore
1244 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1247 this.networkTransactionService.commit().get();
1248 } catch (InterruptedException | ExecutionException e) {
1249 LOG.error("Error populating TAPI topology: ", e);
1251 LOG.info("Roadm Link added succesfully.");
1254 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1255 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1256 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1258 ContextBuilder contextBuilder = new ContextBuilder();
1259 contextBuilder.setServiceInterfacePoint(sips);
1260 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1261 // merge in datastore
1262 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1263 contextBuilder.build());
1264 this.networkTransactionService.commit().get();
1265 LOG.info("TAPI SIPs merged successfully.");
1266 } catch (InterruptedException | ExecutionException e) {
1267 LOG.error("Failed to merge TAPI Sips", e);
1271 private void deleteLinkFromTopo(Uuid linkUuid) {
1272 // TODO: check if this IID is correct
1274 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1275 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1276 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1277 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1278 this.networkTransactionService.commit().get();
1279 LOG.info("TAPI link deleted successfully.");
1280 } catch (InterruptedException | ExecutionException e) {
1281 LOG.error("Failed to delete TAPI link", e);
1285 private void deleteNodeFromTopo(Uuid nodeUuid) {
1286 // TODO: check if this IID is correct
1288 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1289 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1290 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1291 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1292 this.networkTransactionService.commit().get();
1293 LOG.info("TAPI Node deleted successfully.");
1294 } catch (InterruptedException | ExecutionException e) {
1295 LOG.error("Failed to delete TAPI Node", e);
1299 private void deleteSipFromTopo(Uuid sipUuid) {
1300 // TODO: check if this IID is correct
1302 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1303 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1304 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1305 this.networkTransactionService.commit().get();
1306 LOG.info("TAPI SIP deleted successfully.");
1307 } catch (InterruptedException | ExecutionException e) {
1308 LOG.error("Failed to delete TAPI SIP", e);
1312 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1313 // TODO: check if this IID is correct
1314 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1315 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1316 .child(ConnectivityContext.class)
1318 ConnectivityContext connContext = null;
1320 Optional<ConnectivityContext> optConnContext =
1321 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1323 if (!optConnContext.isPresent()) {
1324 LOG.error("Couldnt retrieve connectivity context from datastore");
1327 connContext = optConnContext.get();
1328 } catch (InterruptedException | ExecutionException e) {
1329 LOG.error("Couldnt read connectivity context from datastore", e);
1331 if (connContext == null) {
1332 LOG.error("Connectivity context is empty");
1335 // Loop through services, check if the endpoint uuid is equal to the sip.
1336 // If so update state.
1337 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1338 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1339 if (connServMap != null) {
1340 for (ConnectivityService service:connServMap.values()) {
1341 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1342 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1343 .getServiceInterfacePointUuid().equals(sipUuid))) {
1344 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1345 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1346 .setAdministrativeState(AdministrativeState.LOCKED)
1347 .setOperationalState(OperationalState.DISABLED)
1348 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1350 updateConnectivityService(updService);
1354 // Update state of connections
1355 if (connMap != null) {
1356 for (Connection connection:connMap.values()) {
1357 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1358 Connection updConn = new ConnectionBuilder(connection)
1359 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1360 .setOperationalState(OperationalState.DISABLED)
1362 updateConnection(updConn);
1368 private void updateConnection(Connection updConn) {
1369 // TODO: check if this IID is correct
1370 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1371 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1372 .child(ConnectivityContext.class).child(Connection.class,
1373 new ConnectionKey(updConn.getUuid())).build();
1374 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1376 this.networkTransactionService.commit().get();
1377 } catch (InterruptedException | ExecutionException e) {
1378 LOG.error("Error committing into datastore", e);
1382 private void updateConnectivityService(ConnectivityService updService) {
1383 // TODO: check if this IID is correct
1384 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1385 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1386 .child(ConnectivityContext.class).child(ConnectivityService.class,
1387 new ConnectivityServiceKey(updService.getUuid())).build();
1388 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1390 this.networkTransactionService.commit().get();
1391 } catch (InterruptedException | ExecutionException e) {
1392 LOG.error("Error committing into datastore", e);