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.rev210426.mapping.Mapping;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GE;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
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.TotalSizeBuilder;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ProtectionType;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RestorationPolicy;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePoint;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointKey;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.ResilienceTypeBuilder;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanism;
130 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanismBuilder;
131 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
132 import org.opendaylight.yangtools.yang.common.Uint16;
133 import org.opendaylight.yangtools.yang.common.Uint32;
134 import org.opendaylight.yangtools.yang.common.Uint64;
135 import org.slf4j.Logger;
136 import org.slf4j.LoggerFactory;
138 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
140 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
141 private static final String DSR = "DSR";
142 private static final String I_ODU = "iODU";
143 private static final String E_ODU = "eODU";
144 private static final String OTSI = "OTSi";
145 private static final String E_OTSI = "eOTSi";
146 private static final String I_OTSI = "iOTSi";
147 private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA";
148 private static final String MC = "MEDIA_CHANNEL";
149 private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL";
150 private static final String CLIENT = "-CLIENT";
151 private static final String NETWORK = "-NETWORK";
152 private static final String XPDR = "-XPDR";
153 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER
154 .getBytes(Charset.forName("UTF-8"))).toString());
155 private final NetworkTransactionService networkTransactionService;
156 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
157 private final R2RTapiLinkDiscovery linkDiscovery;
159 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
160 NetworkTransactionService networkTransactionService) {
161 this.networkTransactionService = networkTransactionService;
162 this.sipMap = new HashMap<>();
163 this.linkDiscovery = linkDiscovery;
167 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
168 // TODO -> Implementation with PortMappingListener
169 // check if port mapping exists or not...
170 if (node.getMapping() == null) {
171 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
175 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
177 // check type of device, check version and create node mapping
178 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
180 // transform flat mapping list to per degree and per srg mapping lists
181 Map<String, List<Mapping>> mapDeg = new HashMap<>();
182 Map<String, List<Mapping>> mapSrg = new HashMap<>();
183 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
184 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
186 List<String> nodeShardList = getRoadmNodelist(mappingList);
188 // populate degree and srg LCP map
189 for (String str : nodeShardList) {
190 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
191 .collect(Collectors.toList());
192 if (str.contains("DEG")) {
193 mapDeg.put(str, interList);
194 } else if (str.contains("SRG")) {
195 mapSrg.put(str, interList);
197 LOG.error("unknown element");
200 // Transform LCPs into ONEP
201 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
202 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
203 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
206 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node roadmNode =
207 createRoadmTapiNode(orNodeId, onepMap);
208 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
209 mergeSipsinContext(this.sipMap);
210 // TODO add states corresponding to device config -> based on mapping.
211 // This should be possible after Gilles work is merged
213 // rdm to rdm link creation if neighbour roadm is mounted
214 LOG.info("checking if neighbor roadm exists");
215 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
217 if (!rdm2rdmLinks.isEmpty()) {
218 mergeLinkinTopology(rdm2rdmLinks);
221 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
222 List<Mapping> networkMappings = node.nonnullMapping().values()
223 .stream().filter(k -> k.getLogicalConnectionPoint()
224 .contains("NETWORK")).collect(Collectors.toList());
225 Map<Integer, String> xpdrMap = new HashMap<>();
226 for (Mapping mapping : networkMappings) {
227 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
228 String nodeId = node.getNodeId() + XPDR + xpdrNb;
229 if (!xpdrMap.containsKey(xpdrNb)) {
230 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
231 .stream().filter(k -> k.getLogicalConnectionPoint()
232 .contains("XPDR" + xpdrNb + NETWORK)).collect(Collectors.toList());
233 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
234 .stream().filter(k -> k.getLogicalConnectionPoint()
235 .contains("XPDR" + xpdrNb + CLIENT)).collect(Collectors.toList());
236 xpdrMap.put(xpdrNb, node.getNodeId());
238 // create switching pool
239 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
240 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
242 // node transformation
243 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
244 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool));
246 // add nodes and sips to tapi context
247 mergeNodeinTopology(nodeMap);
248 mergeSipsinContext(this.sipMap);
252 // Device not managed yet
255 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
256 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
257 OduSwitchingPools oorOduSwitchingPool) {
258 Map<NodeKey, Node> nodeMap = new HashMap<>();
259 LOG.info("creation of a DSR/ODU node for {}", nodeId);
260 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, DSR))
261 .getBytes(Charset.forName("UTF-8"))).toString());
262 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
263 String.join("+", nodeId, DSR)).build();
264 List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR,
265 LayerProtocolName.ODU);
266 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
267 .Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr), dsrLayerProtocols,
268 nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
270 nodeMap.put(dsrNode.key(), dsrNode);
272 // node creation [otsi]
273 LOG.info("creation of an OTSi node for {}", nodeId);
274 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, OTSI))
275 .getBytes(Charset.forName("UTF-8"))).toString());
276 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
277 String.join("+", nodeId, OTSI)).build();
278 List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
279 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
280 .Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi), otsiLayerProtocols,
281 nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
283 nodeMap.put(otsiNode.key(), otsiNode);
285 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
286 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
287 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps, nodeUuidDsr,
289 mergeLinkinTopology(linkMap);
294 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
296 // todo: are switching pool correct here??
300 return createTpdrSwitchPool();
303 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
306 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
308 LOG.warn("Xpdr type {} not supported", xpdrType);
313 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
314 Map<String, List<Mapping>> mapSrg) {
315 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
316 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
317 // For each srg node. Loop through the LCPs and create neps and sips for PP
318 for (Mapping m:entry.getValue()) {
319 if (!m.getLogicalConnectionPoint().contains("PP")) {
320 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
323 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
324 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
325 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
326 onepMap.putAll(srgNeps);
332 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
333 Map<String, List<Mapping>> mapDeg) {
334 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
335 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
336 // For each degree node. Loop through the LCPs and create neps and sips for TTP
337 for (Mapping m:entry.getValue()) {
338 if (!m.getLogicalConnectionPoint().contains("TTP")) {
339 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
342 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
343 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
344 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
345 onepMap.putAll(degNeps);
351 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
352 List<String> nodeShardList = new ArrayList<>();
353 for (Mapping mapping : mappingList) {
354 // TODO -> maybe we need to check the id based on the version
355 String str = mapping.getLogicalConnectionPoint().split("-")[0];
356 LOG.info("LCP = {}", str);
357 if (!nodeShardList.contains(str)) {
358 nodeShardList.add(str);
361 return nodeShardList;
365 public void deleteTapinode(String nodeId) {
366 // TODO: check for null objects
367 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
368 // This will delete NEPs. Then check for links that have this node and delete them.
369 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
370 LOG.info("Deleting node {} from TAPI topology", nodeId);
371 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
372 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
373 new TopologyKey(tapiTopoUuid)).build();
374 Topology topology = null;
376 Optional<Topology> optTopology =
377 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
378 if (!optTopology.isPresent()) {
379 LOG.error("No topology object present. Error deleting node {}", nodeId);
382 topology = optTopology.get();
383 } catch (InterruptedException | ExecutionException e) {
384 LOG.error("Couldnt read tapi topology from datastore", e);
386 if (topology == null) {
387 LOG.error("Topology is null, nothing to delete");
390 if (topology.getNode() == null) {
391 LOG.error("No nodes in topology");
394 if (nodeId.contains("ROADM")) {
395 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
396 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, PHTNC_MEDIA))
397 .getBytes(Charset.forName("UTF-8"))).toString());
398 deleteNodeFromTopo(nodeUuid);
400 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
401 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
402 for (Node tapiNode:topology.getNode().values()) {
403 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
404 // Found node we need to delete
405 deleteNodeFromTopo(tapiNode.getUuid());
409 // Delete links of topology
410 Map<LinkKey, Link> linkMap = topology.getLink();
411 if (linkMap != null) {
412 for (Link link:linkMap.values()) {
413 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
414 deleteLinkFromTopo(link.getUuid());
418 // Delete sips of sip map
419 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
420 Context context = null;
422 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
424 if (!optContext.isPresent()) {
425 LOG.error("No context object present in datastore.");
428 context = optContext.get();
429 } catch (InterruptedException | ExecutionException e) {
430 LOG.error("Couldnt read tapi context from datastore", e);
432 if (context == null) {
433 LOG.error("Context is null, nothing to delete");
436 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
438 for (ServiceInterfacePoint sip:sips.values()) {
439 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
440 // Update state of services that have this sip as an endpoint and also connections
441 updateConnectivityServicesState(sip.getUuid(), nodeId);
442 deleteSipFromTopo(sip.getUuid());
448 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, List<LayerProtocolName> layerProtocols,
449 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
450 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
451 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
452 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
453 Map<RuleKey, Rule> ruleList = new HashMap<>();
454 Rule rule = new RuleBuilder()
455 .setLocalId("forward")
456 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
457 .setRuleType(RuleType.FORWARDING)
459 ruleList.put(rule.key(), rule);
460 if (layerProtocols.contains(LayerProtocolName.DSR)) {
461 // neps for dsr/odu layer
462 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
463 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
464 onepl.putAll(dsroduNeps);
465 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
466 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
467 // neps for photonic layer
468 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
469 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
470 onepl.putAll(phtmdNeps);
471 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
473 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
474 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
476 // Empty random creation of mandatory fields for avoiding errors....
477 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
478 .setCostAlgorithm("Restricted Shortest Path - RSP")
479 .setCostName("HOP_COUNT")
480 .setCostValue("12345678")
482 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
483 .setFixedLatencyCharacteristic("12345678")
484 .setQueingLatencyCharacteristic("12345678")
485 .setJitterCharacteristic("12345678")
486 .setWanderCharacteristic("12345678")
487 .setTrafficPropertyName("FIXED_LATENCY")
489 return new NodeBuilder()
492 .setLayerProtocolName(layerProtocols)
493 .setAdministrativeState(AdministrativeState.UNLOCKED)
494 .setOperationalState(OperationalState.ENABLED)
495 .setLifecycleState(LifecycleState.INSTALLED)
496 .setOwnedNodeEdgePoint(onepl)
497 .setNodeRuleGroup(nodeRuleGroupList)
498 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
499 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
500 .setErrorCharacteristic("error")
501 .setLossCharacteristic("loss")
502 .setRepeatDeliveryCharacteristic("repeat delivery")
503 .setDeliveryOrderCharacteristic("delivery order")
504 .setUnavailableTimeCharacteristic("unavailable time")
505 .setServerIntegrityProcessCharacteristic("server integrity process")
509 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
510 List<Mapping> xpdrNetMaps) {
511 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
513 // iNep creation on otsi node
514 for (int i = 0; i < xpdrNetMaps.size(); i++) {
515 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
516 (String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
517 .getBytes(Charset.forName("UTF-8")))
519 Name onedName = new NameBuilder()
520 .setValueName("iNodeEdgePoint")
521 .setValue(String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
524 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
525 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
526 true, String.join("+", nodeId, I_OTSI),
527 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
528 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
529 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
530 onepl.put(onep.key(), onep);
532 // eNep creation on otsi node
533 for (int i = 0; i < xpdrNetMaps.size(); i++) {
534 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
535 (String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
536 .getBytes(Charset.forName("UTF-8"))).toString());
537 Name onedName = new NameBuilder()
538 .setValueName("eNodeEdgePoint")
539 .setValue(String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
542 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
543 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
544 false, String.join("+", nodeId, E_OTSI),
545 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
546 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
547 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
548 onepl.put(onep.key(), onep);
550 // Photonic Media Nep creation on otsi node
551 for (int i = 0; i < xpdrNetMaps.size(); i++) {
552 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
553 (String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
554 .getBytes(Charset.forName("UTF-8"))).toString());
555 Name onedName = new NameBuilder()
556 .setValueName("PhotMedNodeEdgePoint")
557 .setValue(String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
560 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
561 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
562 false, String.join("+", nodeId, PHTNC_MEDIA),
563 xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
564 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
565 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
566 onepl.put(onep.key(), onep);
571 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
572 List<Mapping> xpdrNetMaps,
573 XpdrNodeTypes xponderType) {
574 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
575 // client nep creation on DSR node
576 for (int i = 0; i < xpdrClMaps.size(); i++) {
577 LOG.info("Client NEP = {}", String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
578 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
579 (String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()))
580 .getBytes(Charset.forName("UTF-8"))).toString());
581 NameBuilder nameBldr = new NameBuilder().setValue(
582 String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
584 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
585 name = nameBldr.setValueName("100G-tpdr").build();
587 name = nameBldr.setValueName("NodeEdgePoint_C").build();
590 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
591 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
592 String.join("+", nodeId, DSR), xpdrClMaps.get(i).getSupportedInterfaceCapability(),
593 transformOperState(xpdrClMaps.get(i).getPortOperState()),
594 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
595 onepl.put(onep.key(), onep);
597 // network nep creation on I_ODU node
598 for (int i = 0; i < xpdrNetMaps.size(); i++) {
599 LOG.info("iODU NEP = {}", String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()));
600 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
601 (String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
602 .getBytes(Charset.forName("UTF-8"))).toString());
603 Name onedName = new NameBuilder()
604 .setValueName("iNodeEdgePoint_N")
605 .setValue(String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
608 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
609 Map.of(onedName.key(), onedName),
610 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
611 String.join("+", nodeId, I_ODU), xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
612 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
613 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
614 onepl.put(onep.key(), onep);
616 // network nep creation on E_ODU node
617 for (int i = 0; i < xpdrNetMaps.size(); i++) {
618 LOG.info("eODU NEP = {}", String.join("+", nodeId, E_ODU,
619 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
620 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
621 (String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
622 .getBytes(Charset.forName("UTF-8"))).toString());
623 Name onedName = new NameBuilder()
624 .setValueName("eNodeEdgePoint_N")
625 .setValue(String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint()))
628 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
629 Map.of(onedName.key(), onedName),
630 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
631 String.join("+", nodeId, E_ODU), xpdrNetMaps.get(i).getSupportedInterfaceCapability(),
632 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
633 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
634 onepl.put(onep.key(), onep);
639 private OperationalState transformOperState(String operString) {
640 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
641 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
644 private AdministrativeState transformAdminState(String adminString) {
645 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
646 .setNetworkAdminState(adminString);
647 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
650 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
651 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
653 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
654 OperationalState operState, AdministrativeState adminState) {
655 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
657 .setLayerProtocolName(nepProtocol)
660 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
661 supportedInterfaceCapability, operState, adminState));
663 LOG.debug("Node layer {}", nodeProtocol.getName());
664 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
665 supportedInterfaceCapability, nodeProtocol));
666 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
667 .setAdministrativeState(adminState).setOperationalState(operState)
668 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
669 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
670 return onepBldr.build();
673 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
674 boolean withSip, OperationalState operState,
675 AdministrativeState adminState) {
676 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
677 // PHOTONIC MEDIA nep
678 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, PHTNC_MEDIA, tpId))
679 .getBytes(Charset.forName("UTF-8")))
681 Name nepName = new NameBuilder()
682 .setValueName(PHTNC_MEDIA + "NodeEdgePoint")
683 .setValue(String.join("+", orNodeId, PHTNC_MEDIA, tpId))
685 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
687 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
688 .setName(Map.of(nepName.key(), nepName))
689 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
690 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
691 .setAdministrativeState(adminState).setOperationalState(operState)
692 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
693 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
695 onepMap.put(onep.key(), onep);
698 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, MC, tpId))
699 .getBytes(Charset.forName("UTF-8")))
701 Name nepName1 = new NameBuilder()
702 .setValueName(MC + "NodeEdgePoint")
703 .setValue(String.join("+", orNodeId, MC, tpId))
705 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
707 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
708 .setName(Map.of(nepName1.key(), nepName1))
709 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
710 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
711 .setAdministrativeState(adminState).setOperationalState(operState)
712 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
713 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
715 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
716 tpId, String.join("+", orNodeId, MC), null, operState, adminState));
718 OwnedNodeEdgePoint onep1 = onepBldr1.build();
719 onepMap.put(onep1.key(), onep1);
722 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, OTSI_MC, tpId))
723 .getBytes(Charset.forName("UTF-8")))
725 Name nepName2 = new NameBuilder()
726 .setValueName(OTSI_MC + "NodeEdgePoint")
727 .setValue(String.join("+", orNodeId, OTSI_MC, tpId))
730 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
732 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
733 .setName(Map.of(nepName2.key(), nepName2))
734 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
735 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
736 .setAdministrativeState(adminState).setOperationalState(operState)
737 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
738 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
740 onepMap.put(onep2.key(), onep2);
744 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
745 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
746 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
747 OperationalState operState, AdministrativeState adminState) {
748 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
749 for (int i = 0; i < nb; i++) {
750 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
751 tpid)).getBytes(Charset.forName("UTF-8"))).toString());
752 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
753 .setServiceInterfacePointUuid(sipUuid).build();
754 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint sip
755 = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
756 operState, adminState);
757 this.sipMap.put(sip.key(), sip);
758 LOG.info("SIP created {}", sip.getUuid());
759 // this.tapiSips.put(sip.key(), sip);
760 msipl.put(msip.key(), msip);
765 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
766 List<Class<? extends SupportedIfCapability>> supportedInterfaceCapability,
767 OperationalState operState, AdministrativeState adminState) {
768 // TODO: what value should be set in total capacity and available capacity
769 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
770 Name sipName = new NameBuilder()
771 .setValueName("SIP name")
772 .setValue(String.join("+", nodeid, tpid))
774 return new ServiceInterfacePointBuilder()
776 .setName(Map.of(sipName.key(), sipName))
777 .setLayerProtocolName(layerProtocol)
778 .setAdministrativeState(adminState)
779 .setOperationalState(operState)
780 .setLifecycleState(LifecycleState.INSTALLED)
781 .setAvailableCapacity(new AvailableCapacityBuilder().build())
782 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
783 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
788 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
789 createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
791 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
792 PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
794 Name nodeNames = new NameBuilder().setValueName("roadm node name")
795 .setValue(String.join("+", orNodeId, PHTNC_MEDIA)).build();
797 List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
798 // Empty random creation of mandatory fields for avoiding errors....
799 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
800 .setCostAlgorithm("Restricted Shortest Path - RSP")
801 .setCostName("HOP_COUNT")
802 .setCostValue("12345678")
804 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
805 .setFixedLatencyCharacteristic("12345678")
806 .setQueingLatencyCharacteristic("12345678")
807 .setJitterCharacteristic("12345678")
808 .setWanderCharacteristic("12345678")
809 .setTrafficPropertyName("FIXED_LATENCY")
811 return new NodeBuilder()
813 .setName(Map.of(nodeNames.key(), nodeNames))
814 .setLayerProtocolName(layerProtocols)
815 .setAdministrativeState(AdministrativeState.UNLOCKED)
816 .setOperationalState(OperationalState.ENABLED)
817 .setLifecycleState(LifecycleState.INSTALLED)
818 .setOwnedNodeEdgePoint(oneplist)
819 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
820 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
821 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
822 .setErrorCharacteristic("error")
823 .setLossCharacteristic("loss")
824 .setRepeatDeliveryCharacteristic("repeat delivery")
825 .setDeliveryOrderCharacteristic("delivery order")
826 .setUnavailableTimeCharacteristic("unavailable time")
827 .setServerIntegrityProcessCharacteristic("server integrity process")
831 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
832 Collection<OwnedNodeEdgePoint> onepl) {
833 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
834 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
835 nepMap = new HashMap<>();
836 for (OwnedNodeEdgePoint onep : onepl) {
837 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
838 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
839 .NodeEdgePointBuilder()
840 .setTopologyUuid(tapiTopoUuid)
841 .setNodeUuid(nodeUuid)
842 .setNodeEdgePointUuid(onep.key().getUuid())
844 nepMap.put(nep.key(), nep);
846 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
847 Map<RuleKey, Rule> ruleList = new HashMap<>();
848 Rule rule = new RuleBuilder()
849 .setLocalId("forward")
850 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
851 .setRuleType(RuleType.FORWARDING)
853 ruleList.put(rule.key(), rule);
854 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
855 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
856 .getBytes(Charset.forName("UTF-8"))).toString()))
858 .setNodeEdgePoint(nepMap)
860 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
861 return nodeRuleGroupMap;
864 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps, Uuid nodeUuidDsr,
866 Map<LinkKey, Link> linkMap = new HashMap<>();
867 for (Mapping mapping : xpdrNetMaps) {
868 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
869 String sourceKey = String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint());
870 Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes(
871 (String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint()))
872 .getBytes(Charset.forName("UTF-8"))).toString());
873 String destKey = String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint());
874 Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes(
875 (String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint()))
876 .getBytes(Charset.forName("UTF-8"))).toString());
877 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
878 .setTopologyUuid(this.tapiTopoUuid)
879 .setNodeUuid(nodeUuidDsr)
880 .setNodeEdgePointUuid(sourceUuidTp)
882 nepList.put(sourceNep.key(), sourceNep);
883 NodeEdgePoint destNep = new NodeEdgePointBuilder()
884 .setTopologyUuid(this.tapiTopoUuid)
885 .setNodeUuid(nodeUuidOtsi)
886 .setNodeEdgePointUuid(destUuidTp)
888 nepList.put(destNep.key(), destNep);
889 Name linkName = new NameBuilder().setValueName("transitional link name")
890 .setValue(String.join("--",nodeId, sourceKey, destKey))
892 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
893 .setCostAlgorithm("Restricted Shortest Path - RSP")
894 .setCostName("HOP_COUNT")
895 .setCostValue("12345678")
897 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
898 .setFixedLatencyCharacteristic("12345678")
899 .setQueingLatencyCharacteristic("12345678")
900 .setJitterCharacteristic("12345678")
901 .setWanderCharacteristic("12345678")
902 .setTrafficPropertyName("FIXED_LATENCY")
904 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
905 .setRiskCharacteristicName("risk characteristic")
906 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
908 ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
909 .setValidationMechanism("validation mechanism")
910 .setValidationRobustness("validation robustness")
911 .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
913 Link transiLink = new LinkBuilder()
915 UUID.nameUUIDFromBytes((String.join("--", nodeId, sourceKey, destKey))
916 .getBytes(Charset.forName("UTF-8")))
918 .setName(Map.of(linkName.key(), linkName))
919 .setTransitionedLayerProtocolName(Arrays.asList(LayerProtocolName.ODU.getName(),
920 LayerProtocolName.PHOTONICMEDIA.getName()))
921 .setNodeEdgePoint(nepList)
922 .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.ODU))
923 .setDirection(ForwardingDirection.BIDIRECTIONAL)
924 .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
925 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
927 .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
928 .setRestorationPolicy(RestorationPolicy.NA)
930 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
931 .setOperationalState(transformOperState(mapping.getPortOperState()))
932 .setLifecycleState(LifecycleState.INSTALLED)
933 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
934 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
936 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
937 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
938 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
939 .setErrorCharacteristic("error")
940 .setLossCharacteristic("loss")
941 .setRepeatDeliveryCharacteristic("repeat delivery")
942 .setDeliveryOrderCharacteristic("delivery order")
943 .setUnavailableTimeCharacteristic("unavailable time")
944 .setServerIntegrityProcessCharacteristic("server integrity process")
945 .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
947 linkMap.put(transiLink.key(), transiLink);
949 // return a map of links and then we can do merge the corresponding link map into the topology context
953 private OduSwitchingPools createTpdrSwitchPool() {
954 return new OduSwitchingPoolsBuilder().build();
957 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
959 List<TpId> tpl = new ArrayList<>();
961 for (int i = 1; i <= xpdrClMaps.size(); i++) {
962 tpId = new TpId("XPDR" + xpdrNb + CLIENT + i);
965 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
966 tpId = new TpId("XPDR" + xpdrNb + NETWORK + i);
969 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
970 NonBlockingList nbl = new NonBlockingListBuilder()
971 .setNblNumber(Uint16.valueOf(1))
974 nbMap.put(nbl.key(),nbl);
976 return new OduSwitchingPoolsBuilder()
977 .setSwitchingPoolNumber(Uint16.valueOf(1))
978 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
979 .setNonBlockingList(nbMap)
983 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
984 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
985 for (int i = 1; i <= xpdrClMaps.size(); i++) {
986 List<TpId> tpList = new ArrayList<>();
987 TpId tpId = new TpId("XPDR" + xpdrNb + CLIENT + i);
989 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
991 NonBlockingList nbl = new NonBlockingListBuilder()
992 .setNblNumber(Uint16.valueOf(i))
994 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
995 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
997 nbMap.put(nbl.key(),nbl);
999 return new OduSwitchingPoolsBuilder()
1000 .setSwitchingPoolNumber(Uint16.valueOf(1))
1001 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1002 .setNonBlockingList(nbMap)
1006 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
1007 List<Mapping> xpdrNetMaps,
1008 Map<RuleKey, Rule> ruleList) {
1009 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1010 // create NodeRuleGroup
1012 for (Mapping tpMapping : xpdrNetMaps) {
1013 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
1014 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
1015 nepList = new HashMap<>();
1016 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
1017 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1018 .node.rule.group.NodeEdgePointBuilder()
1019 .setTopologyUuid(tapiTopoUuid)
1020 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1021 (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8")))
1023 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1024 (String.join("+", nodeId, I_OTSI, tpMapping.getLogicalConnectionPoint()))
1025 .getBytes(Charset.forName("UTF-8"))).toString()))
1027 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
1028 .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1029 .node.rule.group.NodeEdgePointBuilder()
1030 .setTopologyUuid(tapiTopoUuid)
1031 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1032 (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8")))
1034 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1035 (String.join("+", nodeId, E_OTSI, tpMapping.getLogicalConnectionPoint()))
1036 .getBytes(Charset.forName("UTF-8"))).toString()))
1038 nepList.put(inep.key(), inep);
1039 nepList.put(enep.key(), enep);
1040 // Empty random creation of mandatory fields for avoiding errors....
1041 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1042 .setCostAlgorithm("Restricted Shortest Path - RSP")
1043 .setCostName("HOP_COUNT")
1044 .setCostValue("12345678")
1046 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1047 .setFixedLatencyCharacteristic("12345678")
1048 .setQueingLatencyCharacteristic("12345678")
1049 .setJitterCharacteristic("12345678")
1050 .setWanderCharacteristic("12345678")
1051 .setTrafficPropertyName("FIXED_LATENCY")
1053 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1054 .setRiskCharacteristicName("risk characteristic")
1055 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1057 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1059 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
1062 .setNodeEdgePoint(nepList)
1063 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1064 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1065 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1067 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1070 return nodeRuleGroupMap;
1073 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1074 OduSwitchingPools oorOduSwitchingPool,
1075 Map<RuleKey, Rule> ruleList,
1076 Map<OwnedNodeEdgePointKey,
1077 OwnedNodeEdgePoint> onepl) {
1078 // create NodeRuleGroup
1079 if (oorOduSwitchingPool == null) {
1080 LOG.info("TPDR node --> no switching pool");
1081 return new HashMap<>();
1083 LOG.info("ONEPL = {}", onepl.values());
1084 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1086 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1087 LOG.info("Non blocking list = {}", nbl);
1088 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
1089 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
1090 nepList = new HashMap<>();
1091 for (TpId tp : nbl.getTpList()) {
1092 LOG.info("EDOU TP = {}", String.join("+", nodeId, E_ODU, tp.getValue()));
1093 LOG.info("DSR TP = {}", String.join("+", nodeId, DSR, tp.getValue()));
1094 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes(
1095 (String.join("+", nodeId, E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8")))
1097 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes(
1098 (String.join("+", nodeId, DSR, tp.getValue())).getBytes(Charset.forName("UTF-8")))
1100 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1101 || onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1102 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
1103 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
1104 .NodeEdgePointBuilder()
1105 .setTopologyUuid(tapiTopoUuid)
1106 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1107 (String.join("+", nodeId, DSR)).getBytes(Charset.forName("UTF-8")))
1109 .setNodeEdgePointUuid((tp.getValue().contains("CLIENT")) ? tp1Uuid : tpUuid)
1111 nepList.put(nep.key(), nep);
1114 // Empty random creation of mandatory fields for avoiding errors....
1115 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1116 .setCostAlgorithm("Restricted Shortest Path - RSP")
1117 .setCostName("HOP_COUNT")
1118 .setCostValue("12345678")
1120 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1121 .setFixedLatencyCharacteristic("12345678")
1122 .setQueingLatencyCharacteristic("12345678")
1123 .setJitterCharacteristic("12345678")
1124 .setWanderCharacteristic("12345678")
1125 .setTrafficPropertyName("FIXED_LATENCY")
1127 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1128 .setRiskCharacteristicName("risk characteristic")
1129 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1131 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1133 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8")))
1136 .setNodeEdgePoint(nepList)
1137 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1138 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1139 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1141 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1144 return nodeRuleGroupMap;
1147 private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(
1148 List<Class<? extends SupportedIfCapability>> sicList, LayerProtocolName lpn) {
1149 if (sicList == null) {
1150 return List.of(PHOTONICLAYERQUALIFIEROMS.class);
1152 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1153 LOG.info("SIC list = {}", sicList);
1154 for (Class<? extends SupportedIfCapability> supInterCapa : sicList) {
1155 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1156 .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa)))
1157 .setIfCapType(convertSupIfCapa(supInterCapa))
1159 supIfMap.put(supIfCapa.key(), supIfCapa);
1161 List<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqList = new ArrayList<>();
1162 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1163 switch (lpn.getName()) {
1166 switch (sic.getIfCapType().getSimpleName()) {
1168 sclpqList.add(ODUTYPEODU2E.class);
1169 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1172 sclpqList.add(ODUTYPEODU2.class);
1173 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1176 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class);
1179 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1180 sclpqList.add(ODUTYPEODU4.class);
1183 sclpqList.add(DIGITALSIGNALTYPE100GigE.class);
1185 case "IfOCHOTU4ODU4":
1187 sclpqList.add(ODUTYPEODU4.class);
1190 LOG.error("IfCapability type not managed");
1194 case "PHOTONIC_MEDIA":
1195 if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1196 || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1197 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class);
1198 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class);
1202 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1209 private static Class<? extends SupportedIfCapability> convertSupIfCapa(Class<? extends
1210 SupportedIfCapability> ifCapType) {
1211 LOG.info("Interface Capability type = {}", ifCapType.getSimpleName());
1212 switch (ifCapType.getSimpleName()) {
1214 return If100GEODU4.class;
1215 case "IfOCHOTU4ODU4":
1216 return IfOCHOTU4ODU4.class;
1218 return If1GEODU0.class;
1220 return If10GEODU2e.class;
1222 return If10GEODU2.class;
1224 return If100GE.class;
1226 return If10GE.class;
1236 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1237 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1238 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1239 LOG.info("Creating tapi node in TAPI topology context");
1240 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1241 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
1242 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
1243 .child(Topology.class, new TopologyKey(tapiTopoUuid))
1246 Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setNode(nodeMap).build();
1248 // merge in datastore
1249 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1252 this.networkTransactionService.commit().get();
1253 } catch (InterruptedException | ExecutionException e) {
1254 LOG.error("Error populating TAPI topology: ", e);
1256 LOG.info("Roadm Node added succesfully.");
1259 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1260 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1261 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1262 LOG.info("Creating tapi node in TAPI topology context");
1263 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1264 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
1265 .child(org.opendaylight.yang.gen.v1.urn
1266 .onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
1267 .child(Topology.class, new TopologyKey(tapiTopoUuid))
1270 Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setLink(linkMap).build();
1272 // merge in datastore
1273 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1276 this.networkTransactionService.commit().get();
1277 } catch (InterruptedException | ExecutionException e) {
1278 LOG.error("Error populating TAPI topology: ", e);
1280 LOG.info("Roadm Link added succesfully.");
1283 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1284 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1285 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1287 ContextBuilder contextBuilder = new ContextBuilder();
1288 contextBuilder.setServiceInterfacePoint(sips);
1289 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1290 // merge in datastore
1291 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1292 contextBuilder.build());
1293 this.networkTransactionService.commit().get();
1294 LOG.info("TAPI SIPs merged successfully.");
1295 } catch (InterruptedException | ExecutionException e) {
1296 LOG.error("Failed to merge TAPI Sips", e);
1300 private void deleteLinkFromTopo(Uuid linkUuid) {
1301 // TODO: check if this IID is correct
1303 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1304 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1305 new TopologyKey(tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1306 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1307 this.networkTransactionService.commit().get();
1308 LOG.info("TAPI link deleted successfully.");
1309 } catch (InterruptedException | ExecutionException e) {
1310 LOG.error("Failed to delete TAPI link", e);
1314 private void deleteNodeFromTopo(Uuid nodeUuid) {
1315 // TODO: check if this IID is correct
1317 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1318 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1319 new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1320 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1321 this.networkTransactionService.commit().get();
1322 LOG.info("TAPI Node deleted successfully.");
1323 } catch (InterruptedException | ExecutionException e) {
1324 LOG.error("Failed to delete TAPI Node", e);
1328 private void deleteSipFromTopo(Uuid sipUuid) {
1329 // TODO: check if this IID is correct
1331 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1332 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1333 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1334 this.networkTransactionService.commit().get();
1335 LOG.info("TAPI SIP deleted successfully.");
1336 } catch (InterruptedException | ExecutionException e) {
1337 LOG.error("Failed to delete TAPI SIP", e);
1341 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1342 // TODO: check if this IID is correct
1343 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1344 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1345 .child(ConnectivityContext.class)
1347 ConnectivityContext connContext = null;
1349 Optional<ConnectivityContext> optConnContext =
1350 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1352 if (!optConnContext.isPresent()) {
1353 LOG.error("Couldnt retrieve connectivity context from datastore");
1356 connContext = optConnContext.get();
1357 } catch (InterruptedException | ExecutionException e) {
1358 LOG.error("Couldnt read connectivity context from datastore", e);
1360 if (connContext == null) {
1361 LOG.error("Connectivity context is empty");
1364 // Loop through services, check if the endpoint uuid is equal to the sip.
1365 // If so update state.
1366 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1367 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1368 if (connServMap != null) {
1369 for (ConnectivityService service:connServMap.values()) {
1370 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1371 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1372 .getServiceInterfacePointUuid().equals(sipUuid))) {
1373 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1374 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1375 .setAdministrativeState(AdministrativeState.LOCKED)
1376 .setOperationalState(OperationalState.DISABLED)
1377 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1379 updateConnectivityService(updService);
1383 // Update state of connections
1384 if (connMap != null) {
1385 for (Connection connection:connMap.values()) {
1386 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1387 Connection updConn = new ConnectionBuilder(connection)
1388 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1389 .setOperationalState(OperationalState.DISABLED)
1391 updateConnection(updConn);
1397 private void updateConnection(Connection updConn) {
1398 // TODO: check if this IID is correct
1399 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1400 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1401 .child(ConnectivityContext.class).child(Connection.class,
1402 new ConnectionKey(updConn.getUuid())).build();
1403 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1405 this.networkTransactionService.commit().get();
1406 } catch (InterruptedException | ExecutionException e) {
1407 LOG.error("Error committing into datastore", e);
1411 private void updateConnectivityService(ConnectivityService updService) {
1412 // TODO: check if this IID is correct
1413 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1414 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1415 .child(ConnectivityContext.class).child(ConnectivityService.class,
1416 new ConnectivityServiceKey(updService.getUuid())).build();
1417 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1419 this.networkTransactionService.commit().get();
1420 } catch (InterruptedException | ExecutionException e) {
1421 LOG.error("Error committing into datastore", e);