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.network.NetworkTransactionService;
28 import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery;
29 import org.opendaylight.transportpce.tapi.TapiStringConstants;
30 import org.opendaylight.transportpce.tapi.utils.TapiLink;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
48 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
49 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1Builder;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepList;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationBuilder;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.NodeEdgePointRef;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
130 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
131 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
132 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
133 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
134 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
135 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
136 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
137 import org.opendaylight.yangtools.yang.binding.Notification;
138 import org.opendaylight.yangtools.yang.common.Uint16;
139 import org.opendaylight.yangtools.yang.common.Uint32;
140 import org.slf4j.Logger;
141 import org.slf4j.LoggerFactory;
143 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
145 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
146 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
147 .getBytes(StandardCharsets.UTF_8)).toString());
148 private final NetworkTransactionService networkTransactionService;
149 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
150 private final R2RTapiLinkDiscovery linkDiscovery;
151 private final TapiLink tapiLink;
152 private final NotificationPublishService notificationPublishService;
154 public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery,
155 NetworkTransactionService networkTransactionService, TapiLink tapiLink,
156 final NotificationPublishService notificationPublishService) {
157 this.networkTransactionService = networkTransactionService;
158 this.sipMap = new HashMap<>();
159 this.linkDiscovery = linkDiscovery;
160 this.tapiLink = tapiLink;
161 this.notificationPublishService = notificationPublishService;
165 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
166 // TODO -> Implementation with PortMappingListener
167 // check if port mapping exists or not...
168 if (node.getMapping() == null) {
169 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
173 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
175 // check type of device, check version and create node mapping
176 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
178 // transform flat mapping list to per degree and per srg mapping lists
179 Map<String, List<Mapping>> mapDeg = new HashMap<>();
180 Map<String, List<Mapping>> mapSrg = new HashMap<>();
181 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
182 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
184 List<String> nodeShardList = getRoadmNodelist(mappingList);
186 // populate degree and srg LCP map
187 for (String str : nodeShardList) {
188 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
189 .collect(Collectors.toList());
190 if (str.contains("DEG")) {
191 mapDeg.put(str, interList);
192 } else if (str.contains("SRG")) {
193 mapSrg.put(str, interList);
195 LOG.error("unknown element");
198 // Transform LCPs into ONEP
199 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
200 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
201 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
204 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
205 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
206 mergeSipsinContext(this.sipMap);
207 // TODO add states corresponding to device config -> based on mapping.
208 // This should be possible after Gilles work is merged
210 // rdm to rdm link creation if neighbour roadm is mounted
211 LOG.info("checking if neighbor roadm exists");
212 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
214 if (!rdm2rdmLinks.isEmpty()) {
215 mergeLinkinTopology(rdm2rdmLinks);
217 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
218 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
219 List<Mapping> networkMappings = node.nonnullMapping().values()
220 .stream().filter(k -> k.getLogicalConnectionPoint()
221 .contains("NETWORK")).collect(Collectors.toList());
222 Map<Integer, String> xpdrMap = new HashMap<>();
223 for (Mapping mapping : networkMappings) {
224 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
225 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
226 if (!xpdrMap.containsKey(xpdrNb)) {
227 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
228 .stream().filter(k -> k.getLogicalConnectionPoint()
229 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
230 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
231 .stream().filter(k -> k.getLogicalConnectionPoint()
232 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
233 xpdrMap.put(xpdrNb, node.getNodeId());
235 // create switching pool
236 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
237 mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
239 // node transformation
240 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
241 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool));
242 // add nodes and sips to tapi context
243 mergeNodeinTopology(nodeMap);
244 mergeSipsinContext(this.sipMap);
247 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
249 // Device not managed yet
253 public void updateTapiTopology(String nodeId, Mapping mapping) {
254 List<Uuid> uuids = getChangedNodeUuids(nodeId, mapping);
256 List<Uuid> changedOneps = updateNeps(mapping, uuids);
257 updateLinks(changedOneps, mapping);
258 sendNotification(changedOneps, mapping);
260 LOG.info("Updated TAPI topology successfully.");
263 private void sendNotification(List<Uuid> changedOneps, Mapping mapping) {
264 Notification notification = new NotificationBuilder()
265 .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE)
266 .setTargetObjectType(ObjectType.NODEEDGEPOINT)
267 .setChangedAttributes(getChangedAttributes(changedOneps, mapping))
268 .setUuid(tapiTopoUuid)
271 notificationPublishService.putNotification(notification);
272 } catch (InterruptedException e) {
273 LOG.error("Could not send notification");
277 private Map<ChangedAttributesKey, ChangedAttributes> getChangedAttributes(List<Uuid> changedOneps,
279 Map<ChangedAttributesKey, ChangedAttributes> changedAttributes = new HashMap<>();
280 for (Uuid nep : changedOneps) {
281 changedAttributes.put(new ChangedAttributesKey(nep.getValue()),
282 new ChangedAttributesBuilder().setValueName(nep.getValue())
283 .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService")
284 .setNewValue(mapping.getPortOperState())
287 return changedAttributes;
290 private void updateLinks(List<Uuid> changedOneps, Mapping mapping) {
292 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
293 .augmentation(Context1.class).child(TopologyContext.class)
294 .child(Topology.class, new TopologyKey(tapiTopoUuid))
296 Optional<Topology> optTopology = this.networkTransactionService
297 .read(LogicalDatastoreType.OPERATIONAL, topoIID).get();
298 if (optTopology.isEmpty()) {
299 LOG.error("Could not update TAPI links");
302 Map<LinkKey, Link> links = optTopology.get().getLink();
304 for (Link link : links.values()) {
305 List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
306 .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
307 if (!Collections.disjoint(changedOneps, linkNeps)) {
308 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
309 .augmentation(Context1.class).child(TopologyContext.class)
310 .child(Topology.class, new TopologyKey(tapiTopoUuid))
311 .child(Link.class, new LinkKey(link.getUuid())).build();
312 Link linkblr = new LinkBuilder().setUuid(link.getUuid())
313 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
314 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
315 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr);
319 this.networkTransactionService.commit().get();
320 } catch (InterruptedException | ExecutionException e) {
321 LOG.error("Could not update TAPI links");
325 private List<Uuid> updateNeps(Mapping mapping, List<Uuid> uuids) {
326 List<Uuid> changedOneps = new ArrayList<>();
327 for (Uuid nodeUuid : uuids) {
329 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
330 .augmentation(Context1.class).child(TopologyContext.class)
331 .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
333 Optional<Node> optionalNode = this.networkTransactionService.read(
334 LogicalDatastoreType.OPERATIONAL, nodeIID).get();
335 if (optionalNode.isPresent()) {
336 Node node = optionalNode.get();
337 List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
338 .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
339 .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
340 for (OwnedNodeEdgePoint onep : oneps) {
341 changedOneps.add(onep.getUuid());
342 updateSips(mapping, onep);
343 CepList cepList = getUpdatedCeps(mapping, onep);
344 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
345 .augmentation(Context1.class).child(TopologyContext.class)
346 .child(Topology.class, new TopologyKey(tapiTopoUuid))
347 .child(Node.class, new NodeKey(nodeUuid))
348 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid()))
350 OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid())
351 .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build())
352 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
353 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
354 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr);
356 this.networkTransactionService.commit().get();
358 } catch (InterruptedException | ExecutionException e) {
359 LOG.error("Could not update TAPI NEP");
365 private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) {
366 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
367 Map<ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
368 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) {
369 for (Map.Entry<ConnectionEndPointKey, ConnectionEndPoint> entry : onep1.getCepList().getConnectionEndPoint()
371 ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue())
372 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
373 cepMap.put(entry.getKey(), cep);
376 return new CepListBuilder().setConnectionEndPoint(cepMap).build();
379 private List<Uuid> getChangedNodeUuids(String nodeId, Mapping mapping) {
380 List<Uuid> uuids = new ArrayList<>();
381 if (nodeId.contains("ROADM")) {
382 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA))
383 .getBytes(StandardCharsets.UTF_8)).toString()));
384 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("CLIENT")) {
385 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
386 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
387 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
388 .getBytes(StandardCharsets.UTF_8)).toString()));
389 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("NETWORK")) {
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 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.OTSI))
395 .getBytes(StandardCharsets.UTF_8)).toString()));
397 LOG.error("Updating this device is currently not supported");
403 private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) {
404 if (onep.getMappedServiceInterfacePoint() == null
405 || onep.getMappedServiceInterfacePoint().size() == 0) {
408 for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) {
409 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier
410 .builder(Context.class)
411 .child(ServiceInterfacePoint.class,
412 new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid()))
414 ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder()
415 .setUuid(msip.getServiceInterfacePointUuid())
416 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
417 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
418 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr);
423 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
424 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
425 OduSwitchingPools oorOduSwitchingPool) {
426 Map<NodeKey, Node> nodeMap = new HashMap<>();
427 LOG.info("creation of a DSR/ODU node for {}", nodeId);
428 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
429 .getBytes(StandardCharsets.UTF_8)).toString());
430 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
431 String.join("+", nodeId, TapiStringConstants.DSR)).build();
432 Name nameNodeType = new NameBuilder().setValueName("Node Type")
433 .setValue(getNodeType(xponderType)).build();
434 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
435 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
436 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
438 nodeMap.put(dsrNode.key(), dsrNode);
440 // node creation [otsi]
441 LOG.info("creation of an OTSi node for {}", nodeId);
442 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
443 .getBytes(StandardCharsets.UTF_8)).toString());
444 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
445 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
446 Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
447 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
448 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
450 nodeMap.put(otsiNode.key(), otsiNode);
452 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
453 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
454 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps);
455 mergeLinkinTopology(linkMap);
460 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
462 // todo: are switching pool correct here??
466 return createTpdrSwitchPool(xpdrNetMaps);
469 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
472 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
474 LOG.warn("Xpdr type {} not supported", xpdrType);
479 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
480 Map<String, List<Mapping>> mapSrg) {
481 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
482 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
483 // For each srg node. Loop through the LCPs and create neps and sips for PP
484 for (Mapping m:entry.getValue()) {
485 if (!m.getLogicalConnectionPoint().contains("PP")) {
486 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
489 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
490 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
491 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
492 onepMap.putAll(srgNeps);
498 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
499 Map<String, List<Mapping>> mapDeg) {
500 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
501 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
502 // For each degree node. Loop through the LCPs and create neps and sips for TTP
503 for (Mapping m:entry.getValue()) {
504 if (!m.getLogicalConnectionPoint().contains("TTP")) {
505 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
508 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
509 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
510 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
511 onepMap.putAll(degNeps);
517 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
518 List<String> nodeShardList = new ArrayList<>();
519 for (Mapping mapping : mappingList) {
520 // TODO -> maybe we need to check the id based on the version
521 String str = mapping.getLogicalConnectionPoint().split("-")[0];
522 LOG.info("LCP = {}", str);
523 if (!nodeShardList.contains(str)) {
524 nodeShardList.add(str);
527 return nodeShardList;
531 public void deleteTapinode(String nodeId) {
532 // TODO: check for null objects
533 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
534 // This will delete NEPs. Then check for links that have this node and delete them.
535 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
536 LOG.info("Deleting node {} from TAPI topology", nodeId);
537 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
538 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
539 new TopologyKey(tapiTopoUuid)).build();
540 Topology topology = null;
542 Optional<Topology> optTopology =
543 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
544 if (!optTopology.isPresent()) {
545 LOG.error("No topology object present. Error deleting node {}", nodeId);
548 topology = optTopology.get();
549 } catch (InterruptedException | ExecutionException e) {
550 LOG.error("Couldnt read tapi topology from datastore", e);
552 if (topology == null) {
553 LOG.error("Topology is null, nothing to delete");
556 if (topology.getNode() == null) {
557 LOG.error("No nodes in topology");
560 if (nodeId.contains("ROADM")) {
561 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
562 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
563 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
564 deleteNodeFromTopo(nodeUuid);
566 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
567 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
568 for (Node tapiNode:topology.getNode().values()) {
569 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
570 // Found node we need to delete
571 deleteNodeFromTopo(tapiNode.getUuid());
575 // Delete links of topology
576 Map<LinkKey, Link> linkMap = topology.getLink();
577 if (linkMap != null) {
578 for (Link link:linkMap.values()) {
579 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
580 deleteLinkFromTopo(link.getUuid());
584 // Delete sips of sip map
585 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
586 Context context = null;
588 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
590 if (!optContext.isPresent()) {
591 LOG.error("No context object present in datastore.");
594 context = optContext.get();
595 } catch (InterruptedException | ExecutionException e) {
596 LOG.error("Couldnt read tapi context from datastore", e);
598 if (context == null) {
599 LOG.error("Context is null, nothing to delete");
602 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
604 for (ServiceInterfacePoint sip:sips.values()) {
605 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
606 // Update state of services that have this sip as an endpoint and also connections
607 updateConnectivityServicesState(sip.getUuid(), nodeId);
608 deleteSipFromTopo(sip.getUuid());
614 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
615 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
616 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
617 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
618 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
619 Map<RuleKey, Rule> ruleList = new HashMap<>();
620 Rule rule = new RuleBuilder()
621 .setLocalId("forward")
622 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
623 .setRuleType(RuleType.FORWARDING)
625 ruleList.put(rule.key(), rule);
626 if (layerProtocols.contains(LayerProtocolName.DSR)) {
627 // neps for dsr/odu layer
628 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
629 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
630 onepl.putAll(dsroduNeps);
631 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
632 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
633 // neps for photonic layer
634 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
635 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
636 onepl.putAll(phtmdNeps);
637 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
639 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
640 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
642 // Empty random creation of mandatory fields for avoiding errors....
643 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
644 .setCostAlgorithm("Restricted Shortest Path - RSP")
645 .setCostName("HOP_COUNT")
646 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
648 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
649 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
650 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
651 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
652 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
653 .setTrafficPropertyName("FIXED_LATENCY")
655 return new NodeBuilder()
658 .setLayerProtocolName(layerProtocols)
659 .setAdministrativeState(AdministrativeState.UNLOCKED)
660 .setOperationalState(OperationalState.ENABLED)
661 .setLifecycleState(LifecycleState.INSTALLED)
662 .setOwnedNodeEdgePoint(onepl)
663 .setNodeRuleGroup(nodeRuleGroupList)
664 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
665 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
666 .setErrorCharacteristic("error")
667 .setLossCharacteristic("loss")
668 .setRepeatDeliveryCharacteristic("repeat delivery")
669 .setDeliveryOrderCharacteristic("delivery order")
670 .setUnavailableTimeCharacteristic("unavailable time")
671 .setServerIntegrityProcessCharacteristic("server integrity process")
675 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
676 List<Mapping> xpdrNetMaps) {
677 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
679 // iNep creation on otsi node
680 for (int i = 0; i < xpdrNetMaps.size(); i++) {
681 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
682 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
683 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
684 Name onedName = new NameBuilder()
685 .setValueName("iNodeEdgePoint")
686 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
687 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
690 List<SupportedIfCapability> newSupIfCapList =
691 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
693 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
694 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
695 true, String.join("+", nodeId, TapiStringConstants.I_OTSI), newSupIfCapList,
696 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
697 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
698 onepl.put(onep.key(), onep);
700 // eNep creation on otsi node
701 for (int i = 0; i < xpdrNetMaps.size(); i++) {
702 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
703 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
704 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
705 Name onedName = new NameBuilder()
706 .setValueName("eNodeEdgePoint")
707 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
708 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
711 List<SupportedIfCapability> newSupIfCapList =
712 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
714 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
715 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
716 false, String.join("+", nodeId, TapiStringConstants.E_OTSI), newSupIfCapList,
717 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
718 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
719 onepl.put(onep.key(), onep);
721 // Photonic Media Nep creation on otsi node
722 for (int i = 0; i < xpdrNetMaps.size(); i++) {
723 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
724 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
725 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
726 Name onedName = new NameBuilder()
727 .setValueName("PhotMedNodeEdgePoint")
728 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
729 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
732 List<SupportedIfCapability> newSupIfCapList =
733 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
735 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
736 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
737 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA), newSupIfCapList,
738 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
739 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
740 onepl.put(onep.key(), onep);
745 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
746 List<Mapping> xpdrNetMaps,
747 XpdrNodeTypes xponderType) {
748 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
749 // client nep creation on DSR node
750 for (int i = 0; i < xpdrClMaps.size(); i++) {
751 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
752 xpdrClMaps.get(i).getLogicalConnectionPoint()));
753 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
754 (String.join("+", nodeId, TapiStringConstants.DSR,
755 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
756 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
757 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
759 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
760 name = nameBldr.setValueName("100G-tpdr").build();
762 name = nameBldr.setValueName("NodeEdgePoint_C").build();
765 List<SupportedIfCapability> newSupIfCapList =
766 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
768 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
769 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
770 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
771 transformOperState(xpdrClMaps.get(i).getPortOperState()),
772 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
773 onepl.put(onep.key(), onep);
775 // network nep creation on I_ODU node
776 for (int i = 0; i < xpdrNetMaps.size(); i++) {
777 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
778 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
779 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
780 (String.join("+", nodeId, TapiStringConstants.I_ODU,
781 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
782 Name onedName = new NameBuilder()
783 .setValueName("iNodeEdgePoint_N")
784 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
785 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
788 List<SupportedIfCapability> newSupIfCapList =
789 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
791 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
792 Map.of(onedName.key(), onedName),
793 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
794 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
795 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
796 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
797 onepl.put(onep.key(), onep);
799 // network nep creation on E_ODU node
800 for (int i = 0; i < xpdrClMaps.size(); i++) {
801 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
802 xpdrClMaps.get(i).getLogicalConnectionPoint()));
803 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
804 (String.join("+", nodeId, TapiStringConstants.E_ODU,
805 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
806 Name onedName = new NameBuilder()
807 .setValueName("eNodeEdgePoint_N")
808 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
809 xpdrClMaps.get(i).getLogicalConnectionPoint()))
812 List<SupportedIfCapability> newSupIfCapList =
813 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
815 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
816 Map.of(onedName.key(), onedName),
817 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
818 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
819 transformOperState(xpdrClMaps.get(i).getPortOperState()),
820 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
821 onepl.put(onep.key(), onep);
826 private OperationalState transformOperState(String operString) {
827 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
828 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
831 private AdministrativeState transformAdminState(String adminString) {
832 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
833 .setNetworkAdminState(adminString);
834 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
837 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
838 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
840 List<SupportedIfCapability> supportedInterfaceCapability,
841 OperationalState operState, AdministrativeState adminState) {
842 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
844 .setLayerProtocolName(nepProtocol)
847 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
848 supportedInterfaceCapability, operState, adminState));
850 LOG.debug("Node layer {}", nodeProtocol.getName());
851 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
852 supportedInterfaceCapability, nepProtocol));
853 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
854 .setAdministrativeState(adminState).setOperationalState(operState)
855 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
856 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
857 return onepBldr.build();
860 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
861 boolean withSip, OperationalState operState,
862 AdministrativeState adminState) {
863 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
864 // PHOTONIC MEDIA nep
865 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
866 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
867 Name nepName = new NameBuilder()
868 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
869 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
871 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
873 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
874 .setName(Map.of(nepName.key(), nepName))
875 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
876 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
877 .setAdministrativeState(adminState).setOperationalState(operState)
878 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
879 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
881 onepMap.put(onep.key(), onep);
884 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
885 TapiStringConstants.MC, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
886 Name nepName1 = new NameBuilder()
887 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
888 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
890 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
892 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
893 .setName(Map.of(nepName1.key(), nepName1))
894 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
895 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
896 .setAdministrativeState(adminState).setOperationalState(operState)
897 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
898 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
900 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
901 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
902 operState, adminState));
904 OwnedNodeEdgePoint onep1 = onepBldr1.build();
905 onepMap.put(onep1.key(), onep1);
908 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
909 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
910 Name nepName2 = new NameBuilder()
911 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
912 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
915 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
917 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
918 .setName(Map.of(nepName2.key(), nepName2))
919 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
920 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
921 .setAdministrativeState(adminState).setOperationalState(operState)
922 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
923 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
925 onepMap.put(onep2.key(), onep2);
929 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
930 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
931 List<SupportedIfCapability> supportedInterfaceCapability,
932 OperationalState operState, AdministrativeState adminState) {
933 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
934 for (int i = 0; i < nb; i++) {
935 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
936 tpid)).getBytes(StandardCharsets.UTF_8)).toString());
937 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
938 .setServiceInterfacePointUuid(sipUuid).build();
939 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
940 operState, adminState);
941 this.sipMap.put(sip.key(), sip);
942 LOG.info("SIP created {}", sip.getUuid());
943 // this.tapiSips.put(sip.key(), sip);
944 msipl.put(msip.key(), msip);
949 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
950 List<SupportedIfCapability> supportedInterfaceCapability,
951 OperationalState operState, AdministrativeState adminState) {
952 // TODO: what value should be set in total capacity and available capacity
953 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
954 Name sipName = new NameBuilder()
955 .setValueName("SIP name")
956 .setValue(String.join("+", nodeid, tpid))
958 return new ServiceInterfacePointBuilder()
960 .setName(Map.of(sipName.key(), sipName))
961 .setLayerProtocolName(layerProtocol)
962 .setAdministrativeState(adminState)
963 .setOperationalState(operState)
964 .setLifecycleState(LifecycleState.INSTALLED)
965 .setAvailableCapacity(new AvailableCapacityBuilder().build())
966 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
967 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
972 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
974 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
975 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
977 Name nodeNames = new NameBuilder().setValueName("roadm node name")
978 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
979 Name nameNodeType = new NameBuilder().setValueName("Node Type")
980 .setValue(OpenroadmNodeType.ROADM.getName()).build();
982 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
983 // Empty random creation of mandatory fields for avoiding errors....
984 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
985 .setCostAlgorithm("Restricted Shortest Path - RSP")
986 .setCostName("HOP_COUNT")
987 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
989 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
990 .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE)
991 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
992 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
993 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
994 .setTrafficPropertyName("FIXED_LATENCY")
996 return new NodeBuilder()
998 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
999 .setLayerProtocolName(layerProtocols)
1000 .setAdministrativeState(AdministrativeState.UNLOCKED)
1001 .setOperationalState(OperationalState.ENABLED)
1002 .setLifecycleState(LifecycleState.INSTALLED)
1003 .setOwnedNodeEdgePoint(oneplist)
1004 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
1005 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1006 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1007 .setErrorCharacteristic("error")
1008 .setLossCharacteristic("loss")
1009 .setRepeatDeliveryCharacteristic("repeat delivery")
1010 .setDeliveryOrderCharacteristic("delivery order")
1011 .setUnavailableTimeCharacteristic("unavailable time")
1012 .setServerIntegrityProcessCharacteristic("server integrity process")
1016 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
1017 Collection<OwnedNodeEdgePoint> onepl) {
1018 Map<NodeEdgePointKey, NodeEdgePoint>
1019 nepMap = new HashMap<>();
1020 for (OwnedNodeEdgePoint onep : onepl) {
1021 NodeEdgePoint nep = new NodeEdgePointBuilder()
1022 .setTopologyUuid(this.tapiTopoUuid)
1023 .setNodeUuid(nodeUuid)
1024 .setNodeEdgePointUuid(onep.key().getUuid())
1026 nepMap.put(nep.key(), nep);
1028 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1029 Map<RuleKey, Rule> ruleList = new HashMap<>();
1030 Rule rule = new RuleBuilder()
1031 .setLocalId("forward")
1032 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
1033 .setRuleType(RuleType.FORWARDING)
1035 ruleList.put(rule.key(), rule);
1036 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1037 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
1038 .getBytes(StandardCharsets.UTF_8)).toString()))
1040 .setNodeEdgePoint(nepMap)
1042 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1043 return nodeRuleGroupMap;
1046 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps) {
1047 Map<LinkKey, Link> linkMap = new HashMap<>();
1048 for (Mapping mapping : xpdrNetMaps) {
1049 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
1050 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
1051 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
1052 "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
1053 Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
1055 linkMap.put(transiLink.key(), transiLink);
1057 // return a map of links and then we can do merge the corresponding link map into the topology context
1061 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
1062 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
1064 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1065 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1066 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1067 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1068 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1069 Set<TpId> tpList = new HashSet<>();
1072 NonBlockingList nbl = new NonBlockingListBuilder()
1073 .setNblNumber(Uint16.valueOf(count))
1076 nblMap.put(nbl.key(), nbl);
1079 return new OduSwitchingPoolsBuilder()
1080 .setNonBlockingList(nblMap)
1081 .setSwitchingPoolNumber(Uint16.valueOf(1))
1085 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
1087 Set<TpId> tpl = new HashSet<>();
1089 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1090 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1093 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1094 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
1097 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1098 NonBlockingList nbl = new NonBlockingListBuilder()
1099 .setNblNumber(Uint16.valueOf(1))
1102 nbMap.put(nbl.key(),nbl);
1104 return new OduSwitchingPoolsBuilder()
1105 .setSwitchingPoolNumber(Uint16.valueOf(1))
1106 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1107 .setNonBlockingList(nbMap)
1111 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
1112 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1113 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1114 Set<TpId> tpList = new HashSet<>();
1115 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1117 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
1119 NonBlockingList nbl = new NonBlockingListBuilder()
1120 .setNblNumber(Uint16.valueOf(i))
1122 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
1123 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
1125 nbMap.put(nbl.key(),nbl);
1127 return new OduSwitchingPoolsBuilder()
1128 .setSwitchingPoolNumber(Uint16.valueOf(1))
1129 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1130 .setNonBlockingList(nbMap)
1134 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
1135 List<Mapping> xpdrNetMaps,
1136 Map<RuleKey, Rule> ruleList) {
1137 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1138 // create NodeRuleGroup
1140 for (Mapping tpMapping : xpdrNetMaps) {
1141 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1142 NodeEdgePoint inep = new NodeEdgePointBuilder()
1143 .setTopologyUuid(this.tapiTopoUuid)
1144 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1145 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1146 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1147 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
1148 .getBytes(StandardCharsets.UTF_8)).toString()))
1150 NodeEdgePoint enep = new NodeEdgePointBuilder()
1151 .setTopologyUuid(this.tapiTopoUuid)
1152 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1153 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1154 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1155 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
1156 tpMapping.getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()))
1158 nepList.put(inep.key(), inep);
1159 nepList.put(enep.key(), enep);
1160 // Empty random creation of mandatory fields for avoiding errors....
1161 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1162 .setCostAlgorithm("Restricted Shortest Path - RSP")
1163 .setCostName("HOP_COUNT")
1164 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1166 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1167 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1168 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1169 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1170 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1171 .setTrafficPropertyName("FIXED_LATENCY")
1173 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1174 .setRiskCharacteristicName("risk characteristic")
1175 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1177 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1179 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(StandardCharsets.UTF_8))
1182 .setNodeEdgePoint(nepList)
1183 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1184 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1185 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1187 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1190 return nodeRuleGroupMap;
1193 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1194 OduSwitchingPools oorOduSwitchingPool,
1195 Map<RuleKey, Rule> ruleList,
1196 Map<OwnedNodeEdgePointKey,
1197 OwnedNodeEdgePoint> onepl) {
1198 // create NodeRuleGroup
1199 if (oorOduSwitchingPool == null) {
1200 LOG.info("No switching pool created for node = {}", nodeId);
1201 return new HashMap<>();
1203 LOG.info("ONEPL = {}", onepl.values());
1204 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1206 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1207 LOG.info("Non blocking list = {}", nbl);
1208 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1209 for (TpId tp : nbl.getTpList()) {
1210 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1211 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1212 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1213 TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1214 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1215 TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1216 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1217 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1218 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1219 .setTopologyUuid(this.tapiTopoUuid)
1220 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1221 (String.join("+", nodeId,TapiStringConstants. DSR))
1222 .getBytes(StandardCharsets.UTF_8)).toString()))
1223 .setNodeEdgePointUuid(tp1Uuid)
1225 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1226 .setTopologyUuid(this.tapiTopoUuid)
1227 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1228 (String.join("+", nodeId,TapiStringConstants. DSR))
1229 .getBytes(StandardCharsets.UTF_8)).toString()))
1230 .setNodeEdgePointUuid(tpUuid)
1232 nepList.put(nep1.key(), nep1);
1233 nepList.put(nep2.key(), nep2);
1236 // Empty random creation of mandatory fields for avoiding errors....
1237 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1238 .setCostAlgorithm("Restricted Shortest Path - RSP")
1239 .setCostName("HOP_COUNT")
1240 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1242 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1243 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1244 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1245 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1246 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1247 .setTrafficPropertyName("FIXED_LATENCY")
1249 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1250 .setRiskCharacteristicName("risk characteristic")
1251 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1253 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1255 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8))
1258 .setNodeEdgePoint(nepList)
1259 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1260 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1261 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1263 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1266 return nodeRuleGroupMap;
1269 private Set<LAYERPROTOCOLQUALIFIER> createSupportedLayerProtocolQualifier(
1270 List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1271 if (sicList == null) {
1272 return Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE);
1274 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1275 LOG.info("SIC list = {}", sicList);
1276 for (SupportedIfCapability supInterCapa : sicList) {
1277 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1278 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1279 .setIfCapType(supInterCapa)
1281 supIfMap.put(supIfCapa.key(), supIfCapa);
1283 Set<LAYERPROTOCOLQUALIFIER> sclpqList = new HashSet<>();
1284 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1285 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1286 switch (lpn.getName()) {
1288 switch (ifCapType) {
1289 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1290 // port are extended in the config file
1292 sclpqList.add(ODUTYPEODU0.VALUE);
1293 sclpqList.add(DIGITALSIGNALTYPEGigE.VALUE);
1296 sclpqList.add(ODUTYPEODU2E.VALUE);
1297 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1300 sclpqList.add(ODUTYPEODU2.VALUE);
1301 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1304 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1307 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1308 sclpqList.add(ODUTYPEODU4.VALUE);
1311 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1313 case "IfOCHOTU4ODU4":
1315 sclpqList.add(ODUTYPEODU4.VALUE);
1318 LOG.error("IfCapability type not managed");
1323 switch (ifCapType) {
1324 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1325 // port are extended in the config file
1327 sclpqList.add(ODUTYPEODU0.VALUE);
1330 sclpqList.add(ODUTYPEODU2E.VALUE);
1334 sclpqList.add(ODUTYPEODU2.VALUE);
1338 case "IfOCHOTU4ODU4":
1340 sclpqList.add(ODUTYPEODU4.VALUE);
1343 LOG.error("IfCapability type not managed");
1347 case "PHOTONIC_MEDIA":
1348 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1349 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.VALUE);
1350 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.VALUE);
1354 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1361 private String getNodeType(XpdrNodeTypes xponderType) {
1362 switch (xponderType.getIntValue()) {
1364 return OpenroadmNodeType.TPDR.getName();
1366 return OpenroadmNodeType.MUXPDR.getName();
1368 return OpenroadmNodeType.SWITCH.getName();
1370 LOG.info("XpdrType {} not supported", xponderType);
1376 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1377 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1378 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1379 LOG.info("Creating tapi node in TAPI topology context");
1380 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1381 .augmentation(Context1.class).child(TopologyContext.class)
1382 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1385 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1387 // merge in datastore
1388 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1391 this.networkTransactionService.commit().get();
1392 } catch (InterruptedException | ExecutionException e) {
1393 LOG.error("Error populating TAPI topology: ", e);
1395 LOG.info("Node added succesfully.");
1398 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1399 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1400 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1401 LOG.info("Creating tapi node in TAPI topology context");
1402 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1403 .augmentation(Context1.class).child(TopologyContext.class)
1404 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1407 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1409 // merge in datastore
1410 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1413 this.networkTransactionService.commit().get();
1414 } catch (InterruptedException | ExecutionException e) {
1415 LOG.error("Error populating TAPI topology: ", e);
1417 LOG.info("Roadm Link added succesfully.");
1420 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1421 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1422 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1424 ContextBuilder contextBuilder = new ContextBuilder();
1425 contextBuilder.setServiceInterfacePoint(sips);
1426 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1427 // merge in datastore
1428 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1429 contextBuilder.build());
1430 this.networkTransactionService.commit().get();
1431 LOG.info("TAPI SIPs merged successfully.");
1432 } catch (InterruptedException | ExecutionException e) {
1433 LOG.error("Failed to merge TAPI Sips", e);
1437 private void deleteLinkFromTopo(Uuid linkUuid) {
1438 // TODO: check if this IID is correct
1440 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1441 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1442 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1443 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1444 this.networkTransactionService.commit().get();
1445 LOG.info("TAPI link deleted successfully.");
1446 } catch (InterruptedException | ExecutionException e) {
1447 LOG.error("Failed to delete TAPI link", e);
1451 private void deleteNodeFromTopo(Uuid nodeUuid) {
1452 // TODO: check if this IID is correct
1454 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1455 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1456 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1457 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1458 this.networkTransactionService.commit().get();
1459 LOG.info("TAPI Node deleted successfully.");
1460 } catch (InterruptedException | ExecutionException e) {
1461 LOG.error("Failed to delete TAPI Node", e);
1465 private void deleteSipFromTopo(Uuid sipUuid) {
1466 // TODO: check if this IID is correct
1468 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1469 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1470 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1471 this.networkTransactionService.commit().get();
1472 LOG.info("TAPI SIP deleted successfully.");
1473 } catch (InterruptedException | ExecutionException e) {
1474 LOG.error("Failed to delete TAPI SIP", e);
1478 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1479 // TODO: check if this IID is correct
1480 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1481 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1482 .child(ConnectivityContext.class)
1484 ConnectivityContext connContext = null;
1486 Optional<ConnectivityContext> optConnContext =
1487 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1489 if (!optConnContext.isPresent()) {
1490 LOG.error("Couldnt retrieve connectivity context from datastore");
1493 connContext = optConnContext.get();
1494 } catch (InterruptedException | ExecutionException e) {
1495 LOG.error("Couldnt read connectivity context from datastore", e);
1497 if (connContext == null) {
1498 LOG.error("Connectivity context is empty");
1501 // Loop through services, check if the endpoint uuid is equal to the sip.
1502 // If so update state.
1503 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1504 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1505 if (connServMap != null) {
1506 for (ConnectivityService service:connServMap.values()) {
1507 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1508 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1509 .getServiceInterfacePointUuid().equals(sipUuid))) {
1510 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1511 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1512 .setAdministrativeState(AdministrativeState.LOCKED)
1513 .setOperationalState(OperationalState.DISABLED)
1514 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1516 updateConnectivityService(updService);
1520 // Update state of connections
1521 if (connMap != null) {
1522 for (Connection connection:connMap.values()) {
1523 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1524 Connection updConn = new ConnectionBuilder(connection)
1525 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1526 .setOperationalState(OperationalState.DISABLED)
1528 updateConnection(updConn);
1534 private void updateConnection(Connection updConn) {
1535 // TODO: check if this IID is correct
1536 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1537 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1538 .child(ConnectivityContext.class).child(Connection.class,
1539 new ConnectionKey(updConn.getUuid())).build();
1540 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1542 this.networkTransactionService.commit().get();
1543 } catch (InterruptedException | ExecutionException e) {
1544 LOG.error("Error committing into datastore", e);
1548 private void updateConnectivityService(ConnectivityService updService) {
1549 // TODO: check if this IID is correct
1550 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1551 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1552 .child(ConnectivityContext.class).child(ConnectivityService.class,
1553 new ConnectivityServiceKey(updService.getUuid())).build();
1554 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1556 this.networkTransactionService.commit().get();
1557 } catch (InterruptedException | ExecutionException e) {
1558 LOG.error("Error committing into datastore", e);