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.StandardCharsets;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Collections;
14 import java.util.Comparator;
15 import java.util.HashMap;
16 import java.util.HashSet;
17 import java.util.List;
19 import java.util.Objects;
20 import java.util.Optional;
22 import java.util.UUID;
23 import java.util.concurrent.ExecutionException;
24 import java.util.stream.Collectors;
25 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
26 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
28 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
29 import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery;
30 import org.opendaylight.transportpce.tapi.TapiStringConstants;
31 import org.opendaylight.transportpce.tapi.utils.TapiLink;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.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.Context;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1Builder;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey;
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.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepList;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.NodeEdgePointRef;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
130 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
131 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
132 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
133 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
134 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
135 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
136 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
137 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
138 import org.opendaylight.yangtools.yang.binding.Notification;
139 import org.opendaylight.yangtools.yang.common.Uint16;
140 import org.opendaylight.yangtools.yang.common.Uint32;
141 import org.osgi.service.component.annotations.Activate;
142 import org.osgi.service.component.annotations.Component;
143 import org.osgi.service.component.annotations.Reference;
144 import org.slf4j.Logger;
145 import org.slf4j.LoggerFactory;
148 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
150 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
152 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
153 .getBytes(StandardCharsets.UTF_8)).toString());
154 private final NetworkTransactionService networkTransactionService;
155 private final R2RTapiLinkDiscovery linkDiscovery;
156 private final TapiLink tapiLink;
157 private final NotificationPublishService notificationPublishService;
158 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap = new HashMap<>();
161 public TapiNetworkModelServiceImpl(@Reference NetworkTransactionService networkTransactionService,
162 @Reference DeviceTransactionManager deviceTransactionManager,
163 @Reference TapiLink tapiLink,
164 @Reference final NotificationPublishService notificationPublishService) {
165 this.networkTransactionService = networkTransactionService;
166 this.linkDiscovery = new R2RTapiLinkDiscovery(networkTransactionService, deviceTransactionManager, tapiLink);
167 this.tapiLink = tapiLink;
168 this.notificationPublishService = notificationPublishService;
172 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
173 // TODO -> Implementation with PortMappingListener
174 // check if port mapping exists or not...
175 if (node.getMapping() == null) {
176 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
180 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
182 // check type of device, check version and create node mapping
183 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
185 // transform flat mapping list to per degree and per srg mapping lists
186 Map<String, List<Mapping>> mapDeg = new HashMap<>();
187 Map<String, List<Mapping>> mapSrg = new HashMap<>();
188 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
189 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
191 List<String> nodeShardList = getRoadmNodelist(mappingList);
193 // populate degree and srg LCP map
194 for (String str : nodeShardList) {
195 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
196 .collect(Collectors.toList());
197 if (str.contains("DEG")) {
198 mapDeg.put(str, interList);
199 } else if (str.contains("SRG")) {
200 mapSrg.put(str, interList);
202 LOG.error("unknown element");
205 // Transform LCPs into ONEP
206 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
207 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
208 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
211 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
212 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
213 mergeSipsinContext(this.sipMap);
214 // TODO add states corresponding to device config -> based on mapping.
215 // This should be possible after Gilles work is merged
217 // rdm to rdm link creation if neighbour roadm is mounted
218 LOG.info("checking if neighbor roadm exists");
219 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
221 if (!rdm2rdmLinks.isEmpty()) {
222 mergeLinkinTopology(rdm2rdmLinks);
224 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
225 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
226 List<Mapping> networkMappings = node.nonnullMapping().values()
227 .stream().filter(k -> k.getLogicalConnectionPoint()
228 .contains("NETWORK")).collect(Collectors.toList());
229 Map<Integer, String> xpdrMap = new HashMap<>();
230 for (Mapping mapping : networkMappings) {
231 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
232 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
233 if (!xpdrMap.containsKey(xpdrNb)) {
234 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
235 .stream().filter(k -> k.getLogicalConnectionPoint()
236 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
237 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
238 .stream().filter(k -> k.getLogicalConnectionPoint()
239 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
240 xpdrMap.put(xpdrNb, node.getNodeId());
242 // create switching pool
243 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
244 mapping.getXpdrType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
246 // node transformation
247 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
248 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXpdrType(), oorOduSwitchingPool));
249 // add nodes and sips to tapi context
250 mergeNodeinTopology(nodeMap);
251 mergeSipsinContext(this.sipMap);
254 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
256 // Device not managed yet
260 public void updateTapiTopology(String nodeId, Mapping mapping) {
261 List<Uuid> uuids = getChangedNodeUuids(nodeId, mapping);
263 List<Uuid> changedOneps = updateNeps(mapping, uuids);
264 updateLinks(changedOneps, mapping);
265 sendNotification(changedOneps, mapping);
267 LOG.info("Updated TAPI topology successfully.");
270 @SuppressWarnings("rawtypes")
271 private void sendNotification(List<Uuid> changedOneps, Mapping mapping) {
272 Notification notification = new NotificationBuilder()
273 .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE)
274 .setTargetObjectType(ObjectType.NODEEDGEPOINT)
275 .setChangedAttributes(getChangedAttributes(changedOneps, mapping))
276 .setUuid(tapiTopoUuid)
279 notificationPublishService.putNotification(notification);
280 } catch (InterruptedException e) {
281 LOG.error("Could not send notification");
285 private Map<ChangedAttributesKey, ChangedAttributes> getChangedAttributes(List<Uuid> changedOneps,
287 Map<ChangedAttributesKey, ChangedAttributes> changedAttributes = new HashMap<>();
288 for (Uuid nep : changedOneps) {
289 changedAttributes.put(new ChangedAttributesKey(nep.getValue()),
290 new ChangedAttributesBuilder().setValueName(nep.getValue())
291 .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService")
292 .setNewValue(mapping.getPortOperState())
295 return changedAttributes;
298 private void updateLinks(List<Uuid> changedOneps, Mapping mapping) {
300 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
301 .augmentation(Context1.class).child(TopologyContext.class)
302 .child(Topology.class, new TopologyKey(tapiTopoUuid))
304 Optional<Topology> optTopology = this.networkTransactionService
305 .read(LogicalDatastoreType.OPERATIONAL, topoIID).get();
306 if (optTopology.isEmpty()) {
307 LOG.error("Could not update TAPI links");
310 for (Link link : optTopology.orElseThrow().nonnullLink().values()) {
311 List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
312 .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
313 if (!Collections.disjoint(changedOneps, linkNeps)) {
314 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
315 .augmentation(Context1.class).child(TopologyContext.class)
316 .child(Topology.class, new TopologyKey(tapiTopoUuid))
317 .child(Link.class, new LinkKey(link.getUuid())).build();
318 Link linkblr = new LinkBuilder().setUuid(link.getUuid())
319 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
320 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
321 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr);
324 this.networkTransactionService.commit().get();
325 } catch (InterruptedException | ExecutionException e) {
326 LOG.error("Could not update TAPI links");
330 private List<Uuid> updateNeps(Mapping mapping, List<Uuid> uuids) {
331 List<Uuid> changedOneps = new ArrayList<>();
332 for (Uuid nodeUuid : uuids) {
334 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
335 .augmentation(Context1.class).child(TopologyContext.class)
336 .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
338 Optional<Node> optionalNode = this.networkTransactionService.read(
339 LogicalDatastoreType.OPERATIONAL, nodeIID).get();
340 if (optionalNode.isPresent()) {
341 Node node = optionalNode.orElseThrow();
342 List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
343 .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
344 .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
345 for (OwnedNodeEdgePoint onep : oneps) {
346 changedOneps.add(onep.getUuid());
347 updateSips(mapping, onep);
348 CepList cepList = getUpdatedCeps(mapping, onep);
349 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
350 .augmentation(Context1.class).child(TopologyContext.class)
351 .child(Topology.class, new TopologyKey(tapiTopoUuid))
352 .child(Node.class, new NodeKey(nodeUuid))
353 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid()))
355 OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid())
356 .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build())
357 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
358 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
359 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr);
361 this.networkTransactionService.commit().get();
363 } catch (InterruptedException | ExecutionException e) {
364 LOG.error("Could not update TAPI NEP");
370 private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) {
371 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
372 Map<ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
373 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) {
374 for (Map.Entry<ConnectionEndPointKey, ConnectionEndPoint> entry : onep1.getCepList().getConnectionEndPoint()
376 ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue())
377 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
378 cepMap.put(entry.getKey(), cep);
381 return new CepListBuilder().setConnectionEndPoint(cepMap).build();
384 private List<Uuid> getChangedNodeUuids(String nodeId, Mapping mapping) {
385 List<Uuid> uuids = new ArrayList<>();
386 if (nodeId.contains("ROADM")) {
387 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA))
388 .getBytes(StandardCharsets.UTF_8)).toString()));
389 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("CLIENT")) {
390 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
391 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
392 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
393 .getBytes(StandardCharsets.UTF_8)).toString()));
394 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("NETWORK")) {
395 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
396 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
397 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
398 .getBytes(StandardCharsets.UTF_8)).toString()));
399 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.OTSI))
400 .getBytes(StandardCharsets.UTF_8)).toString()));
402 LOG.error("Updating this device is currently not supported");
408 private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) {
409 if (onep.getMappedServiceInterfacePoint() == null
410 || onep.getMappedServiceInterfacePoint().size() == 0) {
413 for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) {
414 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier
415 .builder(Context.class)
416 .child(ServiceInterfacePoint.class,
417 new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid()))
419 ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder()
420 .setUuid(msip.getServiceInterfacePointUuid())
421 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
422 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
423 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr);
428 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
429 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
430 OduSwitchingPools oorOduSwitchingPool) {
431 Map<NodeKey, Node> nodeMap = new HashMap<>();
432 LOG.info("creation of a DSR/ODU node for {}", nodeId);
433 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
434 .getBytes(StandardCharsets.UTF_8)).toString());
435 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
436 String.join("+", nodeId, TapiStringConstants.DSR)).build();
437 Name nameNodeType = new NameBuilder().setValueName("Node Type")
438 .setValue(getNodeType(xponderType)).build();
439 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
440 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
441 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
443 nodeMap.put(dsrNode.key(), dsrNode);
445 // node creation [otsi]
446 LOG.info("creation of an OTSi node for {}", nodeId);
447 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
448 .getBytes(StandardCharsets.UTF_8)).toString());
449 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
450 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
451 Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
452 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
453 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
455 nodeMap.put(otsiNode.key(), otsiNode);
457 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
458 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
459 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps);
460 mergeLinkinTopology(linkMap);
465 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
467 // todo: are switching pool correct here??
471 return createTpdrSwitchPool(xpdrNetMaps);
474 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
477 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
479 LOG.warn("Xpdr type {} not supported", xpdrType);
484 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
485 Map<String, List<Mapping>> mapSrg) {
486 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
487 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
488 // For each srg node. Loop through the LCPs and create neps and sips for PP
489 for (Mapping m:entry.getValue()) {
490 if (!m.getLogicalConnectionPoint().contains("PP")) {
491 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
494 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
495 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
496 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
497 onepMap.putAll(srgNeps);
503 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
504 Map<String, List<Mapping>> mapDeg) {
505 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
506 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
507 // For each degree node. Loop through the LCPs and create neps and sips for TTP
508 for (Mapping m:entry.getValue()) {
509 if (!m.getLogicalConnectionPoint().contains("TTP")) {
510 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
513 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
514 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
515 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
516 onepMap.putAll(degNeps);
522 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
523 List<String> nodeShardList = new ArrayList<>();
524 for (Mapping mapping : mappingList) {
525 // TODO -> maybe we need to check the id based on the version
526 String str = mapping.getLogicalConnectionPoint().split("-")[0];
527 LOG.info("LCP = {}", str);
528 if (!nodeShardList.contains(str)) {
529 nodeShardList.add(str);
532 return nodeShardList;
536 public void deleteTapinode(String nodeId) {
537 // TODO: check for null objects
538 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
539 // This will delete NEPs. Then check for links that have this node and delete them.
540 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
541 LOG.info("Deleting node {} from TAPI topology", nodeId);
542 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
543 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
544 new TopologyKey(tapiTopoUuid)).build();
545 Topology topology = null;
547 Optional<Topology> optTopology =
548 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
549 if (!optTopology.isPresent()) {
550 LOG.error("No topology object present. Error deleting node {}", nodeId);
553 topology = optTopology.orElseThrow();
554 } catch (InterruptedException | ExecutionException e) {
555 LOG.error("Couldnt read tapi topology from datastore", e);
557 if (topology == null) {
558 LOG.error("Topology is null, nothing to delete");
561 if (topology.getNode() == null) {
562 LOG.error("No nodes in topology");
565 if (nodeId.contains("ROADM")) {
566 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
567 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
568 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
569 deleteNodeFromTopo(nodeUuid);
571 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
572 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
573 for (Node tapiNode:topology.getNode().values()) {
574 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
575 // Found node we need to delete
576 deleteNodeFromTopo(tapiNode.getUuid());
580 // Delete links of topology
581 Map<LinkKey, Link> linkMap = topology.getLink();
582 if (linkMap != null) {
583 for (Link link:linkMap.values()) {
584 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
585 deleteLinkFromTopo(link.getUuid());
589 // Delete sips of sip map
590 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
591 Context context = null;
593 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
595 if (!optContext.isPresent()) {
596 LOG.error("No context object present in datastore.");
599 context = optContext.orElseThrow();
600 } catch (InterruptedException | ExecutionException e) {
601 LOG.error("Couldnt read tapi context from datastore", e);
603 if (context == null) {
604 LOG.error("Context is null, nothing to delete");
607 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
609 for (ServiceInterfacePoint sip:sips.values()) {
610 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
611 // Update state of services that have this sip as an endpoint and also connections
612 updateConnectivityServicesState(sip.getUuid(), nodeId);
613 deleteSipFromTopo(sip.getUuid());
619 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
620 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
621 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
622 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
623 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
624 Map<RuleKey, Rule> ruleList = new HashMap<>();
625 Rule rule = new RuleBuilder()
626 .setLocalId("forward")
627 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
628 .setRuleType(RuleType.FORWARDING)
630 ruleList.put(rule.key(), rule);
631 if (layerProtocols.contains(LayerProtocolName.DSR)) {
632 // neps for dsr/odu layer
633 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
634 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
635 onepl.putAll(dsroduNeps);
636 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
637 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
638 // neps for photonic layer
639 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
640 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
641 onepl.putAll(phtmdNeps);
642 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
644 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
645 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
647 // Empty random creation of mandatory fields for avoiding errors....
648 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
649 .setCostAlgorithm("Restricted Shortest Path - RSP")
650 .setCostName("HOP_COUNT")
651 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
653 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
654 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
655 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
656 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
657 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
658 .setTrafficPropertyName("FIXED_LATENCY")
660 return new NodeBuilder()
663 .setLayerProtocolName(layerProtocols)
664 .setAdministrativeState(AdministrativeState.UNLOCKED)
665 .setOperationalState(OperationalState.ENABLED)
666 .setLifecycleState(LifecycleState.INSTALLED)
667 .setOwnedNodeEdgePoint(onepl)
668 .setNodeRuleGroup(nodeRuleGroupList)
669 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
670 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
671 .setErrorCharacteristic("error")
672 .setLossCharacteristic("loss")
673 .setRepeatDeliveryCharacteristic("repeat delivery")
674 .setDeliveryOrderCharacteristic("delivery order")
675 .setUnavailableTimeCharacteristic("unavailable time")
676 .setServerIntegrityProcessCharacteristic("server integrity process")
680 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
681 List<Mapping> xpdrNetMaps) {
682 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
684 // iNep creation on otsi node
685 for (int i = 0; i < xpdrNetMaps.size(); i++) {
686 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
687 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
688 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
689 Name onedName = new NameBuilder()
690 .setValueName("iNodeEdgePoint")
691 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
692 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
695 List<SupportedIfCapability> newSupIfCapList =
696 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
698 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
699 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
700 true, String.join("+", nodeId, TapiStringConstants.I_OTSI), newSupIfCapList,
701 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
702 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
703 onepl.put(onep.key(), onep);
705 // eNep creation on otsi node
706 for (int i = 0; i < xpdrNetMaps.size(); i++) {
707 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
708 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
709 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
710 Name onedName = new NameBuilder()
711 .setValueName("eNodeEdgePoint")
712 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
713 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
716 List<SupportedIfCapability> newSupIfCapList =
717 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
719 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
720 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
721 false, String.join("+", nodeId, TapiStringConstants.E_OTSI), newSupIfCapList,
722 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
723 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
724 onepl.put(onep.key(), onep);
726 // Photonic Media Nep creation on otsi node
727 for (int i = 0; i < xpdrNetMaps.size(); i++) {
728 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
729 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
730 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
731 Name onedName = new NameBuilder()
732 .setValueName("PhotMedNodeEdgePoint")
733 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
734 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
737 List<SupportedIfCapability> newSupIfCapList =
738 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
740 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
741 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
742 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA), newSupIfCapList,
743 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
744 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
745 onepl.put(onep.key(), onep);
750 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
751 List<Mapping> xpdrNetMaps,
752 XpdrNodeTypes xponderType) {
753 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
754 // client nep creation on DSR node
755 for (int i = 0; i < xpdrClMaps.size(); i++) {
756 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
757 xpdrClMaps.get(i).getLogicalConnectionPoint()));
758 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
759 (String.join("+", nodeId, TapiStringConstants.DSR,
760 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
761 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
762 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
764 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
765 name = nameBldr.setValueName("100G-tpdr").build();
767 name = nameBldr.setValueName("NodeEdgePoint_C").build();
770 List<SupportedIfCapability> newSupIfCapList =
771 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
773 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
774 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
775 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
776 transformOperState(xpdrClMaps.get(i).getPortOperState()),
777 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
778 onepl.put(onep.key(), onep);
780 // network nep creation on I_ODU node
781 for (int i = 0; i < xpdrNetMaps.size(); i++) {
782 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
783 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
784 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
785 (String.join("+", nodeId, TapiStringConstants.I_ODU,
786 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
787 Name onedName = new NameBuilder()
788 .setValueName("iNodeEdgePoint_N")
789 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
790 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
793 List<SupportedIfCapability> newSupIfCapList =
794 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
796 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
797 Map.of(onedName.key(), onedName),
798 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
799 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
800 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
801 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
802 onepl.put(onep.key(), onep);
804 // network nep creation on E_ODU node
805 for (int i = 0; i < xpdrClMaps.size(); i++) {
806 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
807 xpdrClMaps.get(i).getLogicalConnectionPoint()));
808 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
809 (String.join("+", nodeId, TapiStringConstants.E_ODU,
810 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
811 Name onedName = new NameBuilder()
812 .setValueName("eNodeEdgePoint_N")
813 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
814 xpdrClMaps.get(i).getLogicalConnectionPoint()))
817 List<SupportedIfCapability> newSupIfCapList =
818 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
820 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
821 Map.of(onedName.key(), onedName),
822 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
823 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
824 transformOperState(xpdrClMaps.get(i).getPortOperState()),
825 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
826 onepl.put(onep.key(), onep);
831 private OperationalState transformOperState(String operString) {
832 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
833 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
836 private AdministrativeState transformAdminState(String adminString) {
837 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
838 .setNetworkAdminState(adminString);
839 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
842 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
843 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
845 List<SupportedIfCapability> supportedInterfaceCapability,
846 OperationalState operState, AdministrativeState adminState) {
847 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
849 .setLayerProtocolName(nepProtocol)
852 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
853 supportedInterfaceCapability, operState, adminState));
855 LOG.debug("Node layer {}", nodeProtocol.getName());
856 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
857 supportedInterfaceCapability, nepProtocol));
858 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
859 .setAdministrativeState(adminState).setOperationalState(operState)
860 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
861 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
862 return onepBldr.build();
865 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
866 boolean withSip, OperationalState operState,
867 AdministrativeState adminState) {
868 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
869 // PHOTONIC MEDIA nep
870 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
871 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
872 Name nepName = new NameBuilder()
873 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
874 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
876 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
878 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
879 .setName(Map.of(nepName.key(), nepName))
880 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
881 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
882 .setAdministrativeState(adminState).setOperationalState(operState)
883 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
884 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
886 onepMap.put(onep.key(), onep);
889 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
890 TapiStringConstants.MC, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
891 Name nepName1 = new NameBuilder()
892 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
893 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
895 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
897 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
898 .setName(Map.of(nepName1.key(), nepName1))
899 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
900 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
901 .setAdministrativeState(adminState).setOperationalState(operState)
902 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
903 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
905 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
906 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
907 operState, adminState));
909 OwnedNodeEdgePoint onep1 = onepBldr1.build();
910 onepMap.put(onep1.key(), onep1);
913 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
914 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
915 Name nepName2 = new NameBuilder()
916 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
917 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
920 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
922 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
923 .setName(Map.of(nepName2.key(), nepName2))
924 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
925 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
926 .setAdministrativeState(adminState).setOperationalState(operState)
927 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
928 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
930 onepMap.put(onep2.key(), onep2);
934 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
935 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
936 List<SupportedIfCapability> supportedInterfaceCapability,
937 OperationalState operState, AdministrativeState adminState) {
938 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
939 for (int i = 0; i < nb; i++) {
940 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
941 tpid)).getBytes(StandardCharsets.UTF_8)).toString());
942 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
943 .setServiceInterfacePointUuid(sipUuid).build();
944 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
945 operState, adminState);
946 this.sipMap.put(sip.key(), sip);
947 LOG.info("SIP created {}", sip.getUuid());
948 // this.tapiSips.put(sip.key(), sip);
949 msipl.put(msip.key(), msip);
954 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
955 List<SupportedIfCapability> supportedInterfaceCapability,
956 OperationalState operState, AdministrativeState adminState) {
957 // TODO: what value should be set in total capacity and available capacity
958 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
959 Name sipName = new NameBuilder()
960 .setValueName("SIP name")
961 .setValue(String.join("+", nodeid, tpid))
963 return new ServiceInterfacePointBuilder()
965 .setName(Map.of(sipName.key(), sipName))
966 .setLayerProtocolName(layerProtocol)
967 .setAdministrativeState(adminState)
968 .setOperationalState(operState)
969 .setLifecycleState(LifecycleState.INSTALLED)
970 .setAvailableCapacity(new AvailableCapacityBuilder().build())
971 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
972 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
977 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
979 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
980 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
982 Name nodeNames = new NameBuilder().setValueName("roadm node name")
983 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
984 Name nameNodeType = new NameBuilder().setValueName("Node Type")
985 .setValue(OpenroadmNodeType.ROADM.getName()).build();
987 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
988 // Empty random creation of mandatory fields for avoiding errors....
989 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
990 .setCostAlgorithm("Restricted Shortest Path - RSP")
991 .setCostName("HOP_COUNT")
992 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
994 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
995 .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE)
996 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
997 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
998 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
999 .setTrafficPropertyName("FIXED_LATENCY")
1001 return new NodeBuilder()
1003 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
1004 .setLayerProtocolName(layerProtocols)
1005 .setAdministrativeState(AdministrativeState.UNLOCKED)
1006 .setOperationalState(OperationalState.ENABLED)
1007 .setLifecycleState(LifecycleState.INSTALLED)
1008 .setOwnedNodeEdgePoint(oneplist)
1009 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
1010 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1011 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1012 .setErrorCharacteristic("error")
1013 .setLossCharacteristic("loss")
1014 .setRepeatDeliveryCharacteristic("repeat delivery")
1015 .setDeliveryOrderCharacteristic("delivery order")
1016 .setUnavailableTimeCharacteristic("unavailable time")
1017 .setServerIntegrityProcessCharacteristic("server integrity process")
1021 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
1022 Collection<OwnedNodeEdgePoint> onepl) {
1023 Map<NodeEdgePointKey, NodeEdgePoint>
1024 nepMap = new HashMap<>();
1025 for (OwnedNodeEdgePoint onep : onepl) {
1026 NodeEdgePoint nep = new NodeEdgePointBuilder()
1027 .setTopologyUuid(this.tapiTopoUuid)
1028 .setNodeUuid(nodeUuid)
1029 .setNodeEdgePointUuid(onep.key().getUuid())
1031 nepMap.put(nep.key(), nep);
1033 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1034 Map<RuleKey, Rule> ruleList = new HashMap<>();
1035 Rule rule = new RuleBuilder()
1036 .setLocalId("forward")
1037 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
1038 .setRuleType(RuleType.FORWARDING)
1040 ruleList.put(rule.key(), rule);
1041 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1042 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
1043 .getBytes(StandardCharsets.UTF_8)).toString()))
1045 .setNodeEdgePoint(nepMap)
1047 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1048 return nodeRuleGroupMap;
1051 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps) {
1052 Map<LinkKey, Link> linkMap = new HashMap<>();
1053 for (Mapping mapping : xpdrNetMaps) {
1054 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
1055 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
1056 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
1057 "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
1058 Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
1060 linkMap.put(transiLink.key(), transiLink);
1062 // return a map of links and then we can do merge the corresponding link map into the topology context
1066 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
1067 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
1069 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1070 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1071 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1072 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1073 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1074 Set<TpId> tpList = new HashSet<>();
1077 NonBlockingList nbl = new NonBlockingListBuilder()
1078 .setNblNumber(Uint16.valueOf(count))
1081 nblMap.put(nbl.key(), nbl);
1084 return new OduSwitchingPoolsBuilder()
1085 .setNonBlockingList(nblMap)
1086 .setSwitchingPoolNumber(Uint16.valueOf(1))
1090 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
1092 Set<TpId> tpl = new HashSet<>();
1094 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1095 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1098 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1099 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
1102 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1103 NonBlockingList nbl = new NonBlockingListBuilder()
1104 .setNblNumber(Uint16.valueOf(1))
1107 nbMap.put(nbl.key(),nbl);
1109 return new OduSwitchingPoolsBuilder()
1110 .setSwitchingPoolNumber(Uint16.valueOf(1))
1111 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1112 .setNonBlockingList(nbMap)
1116 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
1117 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1118 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1119 Set<TpId> tpList = new HashSet<>();
1120 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1122 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
1124 NonBlockingList nbl = new NonBlockingListBuilder()
1125 .setNblNumber(Uint16.valueOf(i))
1127 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
1128 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
1130 nbMap.put(nbl.key(),nbl);
1132 return new OduSwitchingPoolsBuilder()
1133 .setSwitchingPoolNumber(Uint16.valueOf(1))
1134 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1135 .setNonBlockingList(nbMap)
1139 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
1140 List<Mapping> xpdrNetMaps,
1141 Map<RuleKey, Rule> ruleList) {
1142 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1143 // create NodeRuleGroup
1145 for (Mapping tpMapping : xpdrNetMaps) {
1146 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1147 NodeEdgePoint inep = new NodeEdgePointBuilder()
1148 .setTopologyUuid(this.tapiTopoUuid)
1149 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1150 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1151 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1152 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
1153 .getBytes(StandardCharsets.UTF_8)).toString()))
1155 NodeEdgePoint enep = new NodeEdgePointBuilder()
1156 .setTopologyUuid(this.tapiTopoUuid)
1157 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1158 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1159 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1160 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
1161 tpMapping.getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()))
1163 nepList.put(inep.key(), inep);
1164 nepList.put(enep.key(), enep);
1165 // Empty random creation of mandatory fields for avoiding errors....
1166 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1167 .setCostAlgorithm("Restricted Shortest Path - RSP")
1168 .setCostName("HOP_COUNT")
1169 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1171 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1172 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1173 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1174 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1175 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1176 .setTrafficPropertyName("FIXED_LATENCY")
1178 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1179 .setRiskCharacteristicName("risk characteristic")
1180 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1182 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1184 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(StandardCharsets.UTF_8))
1187 .setNodeEdgePoint(nepList)
1188 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1189 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1190 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1192 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1195 return nodeRuleGroupMap;
1198 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1199 OduSwitchingPools oorOduSwitchingPool,
1200 Map<RuleKey, Rule> ruleList,
1201 Map<OwnedNodeEdgePointKey,
1202 OwnedNodeEdgePoint> onepl) {
1203 // create NodeRuleGroup
1204 if (oorOduSwitchingPool == null) {
1205 LOG.info("No switching pool created for node = {}", nodeId);
1206 return new HashMap<>();
1208 LOG.info("ONEPL = {}", onepl.values());
1209 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1211 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1212 LOG.info("Non blocking list = {}", nbl);
1213 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1214 for (TpId tp : nbl.getTpList()) {
1215 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1216 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1217 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1218 TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1219 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1220 TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1221 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1222 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1223 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1224 .setTopologyUuid(this.tapiTopoUuid)
1225 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1226 (String.join("+", nodeId,TapiStringConstants. DSR))
1227 .getBytes(StandardCharsets.UTF_8)).toString()))
1228 .setNodeEdgePointUuid(tp1Uuid)
1230 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1231 .setTopologyUuid(this.tapiTopoUuid)
1232 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1233 (String.join("+", nodeId,TapiStringConstants. DSR))
1234 .getBytes(StandardCharsets.UTF_8)).toString()))
1235 .setNodeEdgePointUuid(tpUuid)
1237 nepList.put(nep1.key(), nep1);
1238 nepList.put(nep2.key(), nep2);
1241 // Empty random creation of mandatory fields for avoiding errors....
1242 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1243 .setCostAlgorithm("Restricted Shortest Path - RSP")
1244 .setCostName("HOP_COUNT")
1245 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1247 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1248 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1249 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1250 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1251 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1252 .setTrafficPropertyName("FIXED_LATENCY")
1254 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1255 .setRiskCharacteristicName("risk characteristic")
1256 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1258 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1260 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8))
1263 .setNodeEdgePoint(nepList)
1264 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1265 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1266 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1268 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1271 return nodeRuleGroupMap;
1274 private Set<LAYERPROTOCOLQUALIFIER> createSupportedLayerProtocolQualifier(
1275 List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1276 if (sicList == null) {
1277 return Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE);
1279 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1280 LOG.info("SIC list = {}", sicList);
1281 for (SupportedIfCapability supInterCapa : sicList) {
1282 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1283 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1284 .setIfCapType(supInterCapa)
1286 supIfMap.put(supIfCapa.key(), supIfCapa);
1288 Set<LAYERPROTOCOLQUALIFIER> sclpqList = new HashSet<>();
1289 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1290 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1291 switch (lpn.getName()) {
1293 switch (ifCapType) {
1294 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1295 // port are extended in the config file
1297 sclpqList.add(ODUTYPEODU0.VALUE);
1298 sclpqList.add(DIGITALSIGNALTYPEGigE.VALUE);
1301 sclpqList.add(ODUTYPEODU2E.VALUE);
1302 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1305 sclpqList.add(ODUTYPEODU2.VALUE);
1306 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1309 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1312 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1313 sclpqList.add(ODUTYPEODU4.VALUE);
1316 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1318 case "IfOCHOTU4ODU4":
1320 sclpqList.add(ODUTYPEODU4.VALUE);
1323 LOG.error("IfCapability type not managed");
1328 switch (ifCapType) {
1329 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1330 // port are extended in the config file
1332 sclpqList.add(ODUTYPEODU0.VALUE);
1335 sclpqList.add(ODUTYPEODU2E.VALUE);
1339 sclpqList.add(ODUTYPEODU2.VALUE);
1343 case "IfOCHOTU4ODU4":
1345 sclpqList.add(ODUTYPEODU4.VALUE);
1348 LOG.error("IfCapability type not managed");
1352 case "PHOTONIC_MEDIA":
1353 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1354 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.VALUE);
1355 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.VALUE);
1359 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1366 private String getNodeType(XpdrNodeTypes xponderType) {
1367 switch (xponderType.getIntValue()) {
1369 return OpenroadmNodeType.TPDR.getName();
1371 return OpenroadmNodeType.MUXPDR.getName();
1373 return OpenroadmNodeType.SWITCH.getName();
1375 LOG.info("XpdrType {} not supported", xponderType);
1381 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1382 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1383 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1384 LOG.info("Creating tapi node in TAPI topology context");
1385 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1386 .augmentation(Context1.class).child(TopologyContext.class)
1387 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1390 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1392 // merge in datastore
1393 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1396 this.networkTransactionService.commit().get();
1397 } catch (InterruptedException | ExecutionException e) {
1398 LOG.error("Error populating TAPI topology: ", e);
1400 LOG.info("Node added succesfully.");
1403 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1404 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1405 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1406 LOG.info("Creating tapi node in TAPI topology context");
1407 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1408 .augmentation(Context1.class).child(TopologyContext.class)
1409 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1412 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1414 // merge in datastore
1415 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1418 this.networkTransactionService.commit().get();
1419 } catch (InterruptedException | ExecutionException e) {
1420 LOG.error("Error populating TAPI topology: ", e);
1422 LOG.info("Roadm Link added succesfully.");
1425 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1426 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1427 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1429 ContextBuilder contextBuilder = new ContextBuilder();
1430 contextBuilder.setServiceInterfacePoint(sips);
1431 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1432 // merge in datastore
1433 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1434 contextBuilder.build());
1435 this.networkTransactionService.commit().get();
1436 LOG.info("TAPI SIPs merged successfully.");
1437 } catch (InterruptedException | ExecutionException e) {
1438 LOG.error("Failed to merge TAPI Sips", e);
1442 private void deleteLinkFromTopo(Uuid linkUuid) {
1443 // TODO: check if this IID is correct
1445 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1446 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1447 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1448 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1449 this.networkTransactionService.commit().get();
1450 LOG.info("TAPI link deleted successfully.");
1451 } catch (InterruptedException | ExecutionException e) {
1452 LOG.error("Failed to delete TAPI link", e);
1456 private void deleteNodeFromTopo(Uuid nodeUuid) {
1457 // TODO: check if this IID is correct
1459 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1460 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1461 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1462 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1463 this.networkTransactionService.commit().get();
1464 LOG.info("TAPI Node deleted successfully.");
1465 } catch (InterruptedException | ExecutionException e) {
1466 LOG.error("Failed to delete TAPI Node", e);
1470 private void deleteSipFromTopo(Uuid sipUuid) {
1471 // TODO: check if this IID is correct
1473 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1474 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1475 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1476 this.networkTransactionService.commit().get();
1477 LOG.info("TAPI SIP deleted successfully.");
1478 } catch (InterruptedException | ExecutionException e) {
1479 LOG.error("Failed to delete TAPI SIP", e);
1483 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1484 // TODO: check if this IID is correct
1485 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1486 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1487 .child(ConnectivityContext.class)
1489 ConnectivityContext connContext = null;
1491 Optional<ConnectivityContext> optConnContext =
1492 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1494 if (!optConnContext.isPresent()) {
1495 LOG.error("Couldnt retrieve connectivity context from datastore");
1498 connContext = optConnContext.orElseThrow();
1499 } catch (InterruptedException | ExecutionException e) {
1500 LOG.error("Couldnt read connectivity context from datastore", e);
1502 if (connContext == null) {
1503 LOG.error("Connectivity context is empty");
1506 // Loop through services, check if the endpoint uuid is equal to the sip.
1507 // If so update state.
1508 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1509 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1510 if (connServMap != null) {
1511 for (ConnectivityService service:connServMap.values()) {
1512 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1513 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1514 .getServiceInterfacePointUuid().equals(sipUuid))) {
1515 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1516 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1517 .setAdministrativeState(AdministrativeState.LOCKED)
1518 .setOperationalState(OperationalState.DISABLED)
1519 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1521 updateConnectivityService(updService);
1525 // Update state of connections
1526 if (connMap != null) {
1527 for (Connection connection:connMap.values()) {
1528 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1529 Connection updConn = new ConnectionBuilder(connection)
1530 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1531 .setOperationalState(OperationalState.DISABLED)
1533 updateConnection(updConn);
1539 private void updateConnection(Connection updConn) {
1540 // TODO: check if this IID is correct
1541 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1542 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1543 .child(ConnectivityContext.class).child(Connection.class,
1544 new ConnectionKey(updConn.getUuid())).build();
1545 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1547 this.networkTransactionService.commit().get();
1548 } catch (InterruptedException | ExecutionException e) {
1549 LOG.error("Error committing into datastore", e);
1553 private void updateConnectivityService(ConnectivityService updService) {
1554 // TODO: check if this IID is correct
1555 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1556 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1557 .child(ConnectivityContext.class).child(ConnectivityService.class,
1558 new ConnectivityServiceKey(updService.getUuid())).build();
1559 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1561 this.networkTransactionService.commit().get();
1562 } catch (InterruptedException | ExecutionException e) {
1563 LOG.error("Error committing into datastore", e);