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.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.Mapping;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.network.Nodes;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GE;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
49 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
50 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ProtectionType;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RestorationPolicy;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePoint;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointBuilder;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointKey;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.ResilienceTypeBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
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.LinkBuilder;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanism;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanismBuilder;
129 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
130 import org.opendaylight.yangtools.yang.common.Uint16;
131 import org.opendaylight.yangtools.yang.common.Uint32;
132 import org.opendaylight.yangtools.yang.common.Uint64;
133 import org.slf4j.Logger;
134 import org.slf4j.LoggerFactory;
136 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
138 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
139 private static final String DSR = "DSR";
140 private static final String I_ODU = "iODU";
141 private static final String E_ODU = "eODU";
142 private static final String OTSI = "OTSi";
143 private static final String E_OTSI = "eOTSi";
144 private static final String I_OTSI = "iOTSi";
145 private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA";
146 private static final String MC = "MEDIA_CHANNEL";
147 private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL";
148 private static final String CLIENT = "-CLIENT";
149 private static final String NETWORK = "-NETWORK";
150 private static final String XPDR = "-XPDR";
151 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
152 .getBytes(Charset.forName("UTF-8"))).toString());
153 private final NetworkTransactionService networkTransactionService;
154 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
155 private final R2RTapiLinkDiscovery linkDiscovery;
157 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
158 NetworkTransactionService networkTransactionService) {
159 this.networkTransactionService = networkTransactionService;
160 this.sipMap = new HashMap<>();
161 this.linkDiscovery = linkDiscovery;
165 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
166 // TODO -> Implementation with PortMappingListener
167 // check if port mapping exists or not...
168 if (node.getMapping() == null) {
169 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
173 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
175 // check type of device, check version and create node mapping
176 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
178 // transform flat mapping list to per degree and per srg mapping lists
179 Map<String, List<Mapping>> mapDeg = new HashMap<>();
180 Map<String, List<Mapping>> mapSrg = new HashMap<>();
181 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
182 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
184 List<String> nodeShardList = getRoadmNodelist(mappingList);
186 // populate degree and srg LCP map
187 for (String str : nodeShardList) {
188 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
189 .collect(Collectors.toList());
190 if (str.contains("DEG")) {
191 mapDeg.put(str, interList);
192 } else if (str.contains("SRG")) {
193 mapSrg.put(str, interList);
195 LOG.error("unknown element");
198 // Transform LCPs into ONEP
199 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
200 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
201 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
204 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node roadmNode =
205 createRoadmTapiNode(orNodeId, onepMap);
206 // TODO add states corresponding to device config -> based on mapping.
207 // This should be possible after Gilles work is merged
209 // rdm to rdm link creation if neighbour roadm is mounted
210 LOG.info("checking if neighbor roadm exists");
211 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
213 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
214 mergeSipsinContext(this.sipMap);
215 if (!rdm2rdmLinks.isEmpty()) {
216 mergeLinkinTopology(rdm2rdmLinks);
219 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
220 List<Mapping> networkMappings = node.nonnullMapping().values()
221 .stream().filter(k -> k.getLogicalConnectionPoint()
222 .contains("NETWORK")).collect(Collectors.toList());
223 Map<Integer, String> xpdrMap = new HashMap<>();
224 for (Mapping mapping : networkMappings) {
225 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
226 String nodeId = node.getNodeId() + XPDR + xpdrNb;
227 if (!xpdrMap.containsKey(xpdrNb)) {
228 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
229 .stream().filter(k -> k.getLogicalConnectionPoint()
230 .contains("XPDR" + xpdrNb + NETWORK)).collect(Collectors.toList());
231 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
232 .stream().filter(k -> k.getLogicalConnectionPoint()
233 .contains("XPDR" + xpdrNb + CLIENT)).collect(Collectors.toList());
234 xpdrMap.put(xpdrNb, node.getNodeId());
236 // create switching pool
237 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
238 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
240 // node transformation
241 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
242 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool,
243 mapping.getSupportedInterfaceCapability()));
245 // add nodes and sips to tapi context
246 mergeNodeinTopology(nodeMap);
247 mergeSipsinContext(this.sipMap);
251 // Device not managed yet
254 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
255 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
256 OduSwitchingPools oorOduSwitchingPool,
257 List<Class<? extends SupportedIfCapability>>
258 supportedInterfaceCapability) {
259 Map<NodeKey, Node> nodeMap = new HashMap<>();
260 LOG.info("creation of a DSR/ODU node for {}", nodeId);
261 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, DSR))
262 .getBytes(Charset.forName("UTF-8"))).toString());
263 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
264 String.join("+", nodeId, DSR)).build();
265 List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR,
266 LayerProtocolName.ODU);
267 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
268 .Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr), dsrLayerProtocols,
269 nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool,
270 supportedInterfaceCapability);
272 nodeMap.put(dsrNode.key(), dsrNode);
274 // node creation [otsi]
275 LOG.info("creation of an OTSi node for {}", nodeId);
276 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, OTSI))
277 .getBytes(Charset.forName("UTF-8"))).toString());
278 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
279 String.join("+", nodeId, OTSI)).build();
280 List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
281 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
282 .Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi), otsiLayerProtocols,
283 nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null,
284 supportedInterfaceCapability);
286 nodeMap.put(otsiNode.key(), otsiNode);
288 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
289 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
290 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps, nodeUuidDsr,
292 mergeLinkinTopology(linkMap);
297 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
299 // todo: are switching pool correct here??
303 return createTpdrSwitchPool();
306 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
309 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
311 LOG.warn("Xpdr type {} not supported", xpdrType);
316 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
317 Map<String, List<Mapping>> mapSrg) {
318 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
319 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
320 // For each srg node. Loop through the LCPs and create neps and sips for PP
321 for (Mapping m:entry.getValue()) {
322 if (!m.getLogicalConnectionPoint().contains("PP")) {
323 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
326 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
327 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true);
328 onepMap.putAll(srgNeps);
334 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
335 Map<String, List<Mapping>> mapDeg) {
336 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
337 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
338 // For each degree node. Loop through the LCPs and create neps and sips for TTP
339 for (Mapping m:entry.getValue()) {
340 if (!m.getLogicalConnectionPoint().contains("TTP")) {
341 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
344 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
345 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false);
346 onepMap.putAll(degNeps);
352 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
353 List<String> nodeShardList = new ArrayList<>();
354 for (Mapping mapping : mappingList) {
355 // TODO -> maybe we need to check the id based on the version
356 String str = mapping.getLogicalConnectionPoint().split("-")[0];
357 LOG.info("LCP = {}", str);
358 if (!nodeShardList.contains(str)) {
359 nodeShardList.add(str);
362 return nodeShardList;
366 public void deleteTapinode(String nodeId) {
367 // TODO: check for null objects
368 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
369 // This will delete NEPs. Then check for links that have this node and delete them.
370 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
371 LOG.info("Deleting node {} from TAPI topology", nodeId);
372 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
373 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
374 new TopologyKey(tapiTopoUuid)).build();
375 Topology topology = null;
377 Optional<Topology> optTopology =
378 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
379 if (!optTopology.isPresent()) {
380 LOG.error("No topology object present. Error deleting node {}", nodeId);
383 topology = optTopology.get();
384 } catch (InterruptedException | ExecutionException e) {
385 LOG.error("Couldnt read tapi topology from datastore", e);
387 if (topology == null) {
388 LOG.error("Topology is null, nothing to delete");
391 if (topology.getNode() == null) {
392 LOG.error("No nodes in topology");
395 if (nodeId.contains("ROADM")) {
396 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
397 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, PHTNC_MEDIA))
398 .getBytes(Charset.forName("UTF-8"))).toString());
399 deleteNodeFromTopo(nodeUuid);
401 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
402 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
403 for (Node tapiNode:topology.getNode().values()) {
404 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
405 // Found node we need to delete
406 deleteNodeFromTopo(tapiNode.getUuid());
410 // Delete links of topology
411 Map<LinkKey, Link> linkMap = topology.getLink();
412 if (linkMap != null) {
413 for (Link link:linkMap.values()) {
414 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
415 deleteLinkFromTopo(link.getUuid());
419 // Delete sips of sip map
420 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
421 Context context = null;
423 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
425 if (!optContext.isPresent()) {
426 LOG.error("No context object present in datastore.");
429 context = optContext.get();
430 } catch (InterruptedException | ExecutionException e) {
431 LOG.error("Couldnt read tapi context from datastore", e);
433 if (context == null) {
434 LOG.error("Context is null, nothing to delete");
437 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
439 for (ServiceInterfacePoint sip:sips.values()) {
440 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
441 // Update state of services that have this sip as an endpoint and also connections
442 updateConnectivityServicesState(sip.getUuid(), nodeId);
443 deleteSipFromTopo(sip.getUuid());
449 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, List<LayerProtocolName> layerProtocols,
450 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
451 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool,
452 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
453 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
454 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
455 Map<RuleKey, Rule> ruleList = new HashMap<>();
456 Rule rule = new RuleBuilder()
457 .setLocalId("forward")
458 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
459 .setRuleType(RuleType.FORWARDING)
461 ruleList.put(rule.key(), rule);
462 if (layerProtocols.contains(LayerProtocolName.DSR)) {
463 // neps for dsr/odu layer
464 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
465 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType, supportedInterfaceCapability);
466 onepl.putAll(dsroduNeps);
467 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
468 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
469 // neps for photonic layer
470 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
471 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps, supportedInterfaceCapability);
472 onepl.putAll(phtmdNeps);
473 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
475 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
476 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
478 // Empty random creation of mandatory fields for avoiding errors....
479 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
480 .setCostAlgorithm("Restricted Shortest Path - RSP")
481 .setCostName("HOP_COUNT")
482 .setCostValue("12345678")
484 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
485 .setFixedLatencyCharacteristic("12345678")
486 .setQueingLatencyCharacteristic("12345678")
487 .setJitterCharacteristic("12345678")
488 .setWanderCharacteristic("12345678")
489 .setTrafficPropertyName("FIXED_LATENCY")
491 return new NodeBuilder()
494 .setLayerProtocolName(layerProtocols)
495 .setAdministrativeState(AdministrativeState.UNLOCKED)
496 .setOperationalState(OperationalState.ENABLED)
497 .setLifecycleState(LifecycleState.INSTALLED)
498 .setOwnedNodeEdgePoint(onepl)
499 .setNodeRuleGroup(nodeRuleGroupList)
500 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
501 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
502 .setErrorCharacteristic("error")
503 .setLossCharacteristic("loss")
504 .setRepeatDeliveryCharacteristic("repeat delivery")
505 .setDeliveryOrderCharacteristic("delivery order")
506 .setUnavailableTimeCharacteristic("unavailable time")
507 .setServerIntegrityProcessCharacteristic("server integrity process")
511 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
512 List<Mapping> xpdrNetMaps, List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
513 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
515 // iNep creation on otsi node
516 for (int i = 0; i < xpdrNetMaps.size(); i++) {
517 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
518 (String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
519 .getBytes(Charset.forName("UTF-8")))
521 Name onedName = new NameBuilder()
522 .setValueName("iNodeEdgePoint")
523 .setValue(String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
526 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
527 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
528 true, String.join("+", nodeId, I_OTSI), supportedInterfaceCapability);
529 onepl.put(onep.key(), onep);
531 // eNep creation on otsi node
532 for (int i = 0; i < xpdrNetMaps.size(); i++) {
533 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
534 (String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
535 .getBytes(Charset.forName("UTF-8"))).toString());
536 Name onedName = new NameBuilder()
537 .setValueName("eNodeEdgePoint")
538 .setValue(String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
541 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
542 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
543 false, String.join("+", nodeId, E_OTSI), supportedInterfaceCapability);
544 onepl.put(onep.key(), onep);
546 // Photonic Media Nep creation on otsi node
547 for (int i = 0; i < xpdrNetMaps.size(); i++) {
548 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
549 (String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
550 .getBytes(Charset.forName("UTF-8"))).toString());
551 Name onedName = new NameBuilder()
552 .setValueName("PhotMedNodeEdgePoint")
553 .setValue(String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
556 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
557 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
558 false, String.join("+", nodeId, PHTNC_MEDIA), supportedInterfaceCapability);
559 onepl.put(onep.key(), onep);
564 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
565 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
566 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
567 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
568 // client nep creation on DSR node
569 for (int i = 0; i < xpdrClMaps.size(); i++) {
570 LOG.info("Client NEP = {}", String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
571 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
572 (String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()))
573 .getBytes(Charset.forName("UTF-8"))).toString());
574 NameBuilder nameBldr = new NameBuilder().setValue(
575 String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
577 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
578 name = nameBldr.setValueName("100G-tpdr").build();
580 name = nameBldr.setValueName("NodeEdgePoint_C").build();
583 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
584 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
585 String.join("+", nodeId, DSR), supportedInterfaceCapability);
586 onepl.put(onep.key(), onep);
588 // network nep creation on I_ODU node
589 for (int i = 0; i < xpdrNetMaps.size(); i++) {
590 LOG.info("iODU NEP = {}", String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()));
591 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
592 (String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
593 .getBytes(Charset.forName("UTF-8"))).toString());
594 Name onedName = new NameBuilder()
595 .setValueName("iNodeEdgePoint_N")
596 .setValue(String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
599 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
600 Map.of(onedName.key(), onedName),
601 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
602 String.join("+", nodeId, I_ODU), supportedInterfaceCapability);
603 onepl.put(onep.key(), onep);
605 // network nep creation on E_ODU node
606 for (int i = 0; i < xpdrNetMaps.size(); i++) {
607 LOG.info("eODU NEP = {}", String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()));
608 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
609 (String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
610 .getBytes(Charset.forName("UTF-8"))).toString());
611 Name onedName = new NameBuilder()
612 .setValueName("eNodeEdgePoint_N")
613 .setValue(String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
616 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
617 Map.of(onedName.key(), onedName),
618 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
619 String.join("+", nodeId, E_ODU), supportedInterfaceCapability);
620 onepl.put(onep.key(), onep);
625 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
626 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
628 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
629 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
631 .setLayerProtocolName(nepProtocol)
634 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
635 supportedInterfaceCapability));
637 LOG.debug("Node layer {}", nodeProtocol.getName());
638 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
639 supportedInterfaceCapability, nodeProtocol));
640 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
641 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
642 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
643 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
644 return onepBldr.build();
647 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
649 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
650 // PHOTONIC MEDIA nep
651 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, PHTNC_MEDIA, tpId))
652 .getBytes(Charset.forName("UTF-8")))
654 Name nepName = new NameBuilder()
655 .setValueName("NodeEdgePoint name")
656 .setValue(String.join("+", orNodeId, PHTNC_MEDIA, tpId))
658 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
660 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
661 .setName(Map.of(nepName.key(), nepName))
662 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
663 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
664 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
665 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
666 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
667 OwnedNodeEdgePoint onep = onepBldr.build();
668 onepMap.put(onep.key(), onep);
671 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, MC, tpId))
672 .getBytes(Charset.forName("UTF-8")))
674 Name nepName1 = new NameBuilder()
675 .setValueName("NodeEdgePoint name")
676 .setValue(String.join("+", orNodeId, MC, tpId))
678 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
680 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
681 .setName(Map.of(nepName1.key(), nepName1))
682 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
683 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
684 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
685 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
686 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
688 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
689 tpId, String.join("+", orNodeId, MC), null));
691 OwnedNodeEdgePoint onep1 = onepBldr1.build();
692 onepMap.put(onep1.key(), onep1);
695 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, OTSI_MC, tpId))
696 .getBytes(Charset.forName("UTF-8")))
698 Name nepName2 = new NameBuilder()
699 .setValueName("NodeEdgePoint name")
700 .setValue(String.join("+", orNodeId, OTSI_MC, tpId))
702 OwnedNodeEdgePointBuilder onepBldr2 = new OwnedNodeEdgePointBuilder()
704 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
705 .setName(Map.of(nepName2.key(), nepName2))
706 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
707 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
708 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
709 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
710 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
711 OwnedNodeEdgePoint onep2 = onepBldr2.build();
712 onepMap.put(onep2.key(), onep2);
716 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
717 LayerProtocolName layerProtocol, String tpid, String nodeid,
718 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
719 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
720 for (int i = 0; i < nb; i++) {
721 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
722 tpid)).getBytes(Charset.forName("UTF-8"))).toString());
723 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
724 .setServiceInterfacePointUuid(sipUuid).build();
725 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint sip
726 = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability);
727 this.sipMap.put(sip.key(), sip);
728 LOG.info("SIP created {}", sip.getUuid());
729 // this.tapiSips.put(sip.key(), sip);
730 msipl.put(msip.key(), msip);
735 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
736 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability) {
737 // TODO: what value should be set in total capacity and available capacity
738 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
739 Name sipName = new NameBuilder()
740 .setValueName("SIP name")
741 .setValue(String.join("+", nodeid, tpid))
743 return new ServiceInterfacePointBuilder()
745 .setName(Map.of(sipName.key(), sipName))
746 .setLayerProtocolName(layerProtocol)
747 .setAdministrativeState(AdministrativeState.UNLOCKED)
748 .setOperationalState(OperationalState.ENABLED)
749 .setLifecycleState(LifecycleState.INSTALLED)
750 .setAvailableCapacity(new AvailableCapacityBuilder().build())
751 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
752 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
757 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
758 createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
760 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
761 PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
763 Name nodeNames = new NameBuilder().setValueName("roadm node name")
764 .setValue(String.join("+", orNodeId, PHTNC_MEDIA)).build();
766 List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
767 // Empty random creation of mandatory fields for avoiding errors....
768 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
769 .setCostAlgorithm("Restricted Shortest Path - RSP")
770 .setCostName("HOP_COUNT")
771 .setCostValue("12345678")
773 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
774 .setFixedLatencyCharacteristic("12345678")
775 .setQueingLatencyCharacteristic("12345678")
776 .setJitterCharacteristic("12345678")
777 .setWanderCharacteristic("12345678")
778 .setTrafficPropertyName("FIXED_LATENCY")
780 return new NodeBuilder()
782 .setName(Map.of(nodeNames.key(), nodeNames))
783 .setLayerProtocolName(layerProtocols)
784 .setAdministrativeState(AdministrativeState.UNLOCKED)
785 .setOperationalState(OperationalState.ENABLED)
786 .setLifecycleState(LifecycleState.INSTALLED)
787 .setOwnedNodeEdgePoint(oneplist)
788 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(nodeUuid, oneplist.values()))
789 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
790 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
791 .setErrorCharacteristic("error")
792 .setLossCharacteristic("loss")
793 .setRepeatDeliveryCharacteristic("repeat delivery")
794 .setDeliveryOrderCharacteristic("delivery order")
795 .setUnavailableTimeCharacteristic("unavailable time")
796 .setServerIntegrityProcessCharacteristic("server integrity process")
800 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(Uuid nodeUuid,
801 Collection<OwnedNodeEdgePoint> onepl) {
802 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
803 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
804 nepMap = new HashMap<>();
805 for (OwnedNodeEdgePoint onep : onepl) {
806 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
807 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
808 .NodeEdgePointBuilder()
809 .setTopologyUuid(tapiTopoUuid)
810 .setNodeUuid(nodeUuid)
811 .setNodeEdgePointUuid(onep.key().getUuid())
813 nepMap.put(nep.key(), nep);
815 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
816 Map<RuleKey, Rule> ruleList = new HashMap<>();
817 Rule rule = new RuleBuilder()
818 .setLocalId("forward")
819 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
820 .setRuleType(RuleType.FORWARDING)
822 ruleList.put(rule.key(), rule);
823 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
824 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("rdm infra node rule group")
825 .getBytes(Charset.forName("UTF-8"))).toString()))
827 .setNodeEdgePoint(nepMap)
829 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
830 return nodeRuleGroupMap;
833 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps, Uuid nodeUuidDsr,
835 Map<LinkKey, Link> linkMap = new HashMap<>();
836 for (Mapping mapping : xpdrNetMaps) {
837 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
838 String sourceKey = String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint());
839 Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes(
840 (String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint()))
841 .getBytes(Charset.forName("UTF-8"))).toString());
842 String destKey = String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint());
843 Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes(
844 (String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint()))
845 .getBytes(Charset.forName("UTF-8"))).toString());
846 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
847 .setTopologyUuid(this.tapiTopoUuid)
848 .setNodeUuid(nodeUuidDsr)
849 .setNodeEdgePointUuid(sourceUuidTp)
851 nepList.put(sourceNep.key(), sourceNep);
852 NodeEdgePoint destNep = new NodeEdgePointBuilder()
853 .setTopologyUuid(this.tapiTopoUuid)
854 .setNodeUuid(nodeUuidOtsi)
855 .setNodeEdgePointUuid(destUuidTp)
857 nepList.put(destNep.key(), destNep);
858 Name linkName = new NameBuilder().setValueName("transitional link name")
859 .setValue(String.join("--",nodeId, sourceKey, destKey))
861 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
862 .setCostAlgorithm("Restricted Shortest Path - RSP")
863 .setCostName("HOP_COUNT")
864 .setCostValue("12345678")
866 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
867 .setFixedLatencyCharacteristic("12345678")
868 .setQueingLatencyCharacteristic("12345678")
869 .setJitterCharacteristic("12345678")
870 .setWanderCharacteristic("12345678")
871 .setTrafficPropertyName("FIXED_LATENCY")
873 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
874 .setRiskCharacteristicName("risk characteristic")
875 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
877 ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
878 .setValidationMechanism("validation mechanism")
879 .setValidationRobustness("validation robustness")
880 .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
882 Link transiLink = new LinkBuilder()
884 UUID.nameUUIDFromBytes((String.join("--", nodeId, sourceKey, destKey))
885 .getBytes(Charset.forName("UTF-8")))
887 .setName(Map.of(linkName.key(), linkName))
888 .setTransitionedLayerProtocolName(Arrays.asList(LayerProtocolName.ODU.getName(),
889 LayerProtocolName.PHOTONICMEDIA.getName()))
890 .setNodeEdgePoint(nepList)
891 .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.ODU))
892 .setDirection(ForwardingDirection.BIDIRECTIONAL)
893 .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
894 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
896 .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
897 .setRestorationPolicy(RestorationPolicy.NA)
899 .setAdministrativeState(AdministrativeState.UNLOCKED)
900 .setOperationalState(OperationalState.ENABLED)
901 .setLifecycleState(LifecycleState.INSTALLED)
902 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
903 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
905 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
906 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
907 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
908 .setErrorCharacteristic("error")
909 .setLossCharacteristic("loss")
910 .setRepeatDeliveryCharacteristic("repeat delivery")
911 .setDeliveryOrderCharacteristic("delivery order")
912 .setUnavailableTimeCharacteristic("unavailable time")
913 .setServerIntegrityProcessCharacteristic("server integrity process")
914 .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
916 linkMap.put(transiLink.key(), transiLink);
918 // return a map of links and then we can do merge the corresponding link map into the topology context
922 private OduSwitchingPools createTpdrSwitchPool() {
923 return new OduSwitchingPoolsBuilder().build();
926 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
928 List<TpId> tpl = new ArrayList<>();
930 for (int i = 1; i <= xpdrClMaps.size(); i++) {
931 tpId = new TpId("XPDR" + xpdrNb + CLIENT + i);
934 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
935 tpId = new TpId("XPDR" + xpdrNb + NETWORK + i);
938 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
939 NonBlockingList nbl = new NonBlockingListBuilder()
940 .setNblNumber(Uint16.valueOf(1))
943 nbMap.put(nbl.key(),nbl);
945 return new OduSwitchingPoolsBuilder()
946 .setSwitchingPoolNumber(Uint16.valueOf(1))
947 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
948 .setNonBlockingList(nbMap)
952 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
953 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
954 for (int i = 1; i <= xpdrClMaps.size(); i++) {
955 List<TpId> tpList = new ArrayList<>();
956 TpId tpId = new TpId("XPDR" + xpdrNb + CLIENT + i);
958 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
960 NonBlockingList nbl = new NonBlockingListBuilder()
961 .setNblNumber(Uint16.valueOf(i))
963 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
964 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
966 nbMap.put(nbl.key(),nbl);
968 return new OduSwitchingPoolsBuilder()
969 .setSwitchingPoolNumber(Uint16.valueOf(1))
970 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
971 .setNonBlockingList(nbMap)
975 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
976 List<Mapping> xpdrNetMaps,
977 Map<RuleKey, Rule> ruleList) {
978 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
979 // create NodeRuleGroup
981 for (Mapping tpMapping : xpdrNetMaps) {
982 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
983 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
984 nepList = new HashMap<>();
985 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
986 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
987 .node.rule.group.NodeEdgePointBuilder()
988 .setTopologyUuid(tapiTopoUuid)
989 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
990 (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8")))
992 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
993 (String.join("+", nodeId, I_OTSI, tpMapping.getLogicalConnectionPoint()))
994 .getBytes(Charset.forName("UTF-8"))).toString()))
996 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
997 .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
998 .node.rule.group.NodeEdgePointBuilder()
999 .setTopologyUuid(tapiTopoUuid)
1000 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1001 (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8")))
1003 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1004 (String.join("+", nodeId, E_OTSI, tpMapping.getLogicalConnectionPoint()))
1005 .getBytes(Charset.forName("UTF-8"))).toString()))
1007 nepList.put(inep.key(), inep);
1008 nepList.put(enep.key(), enep);
1009 // Empty random creation of mandatory fields for avoiding errors....
1010 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1011 .setCostAlgorithm("Restricted Shortest Path - RSP")
1012 .setCostName("HOP_COUNT")
1013 .setCostValue("12345678")
1015 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1016 .setFixedLatencyCharacteristic("12345678")
1017 .setQueingLatencyCharacteristic("12345678")
1018 .setJitterCharacteristic("12345678")
1019 .setWanderCharacteristic("12345678")
1020 .setTrafficPropertyName("FIXED_LATENCY")
1022 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1023 .setRiskCharacteristicName("risk characteristic")
1024 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1026 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1028 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
1031 .setNodeEdgePoint(nepList)
1032 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1033 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1034 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1036 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1039 return nodeRuleGroupMap;
1042 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1043 OduSwitchingPools oorOduSwitchingPool,
1044 Map<RuleKey, Rule> ruleList,
1045 Map<OwnedNodeEdgePointKey,
1046 OwnedNodeEdgePoint> onepl) {
1047 // create NodeRuleGroup
1048 if (oorOduSwitchingPool == null) {
1049 LOG.info("TPDR node --> no switching pool");
1050 return new HashMap<>();
1052 LOG.info("ONEPL = {}", onepl.values());
1053 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1055 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1056 LOG.info("Non blocking list = {}", nbl);
1057 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
1058 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
1059 nepList = new HashMap<>();
1060 for (TpId tp : nbl.getTpList()) {
1061 LOG.info("EDOU TP = {}", String.join("+", nodeId, E_ODU, tp.getValue()));
1062 LOG.info("DSR TP = {}", String.join("+", nodeId, DSR, tp.getValue()));
1063 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes(
1064 (String.join("+", nodeId, E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8")))
1066 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes(
1067 (String.join("+", nodeId, DSR, tp.getValue())).getBytes(Charset.forName("UTF-8")))
1069 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1070 || onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1071 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
1072 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
1073 .NodeEdgePointBuilder()
1074 .setTopologyUuid(tapiTopoUuid)
1075 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1076 (String.join("+", nodeId, DSR)).getBytes(Charset.forName("UTF-8")))
1078 .setNodeEdgePointUuid((tp.getValue().contains("CLIENT")) ? tp1Uuid : tpUuid)
1080 nepList.put(nep.key(), nep);
1083 // Empty random creation of mandatory fields for avoiding errors....
1084 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1085 .setCostAlgorithm("Restricted Shortest Path - RSP")
1086 .setCostName("HOP_COUNT")
1087 .setCostValue("12345678")
1089 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1090 .setFixedLatencyCharacteristic("12345678")
1091 .setQueingLatencyCharacteristic("12345678")
1092 .setJitterCharacteristic("12345678")
1093 .setWanderCharacteristic("12345678")
1094 .setTrafficPropertyName("FIXED_LATENCY")
1096 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1097 .setRiskCharacteristicName("risk characteristic")
1098 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1100 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1102 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1105 .setNodeEdgePoint(nepList)
1106 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1107 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1108 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1110 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1113 return nodeRuleGroupMap;
1116 private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1117 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1118 if (sicList == null) {
1119 return List.of(PHOTONICLAYERQUALIFIEROMS.class);
1121 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1122 LOG.info("SIC list = {}", sicList);
1123 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1124 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1125 .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa)))
1126 .setIfCapType(convertSupIfCapa(supInterCapa))
1128 supIfMap.put(supIfCapa.key(), supIfCapa);
1130 List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
1131 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1132 switch (lpn.getName()) {
1135 switch (sic.getIfCapType().getSimpleName()) {
1137 sclpqList.add(ODUTYPEODU2E.class);
1138 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1141 sclpqList.add(ODUTYPEODU2.class);
1142 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1145 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1148 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1149 sclpqList.add(ODUTYPEODU4.class);
1152 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1154 case "IfOCHOTU4ODU4":
1156 sclpqList.add(ODUTYPEODU4.class);
1159 LOG.error("IfCapability type not managed");
1163 case "PHOTONIC_MEDIA":
1164 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1165 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1166 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1167 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1171 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1178 private static Class<? extends SupportedIfCapability> convertSupIfCapa(Class<? extends
1179 SupportedIfCapability> ifCapType) {
1180 LOG.info("Interface Capability type = {}", ifCapType.getSimpleName());
1181 switch (ifCapType.getSimpleName()) {
1183 return If100GEODU4.class;
1184 case "IfOCHOTU4ODU4":
1185 return IfOCHOTU4ODU4.class;
1187 return If1GEODU0.class;
1189 return If10GEODU2e.class;
1191 return If10GEODU2.class;
1193 return If100GE.class;
1195 return If10GE.class;
1205 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1206 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1207 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1208 LOG.info("Creating tapi node in TAPI topology context");
1209 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1210 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
1211 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
1212 .child(Topology.class, new TopologyKey(tapiTopoUuid))
1215 Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setNode(nodeMap).build();
1217 // merge in datastore
1218 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1221 this.networkTransactionService.commit().get();
1222 } catch (InterruptedException | ExecutionException e) {
1223 LOG.error("Error populating TAPI topology: ", e);
1225 LOG.info("Roadm Node added succesfully.");
1228 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1229 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1230 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1231 LOG.info("Creating tapi node in TAPI topology context");
1232 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1233 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
1234 .child(org.opendaylight.yang.gen.v1.urn
1235 .onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
1236 .child(Topology.class, new TopologyKey(tapiTopoUuid))
1239 Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setLink(linkMap).build();
1241 // merge in datastore
1242 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1245 this.networkTransactionService.commit().get();
1246 } catch (InterruptedException | ExecutionException e) {
1247 LOG.error("Error populating TAPI topology: ", e);
1249 LOG.info("Roadm Link added succesfully.");
1252 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1253 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1254 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1256 ContextBuilder contextBuilder = new ContextBuilder();
1257 contextBuilder.setServiceInterfacePoint(sips);
1258 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1259 // merge in datastore
1260 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1261 contextBuilder.build());
1262 this.networkTransactionService.commit().get();
1263 LOG.info("TAPI SIPs merged successfully.");
1264 } catch (InterruptedException | ExecutionException e) {
1265 LOG.error("Failed to merge TAPI Sips", e);
1269 private void deleteLinkFromTopo(Uuid linkUuid) {
1270 // TODO: check if this IID is correct
1272 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1273 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1274 new TopologyKey(tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1275 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1276 this.networkTransactionService.commit().get();
1277 LOG.info("TAPI link deleted successfully.");
1278 } catch (InterruptedException | ExecutionException e) {
1279 LOG.error("Failed to delete TAPI link", e);
1283 private void deleteNodeFromTopo(Uuid nodeUuid) {
1284 // TODO: check if this IID is correct
1286 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1287 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1288 new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1289 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1290 this.networkTransactionService.commit().get();
1291 LOG.info("TAPI Node deleted successfully.");
1292 } catch (InterruptedException | ExecutionException e) {
1293 LOG.error("Failed to delete TAPI Node", e);
1297 private void deleteSipFromTopo(Uuid sipUuid) {
1298 // TODO: check if this IID is correct
1300 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1301 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1302 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1303 this.networkTransactionService.commit().get();
1304 LOG.info("TAPI SIP deleted successfully.");
1305 } catch (InterruptedException | ExecutionException e) {
1306 LOG.error("Failed to delete TAPI SIP", e);
1310 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1311 // TODO: check if this IID is correct
1312 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1313 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1314 .child(ConnectivityContext.class)
1316 ConnectivityContext connContext = null;
1318 Optional<ConnectivityContext> optConnContext =
1319 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1321 if (!optConnContext.isPresent()) {
1322 LOG.error("Couldnt retrieve connectivity context from datastore");
1325 connContext = optConnContext.get();
1326 } catch (InterruptedException | ExecutionException e) {
1327 LOG.error("Couldnt read connectivity context from datastore", e);
1329 if (connContext == null) {
1330 LOG.error("Connectivity context is empty");
1333 // Loop through services, check if the endpoint uuid is equal to the sip.
1334 // If so update state.
1335 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1336 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1337 if (connServMap != null) {
1338 for (ConnectivityService service:connServMap.values()) {
1339 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1340 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1341 .getServiceInterfacePointUuid().equals(sipUuid))) {
1342 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1343 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1344 .setAdministrativeState(AdministrativeState.LOCKED)
1345 .setOperationalState(OperationalState.DISABLED)
1346 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1348 updateConnectivityService(updService);
1352 // Update state of connections
1353 if (connMap != null) {
1354 for (Connection connection:connMap.values()) {
1355 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1356 Connection updConn = new ConnectionBuilder(connection)
1357 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1358 .setOperationalState(OperationalState.DISABLED)
1360 updateConnection(updConn);
1366 private void updateConnection(Connection updConn) {
1367 // TODO: check if this IID is correct
1368 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1369 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1370 .child(ConnectivityContext.class).child(Connection.class,
1371 new ConnectionKey(updConn.getUuid())).build();
1372 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1374 this.networkTransactionService.commit().get();
1375 } catch (InterruptedException | ExecutionException e) {
1376 LOG.error("Error committing into datastore", e);
1380 private void updateConnectivityService(ConnectivityService updService) {
1381 // TODO: check if this IID is correct
1382 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1383 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1384 .child(ConnectivityContext.class).child(ConnectivityService.class,
1385 new ConnectivityServiceKey(updService.getUuid())).build();
1386 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1388 this.networkTransactionService.commit().get();
1389 } catch (InterruptedException | ExecutionException e) {
1390 LOG.error("Error committing into datastore", e);