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.rev220922.mapping.Mapping;
32 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.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.getXpdrType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
239 // node transformation
240 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
241 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXpdrType(), 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 @SuppressWarnings("rawtypes")
264 private void sendNotification(List<Uuid> changedOneps, Mapping mapping) {
265 Notification notification = new NotificationBuilder()
266 .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE)
267 .setTargetObjectType(ObjectType.NODEEDGEPOINT)
268 .setChangedAttributes(getChangedAttributes(changedOneps, mapping))
269 .setUuid(tapiTopoUuid)
272 notificationPublishService.putNotification(notification);
273 } catch (InterruptedException e) {
274 LOG.error("Could not send notification");
278 private Map<ChangedAttributesKey, ChangedAttributes> getChangedAttributes(List<Uuid> changedOneps,
280 Map<ChangedAttributesKey, ChangedAttributes> changedAttributes = new HashMap<>();
281 for (Uuid nep : changedOneps) {
282 changedAttributes.put(new ChangedAttributesKey(nep.getValue()),
283 new ChangedAttributesBuilder().setValueName(nep.getValue())
284 .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService")
285 .setNewValue(mapping.getPortOperState())
288 return changedAttributes;
291 private void updateLinks(List<Uuid> changedOneps, Mapping mapping) {
293 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
294 .augmentation(Context1.class).child(TopologyContext.class)
295 .child(Topology.class, new TopologyKey(tapiTopoUuid))
297 Optional<Topology> optTopology = this.networkTransactionService
298 .read(LogicalDatastoreType.OPERATIONAL, topoIID).get();
299 if (optTopology.isEmpty()) {
300 LOG.error("Could not update TAPI links");
303 for (Link link : optTopology.get().nonnullLink().values()) {
304 List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
305 .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
306 if (!Collections.disjoint(changedOneps, linkNeps)) {
307 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
308 .augmentation(Context1.class).child(TopologyContext.class)
309 .child(Topology.class, new TopologyKey(tapiTopoUuid))
310 .child(Link.class, new LinkKey(link.getUuid())).build();
311 Link linkblr = new LinkBuilder().setUuid(link.getUuid())
312 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
313 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
314 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr);
317 this.networkTransactionService.commit().get();
318 } catch (InterruptedException | ExecutionException e) {
319 LOG.error("Could not update TAPI links");
323 private List<Uuid> updateNeps(Mapping mapping, List<Uuid> uuids) {
324 List<Uuid> changedOneps = new ArrayList<>();
325 for (Uuid nodeUuid : uuids) {
327 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
328 .augmentation(Context1.class).child(TopologyContext.class)
329 .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
331 Optional<Node> optionalNode = this.networkTransactionService.read(
332 LogicalDatastoreType.OPERATIONAL, nodeIID).get();
333 if (optionalNode.isPresent()) {
334 Node node = optionalNode.get();
335 List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
336 .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
337 .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
338 for (OwnedNodeEdgePoint onep : oneps) {
339 changedOneps.add(onep.getUuid());
340 updateSips(mapping, onep);
341 CepList cepList = getUpdatedCeps(mapping, onep);
342 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
343 .augmentation(Context1.class).child(TopologyContext.class)
344 .child(Topology.class, new TopologyKey(tapiTopoUuid))
345 .child(Node.class, new NodeKey(nodeUuid))
346 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid()))
348 OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid())
349 .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build())
350 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
351 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
352 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr);
354 this.networkTransactionService.commit().get();
356 } catch (InterruptedException | ExecutionException e) {
357 LOG.error("Could not update TAPI NEP");
363 private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) {
364 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
365 Map<ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
366 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) {
367 for (Map.Entry<ConnectionEndPointKey, ConnectionEndPoint> entry : onep1.getCepList().getConnectionEndPoint()
369 ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue())
370 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
371 cepMap.put(entry.getKey(), cep);
374 return new CepListBuilder().setConnectionEndPoint(cepMap).build();
377 private List<Uuid> getChangedNodeUuids(String nodeId, Mapping mapping) {
378 List<Uuid> uuids = new ArrayList<>();
379 if (nodeId.contains("ROADM")) {
380 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA))
381 .getBytes(StandardCharsets.UTF_8)).toString()));
382 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("CLIENT")) {
383 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
384 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
385 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
386 .getBytes(StandardCharsets.UTF_8)).toString()));
387 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("NETWORK")) {
388 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
389 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
390 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
391 .getBytes(StandardCharsets.UTF_8)).toString()));
392 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.OTSI))
393 .getBytes(StandardCharsets.UTF_8)).toString()));
395 LOG.error("Updating this device is currently not supported");
401 private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) {
402 if (onep.getMappedServiceInterfacePoint() == null
403 || onep.getMappedServiceInterfacePoint().size() == 0) {
406 for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) {
407 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier
408 .builder(Context.class)
409 .child(ServiceInterfacePoint.class,
410 new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid()))
412 ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder()
413 .setUuid(msip.getServiceInterfacePointUuid())
414 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
415 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
416 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr);
421 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
422 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
423 OduSwitchingPools oorOduSwitchingPool) {
424 Map<NodeKey, Node> nodeMap = new HashMap<>();
425 LOG.info("creation of a DSR/ODU node for {}", nodeId);
426 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
427 .getBytes(StandardCharsets.UTF_8)).toString());
428 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
429 String.join("+", nodeId, TapiStringConstants.DSR)).build();
430 Name nameNodeType = new NameBuilder().setValueName("Node Type")
431 .setValue(getNodeType(xponderType)).build();
432 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
433 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
434 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
436 nodeMap.put(dsrNode.key(), dsrNode);
438 // node creation [otsi]
439 LOG.info("creation of an OTSi node for {}", nodeId);
440 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
441 .getBytes(StandardCharsets.UTF_8)).toString());
442 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
443 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
444 Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
445 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
446 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
448 nodeMap.put(otsiNode.key(), otsiNode);
450 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
451 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
452 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps);
453 mergeLinkinTopology(linkMap);
458 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
460 // todo: are switching pool correct here??
464 return createTpdrSwitchPool(xpdrNetMaps);
467 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
470 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
472 LOG.warn("Xpdr type {} not supported", xpdrType);
477 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
478 Map<String, List<Mapping>> mapSrg) {
479 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
480 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
481 // For each srg node. Loop through the LCPs and create neps and sips for PP
482 for (Mapping m:entry.getValue()) {
483 if (!m.getLogicalConnectionPoint().contains("PP")) {
484 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
487 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
488 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
489 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
490 onepMap.putAll(srgNeps);
496 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
497 Map<String, List<Mapping>> mapDeg) {
498 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
499 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
500 // For each degree node. Loop through the LCPs and create neps and sips for TTP
501 for (Mapping m:entry.getValue()) {
502 if (!m.getLogicalConnectionPoint().contains("TTP")) {
503 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
506 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
507 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
508 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
509 onepMap.putAll(degNeps);
515 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
516 List<String> nodeShardList = new ArrayList<>();
517 for (Mapping mapping : mappingList) {
518 // TODO -> maybe we need to check the id based on the version
519 String str = mapping.getLogicalConnectionPoint().split("-")[0];
520 LOG.info("LCP = {}", str);
521 if (!nodeShardList.contains(str)) {
522 nodeShardList.add(str);
525 return nodeShardList;
529 public void deleteTapinode(String nodeId) {
530 // TODO: check for null objects
531 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
532 // This will delete NEPs. Then check for links that have this node and delete them.
533 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
534 LOG.info("Deleting node {} from TAPI topology", nodeId);
535 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
536 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
537 new TopologyKey(tapiTopoUuid)).build();
538 Topology topology = null;
540 Optional<Topology> optTopology =
541 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
542 if (!optTopology.isPresent()) {
543 LOG.error("No topology object present. Error deleting node {}", nodeId);
546 topology = optTopology.get();
547 } catch (InterruptedException | ExecutionException e) {
548 LOG.error("Couldnt read tapi topology from datastore", e);
550 if (topology == null) {
551 LOG.error("Topology is null, nothing to delete");
554 if (topology.getNode() == null) {
555 LOG.error("No nodes in topology");
558 if (nodeId.contains("ROADM")) {
559 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
560 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
561 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
562 deleteNodeFromTopo(nodeUuid);
564 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
565 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
566 for (Node tapiNode:topology.getNode().values()) {
567 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
568 // Found node we need to delete
569 deleteNodeFromTopo(tapiNode.getUuid());
573 // Delete links of topology
574 Map<LinkKey, Link> linkMap = topology.getLink();
575 if (linkMap != null) {
576 for (Link link:linkMap.values()) {
577 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
578 deleteLinkFromTopo(link.getUuid());
582 // Delete sips of sip map
583 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
584 Context context = null;
586 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
588 if (!optContext.isPresent()) {
589 LOG.error("No context object present in datastore.");
592 context = optContext.get();
593 } catch (InterruptedException | ExecutionException e) {
594 LOG.error("Couldnt read tapi context from datastore", e);
596 if (context == null) {
597 LOG.error("Context is null, nothing to delete");
600 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
602 for (ServiceInterfacePoint sip:sips.values()) {
603 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
604 // Update state of services that have this sip as an endpoint and also connections
605 updateConnectivityServicesState(sip.getUuid(), nodeId);
606 deleteSipFromTopo(sip.getUuid());
612 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
613 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
614 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
615 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
616 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
617 Map<RuleKey, Rule> ruleList = new HashMap<>();
618 Rule rule = new RuleBuilder()
619 .setLocalId("forward")
620 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
621 .setRuleType(RuleType.FORWARDING)
623 ruleList.put(rule.key(), rule);
624 if (layerProtocols.contains(LayerProtocolName.DSR)) {
625 // neps for dsr/odu layer
626 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
627 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
628 onepl.putAll(dsroduNeps);
629 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
630 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
631 // neps for photonic layer
632 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
633 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
634 onepl.putAll(phtmdNeps);
635 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
637 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
638 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
640 // Empty random creation of mandatory fields for avoiding errors....
641 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
642 .setCostAlgorithm("Restricted Shortest Path - RSP")
643 .setCostName("HOP_COUNT")
644 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
646 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
647 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
648 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
649 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
650 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
651 .setTrafficPropertyName("FIXED_LATENCY")
653 return new NodeBuilder()
656 .setLayerProtocolName(layerProtocols)
657 .setAdministrativeState(AdministrativeState.UNLOCKED)
658 .setOperationalState(OperationalState.ENABLED)
659 .setLifecycleState(LifecycleState.INSTALLED)
660 .setOwnedNodeEdgePoint(onepl)
661 .setNodeRuleGroup(nodeRuleGroupList)
662 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
663 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
664 .setErrorCharacteristic("error")
665 .setLossCharacteristic("loss")
666 .setRepeatDeliveryCharacteristic("repeat delivery")
667 .setDeliveryOrderCharacteristic("delivery order")
668 .setUnavailableTimeCharacteristic("unavailable time")
669 .setServerIntegrityProcessCharacteristic("server integrity process")
673 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
674 List<Mapping> xpdrNetMaps) {
675 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
677 // iNep creation on otsi node
678 for (int i = 0; i < xpdrNetMaps.size(); i++) {
679 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
680 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
681 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
682 Name onedName = new NameBuilder()
683 .setValueName("iNodeEdgePoint")
684 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
685 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
688 List<SupportedIfCapability> newSupIfCapList =
689 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
691 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
692 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
693 true, String.join("+", nodeId, TapiStringConstants.I_OTSI), newSupIfCapList,
694 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
695 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
696 onepl.put(onep.key(), onep);
698 // eNep creation on otsi node
699 for (int i = 0; i < xpdrNetMaps.size(); i++) {
700 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
701 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
702 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
703 Name onedName = new NameBuilder()
704 .setValueName("eNodeEdgePoint")
705 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
706 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
709 List<SupportedIfCapability> newSupIfCapList =
710 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
712 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
713 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
714 false, String.join("+", nodeId, TapiStringConstants.E_OTSI), newSupIfCapList,
715 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
716 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
717 onepl.put(onep.key(), onep);
719 // Photonic Media Nep creation on otsi node
720 for (int i = 0; i < xpdrNetMaps.size(); i++) {
721 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
722 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
723 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
724 Name onedName = new NameBuilder()
725 .setValueName("PhotMedNodeEdgePoint")
726 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
727 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
730 List<SupportedIfCapability> newSupIfCapList =
731 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
733 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
734 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
735 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA), newSupIfCapList,
736 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
737 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
738 onepl.put(onep.key(), onep);
743 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
744 List<Mapping> xpdrNetMaps,
745 XpdrNodeTypes xponderType) {
746 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
747 // client nep creation on DSR node
748 for (int i = 0; i < xpdrClMaps.size(); i++) {
749 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
750 xpdrClMaps.get(i).getLogicalConnectionPoint()));
751 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
752 (String.join("+", nodeId, TapiStringConstants.DSR,
753 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
754 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
755 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
757 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
758 name = nameBldr.setValueName("100G-tpdr").build();
760 name = nameBldr.setValueName("NodeEdgePoint_C").build();
763 List<SupportedIfCapability> newSupIfCapList =
764 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
766 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
767 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
768 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
769 transformOperState(xpdrClMaps.get(i).getPortOperState()),
770 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
771 onepl.put(onep.key(), onep);
773 // network nep creation on I_ODU node
774 for (int i = 0; i < xpdrNetMaps.size(); i++) {
775 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
776 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
777 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
778 (String.join("+", nodeId, TapiStringConstants.I_ODU,
779 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
780 Name onedName = new NameBuilder()
781 .setValueName("iNodeEdgePoint_N")
782 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
783 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
786 List<SupportedIfCapability> newSupIfCapList =
787 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
789 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
790 Map.of(onedName.key(), onedName),
791 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
792 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
793 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
794 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
795 onepl.put(onep.key(), onep);
797 // network nep creation on E_ODU node
798 for (int i = 0; i < xpdrClMaps.size(); i++) {
799 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
800 xpdrClMaps.get(i).getLogicalConnectionPoint()));
801 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
802 (String.join("+", nodeId, TapiStringConstants.E_ODU,
803 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
804 Name onedName = new NameBuilder()
805 .setValueName("eNodeEdgePoint_N")
806 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
807 xpdrClMaps.get(i).getLogicalConnectionPoint()))
810 List<SupportedIfCapability> newSupIfCapList =
811 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
813 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
814 Map.of(onedName.key(), onedName),
815 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
816 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
817 transformOperState(xpdrClMaps.get(i).getPortOperState()),
818 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
819 onepl.put(onep.key(), onep);
824 private OperationalState transformOperState(String operString) {
825 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
826 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
829 private AdministrativeState transformAdminState(String adminString) {
830 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
831 .setNetworkAdminState(adminString);
832 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
835 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
836 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
838 List<SupportedIfCapability> supportedInterfaceCapability,
839 OperationalState operState, AdministrativeState adminState) {
840 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
842 .setLayerProtocolName(nepProtocol)
845 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
846 supportedInterfaceCapability, operState, adminState));
848 LOG.debug("Node layer {}", nodeProtocol.getName());
849 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
850 supportedInterfaceCapability, nepProtocol));
851 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
852 .setAdministrativeState(adminState).setOperationalState(operState)
853 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
854 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
855 return onepBldr.build();
858 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
859 boolean withSip, OperationalState operState,
860 AdministrativeState adminState) {
861 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
862 // PHOTONIC MEDIA nep
863 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
864 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
865 Name nepName = new NameBuilder()
866 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
867 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
869 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
871 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
872 .setName(Map.of(nepName.key(), nepName))
873 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
874 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
875 .setAdministrativeState(adminState).setOperationalState(operState)
876 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
877 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
879 onepMap.put(onep.key(), onep);
882 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
883 TapiStringConstants.MC, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
884 Name nepName1 = new NameBuilder()
885 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
886 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
888 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
890 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
891 .setName(Map.of(nepName1.key(), nepName1))
892 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
893 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
894 .setAdministrativeState(adminState).setOperationalState(operState)
895 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
896 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
898 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
899 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
900 operState, adminState));
902 OwnedNodeEdgePoint onep1 = onepBldr1.build();
903 onepMap.put(onep1.key(), onep1);
906 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
907 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
908 Name nepName2 = new NameBuilder()
909 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
910 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
913 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
915 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
916 .setName(Map.of(nepName2.key(), nepName2))
917 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
918 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
919 .setAdministrativeState(adminState).setOperationalState(operState)
920 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
921 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
923 onepMap.put(onep2.key(), onep2);
927 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
928 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
929 List<SupportedIfCapability> supportedInterfaceCapability,
930 OperationalState operState, AdministrativeState adminState) {
931 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
932 for (int i = 0; i < nb; i++) {
933 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
934 tpid)).getBytes(StandardCharsets.UTF_8)).toString());
935 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
936 .setServiceInterfacePointUuid(sipUuid).build();
937 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
938 operState, adminState);
939 this.sipMap.put(sip.key(), sip);
940 LOG.info("SIP created {}", sip.getUuid());
941 // this.tapiSips.put(sip.key(), sip);
942 msipl.put(msip.key(), msip);
947 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
948 List<SupportedIfCapability> supportedInterfaceCapability,
949 OperationalState operState, AdministrativeState adminState) {
950 // TODO: what value should be set in total capacity and available capacity
951 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
952 Name sipName = new NameBuilder()
953 .setValueName("SIP name")
954 .setValue(String.join("+", nodeid, tpid))
956 return new ServiceInterfacePointBuilder()
958 .setName(Map.of(sipName.key(), sipName))
959 .setLayerProtocolName(layerProtocol)
960 .setAdministrativeState(adminState)
961 .setOperationalState(operState)
962 .setLifecycleState(LifecycleState.INSTALLED)
963 .setAvailableCapacity(new AvailableCapacityBuilder().build())
964 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
965 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
970 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
972 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
973 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
975 Name nodeNames = new NameBuilder().setValueName("roadm node name")
976 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
977 Name nameNodeType = new NameBuilder().setValueName("Node Type")
978 .setValue(OpenroadmNodeType.ROADM.getName()).build();
980 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
981 // Empty random creation of mandatory fields for avoiding errors....
982 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
983 .setCostAlgorithm("Restricted Shortest Path - RSP")
984 .setCostName("HOP_COUNT")
985 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
987 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
988 .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE)
989 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
990 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
991 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
992 .setTrafficPropertyName("FIXED_LATENCY")
994 return new NodeBuilder()
996 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
997 .setLayerProtocolName(layerProtocols)
998 .setAdministrativeState(AdministrativeState.UNLOCKED)
999 .setOperationalState(OperationalState.ENABLED)
1000 .setLifecycleState(LifecycleState.INSTALLED)
1001 .setOwnedNodeEdgePoint(oneplist)
1002 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
1003 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1004 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1005 .setErrorCharacteristic("error")
1006 .setLossCharacteristic("loss")
1007 .setRepeatDeliveryCharacteristic("repeat delivery")
1008 .setDeliveryOrderCharacteristic("delivery order")
1009 .setUnavailableTimeCharacteristic("unavailable time")
1010 .setServerIntegrityProcessCharacteristic("server integrity process")
1014 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
1015 Collection<OwnedNodeEdgePoint> onepl) {
1016 Map<NodeEdgePointKey, NodeEdgePoint>
1017 nepMap = new HashMap<>();
1018 for (OwnedNodeEdgePoint onep : onepl) {
1019 NodeEdgePoint nep = new NodeEdgePointBuilder()
1020 .setTopologyUuid(this.tapiTopoUuid)
1021 .setNodeUuid(nodeUuid)
1022 .setNodeEdgePointUuid(onep.key().getUuid())
1024 nepMap.put(nep.key(), nep);
1026 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1027 Map<RuleKey, Rule> ruleList = new HashMap<>();
1028 Rule rule = new RuleBuilder()
1029 .setLocalId("forward")
1030 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
1031 .setRuleType(RuleType.FORWARDING)
1033 ruleList.put(rule.key(), rule);
1034 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1035 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
1036 .getBytes(StandardCharsets.UTF_8)).toString()))
1038 .setNodeEdgePoint(nepMap)
1040 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1041 return nodeRuleGroupMap;
1044 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps) {
1045 Map<LinkKey, Link> linkMap = new HashMap<>();
1046 for (Mapping mapping : xpdrNetMaps) {
1047 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
1048 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
1049 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
1050 "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
1051 Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
1053 linkMap.put(transiLink.key(), transiLink);
1055 // return a map of links and then we can do merge the corresponding link map into the topology context
1059 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
1060 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
1062 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1063 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1064 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1065 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1066 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1067 Set<TpId> tpList = new HashSet<>();
1070 NonBlockingList nbl = new NonBlockingListBuilder()
1071 .setNblNumber(Uint16.valueOf(count))
1074 nblMap.put(nbl.key(), nbl);
1077 return new OduSwitchingPoolsBuilder()
1078 .setNonBlockingList(nblMap)
1079 .setSwitchingPoolNumber(Uint16.valueOf(1))
1083 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
1085 Set<TpId> tpl = new HashSet<>();
1087 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1088 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1091 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1092 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
1095 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1096 NonBlockingList nbl = new NonBlockingListBuilder()
1097 .setNblNumber(Uint16.valueOf(1))
1100 nbMap.put(nbl.key(),nbl);
1102 return new OduSwitchingPoolsBuilder()
1103 .setSwitchingPoolNumber(Uint16.valueOf(1))
1104 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1105 .setNonBlockingList(nbMap)
1109 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
1110 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1111 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1112 Set<TpId> tpList = new HashSet<>();
1113 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1115 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
1117 NonBlockingList nbl = new NonBlockingListBuilder()
1118 .setNblNumber(Uint16.valueOf(i))
1120 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
1121 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
1123 nbMap.put(nbl.key(),nbl);
1125 return new OduSwitchingPoolsBuilder()
1126 .setSwitchingPoolNumber(Uint16.valueOf(1))
1127 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1128 .setNonBlockingList(nbMap)
1132 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
1133 List<Mapping> xpdrNetMaps,
1134 Map<RuleKey, Rule> ruleList) {
1135 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1136 // create NodeRuleGroup
1138 for (Mapping tpMapping : xpdrNetMaps) {
1139 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1140 NodeEdgePoint inep = new NodeEdgePointBuilder()
1141 .setTopologyUuid(this.tapiTopoUuid)
1142 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1143 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1144 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1145 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
1146 .getBytes(StandardCharsets.UTF_8)).toString()))
1148 NodeEdgePoint enep = new NodeEdgePointBuilder()
1149 .setTopologyUuid(this.tapiTopoUuid)
1150 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1151 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1152 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1153 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
1154 tpMapping.getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()))
1156 nepList.put(inep.key(), inep);
1157 nepList.put(enep.key(), enep);
1158 // Empty random creation of mandatory fields for avoiding errors....
1159 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1160 .setCostAlgorithm("Restricted Shortest Path - RSP")
1161 .setCostName("HOP_COUNT")
1162 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1164 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1165 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1166 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1167 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1168 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1169 .setTrafficPropertyName("FIXED_LATENCY")
1171 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1172 .setRiskCharacteristicName("risk characteristic")
1173 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1175 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1177 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(StandardCharsets.UTF_8))
1180 .setNodeEdgePoint(nepList)
1181 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1182 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1183 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1185 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1188 return nodeRuleGroupMap;
1191 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1192 OduSwitchingPools oorOduSwitchingPool,
1193 Map<RuleKey, Rule> ruleList,
1194 Map<OwnedNodeEdgePointKey,
1195 OwnedNodeEdgePoint> onepl) {
1196 // create NodeRuleGroup
1197 if (oorOduSwitchingPool == null) {
1198 LOG.info("No switching pool created for node = {}", nodeId);
1199 return new HashMap<>();
1201 LOG.info("ONEPL = {}", onepl.values());
1202 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1204 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1205 LOG.info("Non blocking list = {}", nbl);
1206 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1207 for (TpId tp : nbl.getTpList()) {
1208 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1209 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1210 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1211 TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1212 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1213 TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1214 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1215 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1216 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1217 .setTopologyUuid(this.tapiTopoUuid)
1218 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1219 (String.join("+", nodeId,TapiStringConstants. DSR))
1220 .getBytes(StandardCharsets.UTF_8)).toString()))
1221 .setNodeEdgePointUuid(tp1Uuid)
1223 NodeEdgePoint nep2 = 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(tpUuid)
1230 nepList.put(nep1.key(), nep1);
1231 nepList.put(nep2.key(), nep2);
1234 // Empty random creation of mandatory fields for avoiding errors....
1235 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1236 .setCostAlgorithm("Restricted Shortest Path - RSP")
1237 .setCostName("HOP_COUNT")
1238 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1240 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1241 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1242 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1243 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1244 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1245 .setTrafficPropertyName("FIXED_LATENCY")
1247 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1248 .setRiskCharacteristicName("risk characteristic")
1249 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1251 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1253 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8))
1256 .setNodeEdgePoint(nepList)
1257 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1258 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1259 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1261 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1264 return nodeRuleGroupMap;
1267 private Set<LAYERPROTOCOLQUALIFIER> createSupportedLayerProtocolQualifier(
1268 List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1269 if (sicList == null) {
1270 return Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE);
1272 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1273 LOG.info("SIC list = {}", sicList);
1274 for (SupportedIfCapability supInterCapa : sicList) {
1275 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1276 .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
1277 .setIfCapType(supInterCapa)
1279 supIfMap.put(supIfCapa.key(), supIfCapa);
1281 Set<LAYERPROTOCOLQUALIFIER> sclpqList = new HashSet<>();
1282 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1283 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1284 switch (lpn.getName()) {
1286 switch (ifCapType) {
1287 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1288 // port are extended in the config file
1290 sclpqList.add(ODUTYPEODU0.VALUE);
1291 sclpqList.add(DIGITALSIGNALTYPEGigE.VALUE);
1294 sclpqList.add(ODUTYPEODU2E.VALUE);
1295 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1298 sclpqList.add(ODUTYPEODU2.VALUE);
1299 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1302 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1305 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1306 sclpqList.add(ODUTYPEODU4.VALUE);
1309 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1311 case "IfOCHOTU4ODU4":
1313 sclpqList.add(ODUTYPEODU4.VALUE);
1316 LOG.error("IfCapability type not managed");
1321 switch (ifCapType) {
1322 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1323 // port are extended in the config file
1325 sclpqList.add(ODUTYPEODU0.VALUE);
1328 sclpqList.add(ODUTYPEODU2E.VALUE);
1332 sclpqList.add(ODUTYPEODU2.VALUE);
1336 case "IfOCHOTU4ODU4":
1338 sclpqList.add(ODUTYPEODU4.VALUE);
1341 LOG.error("IfCapability type not managed");
1345 case "PHOTONIC_MEDIA":
1346 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1347 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.VALUE);
1348 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.VALUE);
1352 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1359 private String getNodeType(XpdrNodeTypes xponderType) {
1360 switch (xponderType.getIntValue()) {
1362 return OpenroadmNodeType.TPDR.getName();
1364 return OpenroadmNodeType.MUXPDR.getName();
1366 return OpenroadmNodeType.SWITCH.getName();
1368 LOG.info("XpdrType {} not supported", xponderType);
1374 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1375 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1376 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1377 LOG.info("Creating tapi node in TAPI topology context");
1378 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1379 .augmentation(Context1.class).child(TopologyContext.class)
1380 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1383 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1385 // merge in datastore
1386 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1389 this.networkTransactionService.commit().get();
1390 } catch (InterruptedException | ExecutionException e) {
1391 LOG.error("Error populating TAPI topology: ", e);
1393 LOG.info("Node added succesfully.");
1396 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1397 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1398 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1399 LOG.info("Creating tapi node in TAPI topology context");
1400 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1401 .augmentation(Context1.class).child(TopologyContext.class)
1402 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1405 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1407 // merge in datastore
1408 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1411 this.networkTransactionService.commit().get();
1412 } catch (InterruptedException | ExecutionException e) {
1413 LOG.error("Error populating TAPI topology: ", e);
1415 LOG.info("Roadm Link added succesfully.");
1418 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1419 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1420 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1422 ContextBuilder contextBuilder = new ContextBuilder();
1423 contextBuilder.setServiceInterfacePoint(sips);
1424 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1425 // merge in datastore
1426 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1427 contextBuilder.build());
1428 this.networkTransactionService.commit().get();
1429 LOG.info("TAPI SIPs merged successfully.");
1430 } catch (InterruptedException | ExecutionException e) {
1431 LOG.error("Failed to merge TAPI Sips", e);
1435 private void deleteLinkFromTopo(Uuid linkUuid) {
1436 // TODO: check if this IID is correct
1438 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1439 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1440 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1441 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1442 this.networkTransactionService.commit().get();
1443 LOG.info("TAPI link deleted successfully.");
1444 } catch (InterruptedException | ExecutionException e) {
1445 LOG.error("Failed to delete TAPI link", e);
1449 private void deleteNodeFromTopo(Uuid nodeUuid) {
1450 // TODO: check if this IID is correct
1452 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1453 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1454 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1455 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1456 this.networkTransactionService.commit().get();
1457 LOG.info("TAPI Node deleted successfully.");
1458 } catch (InterruptedException | ExecutionException e) {
1459 LOG.error("Failed to delete TAPI Node", e);
1463 private void deleteSipFromTopo(Uuid sipUuid) {
1464 // TODO: check if this IID is correct
1466 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1467 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1468 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1469 this.networkTransactionService.commit().get();
1470 LOG.info("TAPI SIP deleted successfully.");
1471 } catch (InterruptedException | ExecutionException e) {
1472 LOG.error("Failed to delete TAPI SIP", e);
1476 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1477 // TODO: check if this IID is correct
1478 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1479 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1480 .child(ConnectivityContext.class)
1482 ConnectivityContext connContext = null;
1484 Optional<ConnectivityContext> optConnContext =
1485 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1487 if (!optConnContext.isPresent()) {
1488 LOG.error("Couldnt retrieve connectivity context from datastore");
1491 connContext = optConnContext.get();
1492 } catch (InterruptedException | ExecutionException e) {
1493 LOG.error("Couldnt read connectivity context from datastore", e);
1495 if (connContext == null) {
1496 LOG.error("Connectivity context is empty");
1499 // Loop through services, check if the endpoint uuid is equal to the sip.
1500 // If so update state.
1501 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1502 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1503 if (connServMap != null) {
1504 for (ConnectivityService service:connServMap.values()) {
1505 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1506 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1507 .getServiceInterfacePointUuid().equals(sipUuid))) {
1508 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1509 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1510 .setAdministrativeState(AdministrativeState.LOCKED)
1511 .setOperationalState(OperationalState.DISABLED)
1512 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1514 updateConnectivityService(updService);
1518 // Update state of connections
1519 if (connMap != null) {
1520 for (Connection connection:connMap.values()) {
1521 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1522 Connection updConn = new ConnectionBuilder(connection)
1523 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1524 .setOperationalState(OperationalState.DISABLED)
1526 updateConnection(updConn);
1532 private void updateConnection(Connection updConn) {
1533 // TODO: check if this IID is correct
1534 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1535 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1536 .child(ConnectivityContext.class).child(Connection.class,
1537 new ConnectionKey(updConn.getUuid())).build();
1538 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1540 this.networkTransactionService.commit().get();
1541 } catch (InterruptedException | ExecutionException e) {
1542 LOG.error("Error committing into datastore", e);
1546 private void updateConnectivityService(ConnectivityService updService) {
1547 // TODO: check if this IID is correct
1548 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1549 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1550 .child(ConnectivityContext.class).child(ConnectivityService.class,
1551 new ConnectivityServiceKey(updService.getUuid())).build();
1552 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1554 this.networkTransactionService.commit().get();
1555 } catch (InterruptedException | ExecutionException e) {
1556 LOG.error("Error committing into datastore", e);