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 com.google.common.collect.ImmutableMap;
11 import java.nio.charset.StandardCharsets;
12 import java.util.ArrayList;
13 import java.util.Collection;
14 import java.util.Collections;
15 import java.util.Comparator;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
20 import java.util.Objects;
21 import java.util.Optional;
23 import java.util.UUID;
24 import java.util.concurrent.ExecutionException;
25 import java.util.stream.Collectors;
26 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
27 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
28 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
29 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
30 import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery;
31 import org.opendaylight.transportpce.tapi.TapiStringConstants;
32 import org.opendaylight.transportpce.tapi.utils.TapiLink;
33 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPools;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev201211.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmNodeType;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GE;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GEODU4;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GE;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GEODU2;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GEODU2e;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If1GEODU0;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If400GE;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCH;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOTU4ODU4;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.SupportedIfCapability;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1Builder;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepList;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.NodeEdgePointRef;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder;
130 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey;
131 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
132 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
133 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
134 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
135 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
136 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
137 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
138 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
139 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
140 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
141 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
142 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
143 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder;
144 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
145 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
146 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
147 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
148 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
149 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
150 import org.opendaylight.yangtools.yang.binding.Notification;
151 import org.opendaylight.yangtools.yang.common.Uint16;
152 import org.opendaylight.yangtools.yang.common.Uint32;
153 import org.osgi.service.component.annotations.Activate;
154 import org.osgi.service.component.annotations.Component;
155 import org.osgi.service.component.annotations.Reference;
156 import org.slf4j.Logger;
157 import org.slf4j.LoggerFactory;
161 public class TapiNetworkModelServiceImpl implements TapiNetworkModelService {
163 private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class);
165 private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
166 .getBytes(StandardCharsets.UTF_8)).toString());
167 private final NetworkTransactionService networkTransactionService;
168 private final R2RTapiLinkDiscovery linkDiscovery;
169 private final TapiLink tapiLink;
170 private final NotificationPublishService notificationPublishService;
171 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap = new HashMap<>();
174 public TapiNetworkModelServiceImpl(@Reference NetworkTransactionService networkTransactionService,
175 @Reference DeviceTransactionManager deviceTransactionManager,
176 @Reference TapiLink tapiLink,
177 @Reference final NotificationPublishService notificationPublishService) {
178 this.networkTransactionService = networkTransactionService;
179 this.linkDiscovery = new R2RTapiLinkDiscovery(networkTransactionService, deviceTransactionManager, tapiLink);
180 this.tapiLink = tapiLink;
181 this.notificationPublishService = notificationPublishService;
185 public void createTapiNode(String orNodeId, int orNodeVersion, Nodes node) {
186 // TODO -> Implementation with PortMappingListener
187 // check if port mapping exists or not...
188 if (node.getMapping() == null) {
189 LOG.warn("Could not generate port mapping for {} skipping network model creation", orNodeId);
193 LOG.info("Mapping of node {}: {}", orNodeId, node.getMapping().values());
195 // check type of device, check version and create node mapping
196 if (NodeTypes.Rdm.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
198 // transform flat mapping list to per degree and per srg mapping lists
199 Map<String, List<Mapping>> mapDeg = new HashMap<>();
200 Map<String, List<Mapping>> mapSrg = new HashMap<>();
201 List<Mapping> mappingList = new ArrayList<>(node.nonnullMapping().values());
202 mappingList.sort(Comparator.comparing(Mapping::getLogicalConnectionPoint));
204 List<String> nodeShardList = getRoadmNodelist(mappingList);
206 // populate degree and srg LCP map
207 for (String str : nodeShardList) {
208 List<Mapping> interList = mappingList.stream().filter(x -> x.getLogicalConnectionPoint().contains(str))
209 .collect(Collectors.toList());
210 if (str.contains("DEG")) {
211 mapDeg.put(str, interList);
212 } else if (str.contains("SRG")) {
213 mapSrg.put(str, interList);
215 LOG.error("unknown element");
218 // Transform LCPs into ONEP
219 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap =
220 new HashMap<>(transformDegToOnep(orNodeId, mapDeg));
221 onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg));
224 Node roadmNode = createRoadmTapiNode(orNodeId, onepMap);
225 mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode));
226 mergeSipsinContext(this.sipMap);
227 // TODO add states corresponding to device config -> based on mapping.
228 // This should be possible after Gilles work is merged
230 // rdm to rdm link creation if neighbour roadm is mounted
231 LOG.info("checking if neighbor roadm exists");
232 Map<LinkKey, Link> rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion,
234 if (!rdm2rdmLinks.isEmpty()) {
235 mergeLinkinTopology(rdm2rdmLinks);
237 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
238 } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) {
239 List<Mapping> networkMappings = node.nonnullMapping().values()
240 .stream().filter(k -> k.getLogicalConnectionPoint()
241 .contains("NETWORK")).collect(Collectors.toList());
242 Map<Integer, String> xpdrMap = new HashMap<>();
243 for (Mapping mapping : networkMappings) {
244 Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
245 String nodeId = node.getNodeId() + TapiStringConstants.XPDR + xpdrNb;
246 if (!xpdrMap.containsKey(xpdrNb)) {
247 List<Mapping> xpdrNetMaps = node.nonnullMapping().values()
248 .stream().filter(k -> k.getLogicalConnectionPoint()
249 .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList());
250 List<Mapping> xpdrClMaps = node.nonnullMapping().values()
251 .stream().filter(k -> k.getLogicalConnectionPoint()
252 .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList());
253 xpdrMap.put(xpdrNb, node.getNodeId());
255 // create switching pool
256 OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr(
257 mapping.getXpdrType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb);
259 // node transformation
260 Map<NodeKey, Node> nodeMap = new HashMap<>(transformXpdrToTapiNode(
261 nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXpdrType(), oorOduSwitchingPool));
262 // add nodes and sips to tapi context
263 mergeNodeinTopology(nodeMap);
264 mergeSipsinContext(this.sipMap);
267 LOG.info("TAPI node for or node {} successfully merged", orNodeId);
269 // Device not managed yet
273 public void updateTapiTopology(String nodeId, Mapping mapping) {
274 List<Uuid> uuids = getChangedNodeUuids(nodeId, mapping);
276 List<Uuid> changedOneps = updateNeps(mapping, uuids);
277 updateLinks(changedOneps, mapping);
278 sendNotification(changedOneps, mapping);
280 LOG.info("Updated TAPI topology successfully.");
283 @SuppressWarnings("rawtypes")
284 private void sendNotification(List<Uuid> changedOneps, Mapping mapping) {
285 Notification notification = new NotificationBuilder()
286 .setNotificationType(NotificationType.ATTRIBUTEVALUECHANGE)
287 .setTargetObjectType(ObjectType.NODEEDGEPOINT)
288 .setChangedAttributes(getChangedAttributes(changedOneps, mapping))
289 .setUuid(tapiTopoUuid)
292 notificationPublishService.putNotification(notification);
293 } catch (InterruptedException e) {
294 LOG.error("Could not send notification");
298 private Map<ChangedAttributesKey, ChangedAttributes> getChangedAttributes(List<Uuid> changedOneps,
300 Map<ChangedAttributesKey, ChangedAttributes> changedAttributes = new HashMap<>();
301 for (Uuid nep : changedOneps) {
302 changedAttributes.put(new ChangedAttributesKey(nep.getValue()),
303 new ChangedAttributesBuilder().setValueName(nep.getValue())
304 .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService")
305 .setNewValue(mapping.getPortOperState())
308 return changedAttributes;
311 private void updateLinks(List<Uuid> changedOneps, Mapping mapping) {
313 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
314 .augmentation(Context1.class).child(TopologyContext.class)
315 .child(Topology.class, new TopologyKey(tapiTopoUuid))
317 Optional<Topology> optTopology = this.networkTransactionService
318 .read(LogicalDatastoreType.OPERATIONAL, topoIID).get();
319 if (optTopology.isEmpty()) {
320 LOG.error("Could not update TAPI links");
323 for (Link link : optTopology.orElseThrow().nonnullLink().values()) {
324 List<Uuid> linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream()
325 .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList());
326 if (!Collections.disjoint(changedOneps, linkNeps)) {
327 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
328 .augmentation(Context1.class).child(TopologyContext.class)
329 .child(Topology.class, new TopologyKey(tapiTopoUuid))
330 .child(Link.class, new LinkKey(link.getUuid())).build();
331 Link linkblr = new LinkBuilder().setUuid(link.getUuid())
332 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
333 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
334 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr);
337 this.networkTransactionService.commit().get();
338 } catch (InterruptedException | ExecutionException e) {
339 LOG.error("Could not update TAPI links");
343 private List<Uuid> updateNeps(Mapping mapping, List<Uuid> uuids) {
344 List<Uuid> changedOneps = new ArrayList<>();
345 for (Uuid nodeUuid : uuids) {
347 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
348 .augmentation(Context1.class).child(TopologyContext.class)
349 .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
351 Optional<Node> optionalNode = this.networkTransactionService.read(
352 LogicalDatastoreType.OPERATIONAL, nodeIID).get();
353 if (optionalNode.isPresent()) {
354 Node node = optionalNode.orElseThrow();
355 List<OwnedNodeEdgePoint> oneps = node.getOwnedNodeEdgePoint().values().stream()
356 .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue()
357 .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList());
358 for (OwnedNodeEdgePoint onep : oneps) {
359 changedOneps.add(onep.getUuid());
360 updateSips(mapping, onep);
361 CepList cepList = getUpdatedCeps(mapping, onep);
362 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
363 .augmentation(Context1.class).child(TopologyContext.class)
364 .child(Topology.class, new TopologyKey(tapiTopoUuid))
365 .child(Node.class, new NodeKey(nodeUuid))
366 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid()))
368 OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid())
369 .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build())
370 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
371 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
372 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr);
374 this.networkTransactionService.commit().get();
376 } catch (InterruptedException | ExecutionException e) {
377 LOG.error("Could not update TAPI NEP");
383 private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) {
384 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
385 Map<ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
386 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) {
387 for (Map.Entry<ConnectionEndPointKey, ConnectionEndPoint> entry : onep1.getCepList().getConnectionEndPoint()
389 ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue())
390 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
391 cepMap.put(entry.getKey(), cep);
394 return new CepListBuilder().setConnectionEndPoint(cepMap).build();
397 private List<Uuid> getChangedNodeUuids(String nodeId, Mapping mapping) {
398 List<Uuid> uuids = new ArrayList<>();
399 if (nodeId.contains("ROADM")) {
400 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA))
401 .getBytes(StandardCharsets.UTF_8)).toString()));
402 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("CLIENT")) {
403 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
404 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
405 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
406 .getBytes(StandardCharsets.UTF_8)).toString()));
407 } else if (nodeId.contains("PDR") && mapping.getLogicalConnectionPoint().contains("NETWORK")) {
408 int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]);
409 String xpdrNodeId = nodeId + TapiStringConstants.XPDR + xpdrNb;
410 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.DSR))
411 .getBytes(StandardCharsets.UTF_8)).toString()));
412 uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.OTSI))
413 .getBytes(StandardCharsets.UTF_8)).toString()));
415 LOG.error("Updating this device is currently not supported");
421 private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) {
422 if (onep.getMappedServiceInterfacePoint() == null
423 || onep.getMappedServiceInterfacePoint().size() == 0) {
426 for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) {
427 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier
428 .builder(Context.class)
429 .child(ServiceInterfacePoint.class,
430 new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid()))
432 ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder()
433 .setUuid(msip.getServiceInterfacePointUuid())
434 .setAdministrativeState(transformAdminState(mapping.getPortAdminState()))
435 .setOperationalState(transformOperState(mapping.getPortOperState())).build();
436 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr);
441 private Map<NodeKey, Node> transformXpdrToTapiNode(String nodeId, List<Mapping> xpdrClMaps,
442 List<Mapping> xpdrNetMaps, XpdrNodeTypes xponderType,
443 OduSwitchingPools oorOduSwitchingPool) {
444 Map<NodeKey, Node> nodeMap = new HashMap<>();
445 LOG.info("creation of a DSR/ODU node for {}", nodeId);
446 Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.DSR))
447 .getBytes(StandardCharsets.UTF_8)).toString());
448 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
449 String.join("+", nodeId, TapiStringConstants.DSR)).build();
450 Name nameNodeType = new NameBuilder().setValueName("Node Type")
451 .setValue(getNodeType(xponderType)).build();
452 Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU);
453 Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameNodeType.key(), nameNodeType),
454 dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool);
456 nodeMap.put(dsrNode.key(), dsrNode);
458 // node creation [otsi]
459 LOG.info("creation of an OTSi node for {}", nodeId);
460 Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.OTSI))
461 .getBytes(StandardCharsets.UTF_8)).toString());
462 Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue(
463 String.join("+", nodeId, TapiStringConstants.OTSI)).build();
464 Set<LayerProtocolName> otsiLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
465 Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi, nameNodeType.key(), nameNodeType),
466 otsiLayerProtocols, nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null);
468 nodeMap.put(otsiNode.key(), otsiNode);
470 // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
471 LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
472 Map<LinkKey, Link> linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps);
473 mergeLinkinTopology(linkMap);
478 private OduSwitchingPools createSwitchPoolForXpdr(int xpdrType, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
480 // todo: are switching pool correct here??
484 return createTpdrSwitchPool(xpdrNetMaps);
487 return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
490 return createSwtchSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb);
492 LOG.warn("Xpdr type {} not supported", xpdrType);
497 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformSrgToOnep(String orNodeId,
498 Map<String, List<Mapping>> mapSrg) {
499 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
500 for (Map.Entry<String, List<Mapping>> entry : mapSrg.entrySet()) {
501 // For each srg node. Loop through the LCPs and create neps and sips for PP
502 for (Mapping m:entry.getValue()) {
503 if (!m.getLogicalConnectionPoint().contains("PP")) {
504 LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint());
507 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> srgNeps =
508 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true,
509 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
510 onepMap.putAll(srgNeps);
516 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> transformDegToOnep(String orNodeId,
517 Map<String, List<Mapping>> mapDeg) {
518 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
519 for (Map.Entry<String, List<Mapping>> entry : mapDeg.entrySet()) {
520 // For each degree node. Loop through the LCPs and create neps and sips for TTP
521 for (Mapping m:entry.getValue()) {
522 if (!m.getLogicalConnectionPoint().contains("TTP")) {
523 LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint());
526 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> degNeps =
527 createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false,
528 transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState()));
529 onepMap.putAll(degNeps);
535 private List<String> getRoadmNodelist(List<Mapping> mappingList) {
536 List<String> nodeShardList = new ArrayList<>();
537 for (Mapping mapping : mappingList) {
538 // TODO -> maybe we need to check the id based on the version
539 String str = mapping.getLogicalConnectionPoint().split("-")[0];
540 LOG.info("LCP = {}", str);
541 if (!nodeShardList.contains(str)) {
542 nodeShardList.add(str);
545 return nodeShardList;
549 public void deleteTapinode(String nodeId) {
550 // TODO: check for null objects
551 // Check if it is ROADM or XPDR --> create the uuids of the node and delete from topology the node.
552 // This will delete NEPs. Then check for links that have this node and delete them.
553 // Then check SIPs and delete them. Then services and connections with SIPs and put them to another state.
554 LOG.info("Deleting node {} from TAPI topology", nodeId);
555 InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.builder(Context.class)
556 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
557 new TopologyKey(tapiTopoUuid)).build();
558 Topology topology = null;
560 Optional<Topology> optTopology =
561 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, topologyIID).get();
562 if (!optTopology.isPresent()) {
563 LOG.error("No topology object present. Error deleting node {}", nodeId);
566 topology = optTopology.orElseThrow();
567 } catch (InterruptedException | ExecutionException e) {
568 LOG.error("Couldnt read tapi topology from datastore", e);
570 if (topology == null) {
571 LOG.error("Topology is null, nothing to delete");
574 if (topology.getNode() == null) {
575 LOG.error("No nodes in topology");
578 if (nodeId.contains("ROADM")) {
579 // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA
580 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
581 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
582 deleteNodeFromTopo(nodeUuid);
584 if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) {
585 // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names
586 for (Node tapiNode:topology.getNode().values()) {
587 if (tapiNode.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
588 // Found node we need to delete
589 deleteNodeFromTopo(tapiNode.getUuid());
593 // Delete links of topology
594 Map<LinkKey, Link> linkMap = topology.getLink();
595 if (linkMap != null) {
596 for (Link link:linkMap.values()) {
597 if (link.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
598 deleteLinkFromTopo(link.getUuid());
602 // Delete sips of sip map
603 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
604 Context context = null;
606 Optional<Context> optContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
608 if (!optContext.isPresent()) {
609 LOG.error("No context object present in datastore.");
612 context = optContext.orElseThrow();
613 } catch (InterruptedException | ExecutionException e) {
614 LOG.error("Couldnt read tapi context from datastore", e);
616 if (context == null) {
617 LOG.error("Context is null, nothing to delete");
620 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips = context.getServiceInterfacePoint();
622 for (ServiceInterfacePoint sip:sips.values()) {
623 if (sip.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
624 // Update state of services that have this sip as an endpoint and also connections
625 updateConnectivityServicesState(sip.getUuid(), nodeId);
626 deleteSipFromTopo(sip.getUuid());
632 private Node createTapiXpdrNode(Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
633 String nodeId, Uuid nodeUuid, List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
634 XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) {
635 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
636 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
637 Map<RuleKey, Rule> ruleList = new HashMap<>();
638 Rule rule = new RuleBuilder()
639 .setLocalId("forward")
640 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
641 .setRuleType(RuleType.FORWARDING)
643 ruleList.put(rule.key(), rule);
644 if (layerProtocols.contains(LayerProtocolName.DSR)) {
645 // neps for dsr/odu layer
646 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> dsroduNeps =
647 createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType);
648 onepl.putAll(dsroduNeps);
649 nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl);
650 } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
651 // neps for photonic layer
652 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> phtmdNeps =
653 createXpdrPhtnMdNeps(nodeId, xpdrNetMaps);
654 onepl.putAll(phtmdNeps);
655 nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList);
657 LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next())
658 .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue());
660 // Empty random creation of mandatory fields for avoiding errors....
661 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
662 .setCostAlgorithm("Restricted Shortest Path - RSP")
663 .setCostName("HOP_COUNT")
664 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
666 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
667 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
668 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
669 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
670 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
671 .setTrafficPropertyName("FIXED_LATENCY")
673 return new NodeBuilder()
676 .setLayerProtocolName(layerProtocols)
677 .setAdministrativeState(AdministrativeState.UNLOCKED)
678 .setOperationalState(OperationalState.ENABLED)
679 .setLifecycleState(LifecycleState.INSTALLED)
680 .setOwnedNodeEdgePoint(onepl)
681 .setNodeRuleGroup(nodeRuleGroupList)
682 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
683 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
684 .setErrorCharacteristic("error")
685 .setLossCharacteristic("loss")
686 .setRepeatDeliveryCharacteristic("repeat delivery")
687 .setDeliveryOrderCharacteristic("delivery order")
688 .setUnavailableTimeCharacteristic("unavailable time")
689 .setServerIntegrityProcessCharacteristic("server integrity process")
693 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrPhtnMdNeps(String nodeId,
694 List<Mapping> xpdrNetMaps) {
695 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
697 // iNep creation on otsi node
698 for (int i = 0; i < xpdrNetMaps.size(); i++) {
699 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
700 (String.join("+", nodeId, TapiStringConstants.I_OTSI,
701 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
702 Name onedName = new NameBuilder()
703 .setValueName("iNodeEdgePoint")
704 .setValue(String.join("+", nodeId, TapiStringConstants.I_OTSI,
705 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
708 List<SupportedIfCapability> newSupIfCapList =
709 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
711 OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
712 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
713 true, String.join("+", nodeId, TapiStringConstants.I_OTSI), newSupIfCapList,
714 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
715 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
716 onepl.put(onep.key(), onep);
718 // eNep creation on otsi node
719 for (int i = 0; i < xpdrNetMaps.size(); i++) {
720 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
721 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
722 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
723 Name onedName = new NameBuilder()
724 .setValueName("eNodeEdgePoint")
725 .setValue(String.join("+", nodeId, TapiStringConstants.E_OTSI,
726 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
729 List<SupportedIfCapability> newSupIfCapList =
730 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
732 OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
733 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
734 false, String.join("+", nodeId, TapiStringConstants.E_OTSI), newSupIfCapList,
735 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
736 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
737 onepl.put(onep.key(), onep);
739 // Photonic Media Nep creation on otsi node
740 for (int i = 0; i < xpdrNetMaps.size(); i++) {
741 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
742 (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
743 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
744 Name onedName = new NameBuilder()
745 .setValueName("PhotMedNodeEdgePoint")
746 .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA,
747 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
750 List<SupportedIfCapability> newSupIfCapList =
751 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
753 OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
754 Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA,
755 false, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA), newSupIfCapList,
756 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
757 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
758 onepl.put(onep.key(), onep);
763 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createXpdrDsrOduNeps(String nodeId, List<Mapping> xpdrClMaps,
764 List<Mapping> xpdrNetMaps,
765 XpdrNodeTypes xponderType) {
766 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
767 // client nep creation on DSR node
768 for (int i = 0; i < xpdrClMaps.size(); i++) {
769 LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR,
770 xpdrClMaps.get(i).getLogicalConnectionPoint()));
771 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
772 (String.join("+", nodeId, TapiStringConstants.DSR,
773 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
774 NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId,
775 TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint()));
777 if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) {
778 name = nameBldr.setValueName("100G-tpdr").build();
780 name = nameBldr.setValueName("NodeEdgePoint_C").build();
783 List<SupportedIfCapability> newSupIfCapList =
784 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
786 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
787 Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true,
788 String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList,
789 transformOperState(xpdrClMaps.get(i).getPortOperState()),
790 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
791 onepl.put(onep.key(), onep);
793 // network nep creation on I_ODU node
794 for (int i = 0; i < xpdrNetMaps.size(); i++) {
795 LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU,
796 xpdrNetMaps.get(i).getLogicalConnectionPoint()));
797 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
798 (String.join("+", nodeId, TapiStringConstants.I_ODU,
799 xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
800 Name onedName = new NameBuilder()
801 .setValueName("iNodeEdgePoint_N")
802 .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU,
803 xpdrNetMaps.get(i).getLogicalConnectionPoint()))
806 List<SupportedIfCapability> newSupIfCapList =
807 new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability());
809 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(),
810 Map.of(onedName.key(), onedName),
811 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
812 String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList,
813 transformOperState(xpdrNetMaps.get(i).getPortOperState()),
814 transformAdminState(xpdrNetMaps.get(i).getPortAdminState()));
815 onepl.put(onep.key(), onep);
817 // network nep creation on E_ODU node
818 for (int i = 0; i < xpdrClMaps.size(); i++) {
819 LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU,
820 xpdrClMaps.get(i).getLogicalConnectionPoint()));
821 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
822 (String.join("+", nodeId, TapiStringConstants.E_ODU,
823 xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString());
824 Name onedName = new NameBuilder()
825 .setValueName("eNodeEdgePoint_N")
826 .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU,
827 xpdrClMaps.get(i).getLogicalConnectionPoint()))
830 List<SupportedIfCapability> newSupIfCapList =
831 new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability());
833 OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(),
834 Map.of(onedName.key(), onedName),
835 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
836 String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList,
837 transformOperState(xpdrClMaps.get(i).getPortOperState()),
838 transformAdminState(xpdrClMaps.get(i).getPortAdminState()));
839 onepl.put(onep.key(), onep);
844 private OperationalState transformOperState(String operString) {
845 State operState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils.setNetworkOperState(operString);
846 return operState.equals(State.InService) ? OperationalState.ENABLED : OperationalState.DISABLED;
849 private AdministrativeState transformAdminState(String adminString) {
850 AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils
851 .setNetworkAdminState(adminString);
852 return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
855 private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map<NameKey, Name> nepNames,
856 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
858 List<SupportedIfCapability> supportedInterfaceCapability,
859 OperationalState operState, AdministrativeState adminState) {
860 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
862 .setLayerProtocolName(nepProtocol)
865 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword,
866 supportedInterfaceCapability, operState, adminState));
868 LOG.debug("Node layer {}", nodeProtocol.getName());
869 onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(
870 supportedInterfaceCapability, nepProtocol));
871 onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
872 .setAdministrativeState(adminState).setOperationalState(operState)
873 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
874 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
875 return onepBldr.build();
878 private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createRoadmNeps(String orNodeId, String tpId,
879 boolean withSip, OperationalState operState,
880 AdministrativeState adminState) {
881 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
882 // PHOTONIC MEDIA nep
883 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
884 TapiStringConstants.PHTNC_MEDIA, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
885 Name nepName = new NameBuilder()
886 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
887 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA, tpId))
889 OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
891 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
892 .setName(Map.of(nepName.key(), nepName))
893 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
894 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
895 .setAdministrativeState(adminState).setOperationalState(operState)
896 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
897 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
899 onepMap.put(onep.key(), onep);
902 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
903 TapiStringConstants.MC, tpId)).getBytes(StandardCharsets.UTF_8)).toString());
904 Name nepName1 = new NameBuilder()
905 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
906 .setValue(String.join("+", orNodeId, TapiStringConstants.MC, tpId))
908 OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
910 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
911 .setName(Map.of(nepName1.key(), nepName1))
912 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
913 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
914 .setAdministrativeState(adminState).setOperationalState(operState)
915 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
916 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
918 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
919 tpId, String.join("+", orNodeId, TapiStringConstants.MC), null,
920 operState, adminState));
922 OwnedNodeEdgePoint onep1 = onepBldr1.build();
923 onepMap.put(onep1.key(), onep1);
926 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, TapiStringConstants.OTSI_MC,
927 tpId)).getBytes(StandardCharsets.UTF_8)).toString());
928 Name nepName2 = new NameBuilder()
929 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
930 .setValue(String.join("+", orNodeId, TapiStringConstants.OTSI_MC, tpId))
933 OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
935 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
936 .setName(Map.of(nepName2.key(), nepName2))
937 .setSupportedCepLayerProtocolQualifier(Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE))
938 .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
939 .setAdministrativeState(adminState).setOperationalState(operState)
940 .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
941 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
943 onepMap.put(onep2.key(), onep2);
947 private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint>
948 createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid,
949 List<SupportedIfCapability> supportedInterfaceCapability,
950 OperationalState operState, AdministrativeState adminState) {
951 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
952 for (int i = 0; i < nb; i++) {
953 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
954 tpid)).getBytes(StandardCharsets.UTF_8)).toString());
955 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
956 .setServiceInterfacePointUuid(sipUuid).build();
957 ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability,
958 operState, adminState);
959 this.sipMap.put(sip.key(), sip);
960 LOG.info("SIP created {}", sip.getUuid());
961 // this.tapiSips.put(sip.key(), sip);
962 msipl.put(msip.key(), msip);
967 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid,
968 List<SupportedIfCapability> supportedInterfaceCapability,
969 OperationalState operState, AdministrativeState adminState) {
970 // TODO: what value should be set in total capacity and available capacity
971 LOG.info("SIP name = {}", String.join("+", nodeid, tpid));
972 Name sipName = new NameBuilder()
973 .setValueName("SIP name")
974 .setValue(String.join("+", nodeid, tpid))
976 return new ServiceInterfacePointBuilder()
978 .setName(Map.of(sipName.key(), sipName))
979 .setLayerProtocolName(layerProtocol)
980 .setAdministrativeState(adminState)
981 .setOperationalState(operState)
982 .setLifecycleState(LifecycleState.INSTALLED)
983 .setAvailableCapacity(new AvailableCapacityBuilder().build())
984 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
985 .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability,
990 private Node createRoadmTapiNode(String orNodeId, Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
992 Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId,
993 TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString());
995 Name nodeNames = new NameBuilder().setValueName("roadm node name")
996 .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build();
997 Name nameNodeType = new NameBuilder().setValueName("Node Type")
998 .setValue(OpenroadmNodeType.ROADM.getName()).build();
1000 Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
1001 // Empty random creation of mandatory fields for avoiding errors....
1002 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1003 .setCostAlgorithm("Restricted Shortest Path - RSP")
1004 .setCostName("HOP_COUNT")
1005 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1007 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1008 .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE)
1009 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1010 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1011 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1012 .setTrafficPropertyName("FIXED_LATENCY")
1014 return new NodeBuilder()
1016 .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType))
1017 .setLayerProtocolName(layerProtocols)
1018 .setAdministrativeState(AdministrativeState.UNLOCKED)
1019 .setOperationalState(OperationalState.ENABLED)
1020 .setLifecycleState(LifecycleState.INSTALLED)
1021 .setOwnedNodeEdgePoint(oneplist)
1022 .setNodeRuleGroup(createNodeRuleGroupForRdmNode(orNodeId, nodeUuid, oneplist.values()))
1023 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1024 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1025 .setErrorCharacteristic("error")
1026 .setLossCharacteristic("loss")
1027 .setRepeatDeliveryCharacteristic("repeat delivery")
1028 .setDeliveryOrderCharacteristic("delivery order")
1029 .setUnavailableTimeCharacteristic("unavailable time")
1030 .setServerIntegrityProcessCharacteristic("server integrity process")
1034 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String orNodeId, Uuid nodeUuid,
1035 Collection<OwnedNodeEdgePoint> onepl) {
1036 Map<NodeEdgePointKey, NodeEdgePoint>
1037 nepMap = new HashMap<>();
1038 for (OwnedNodeEdgePoint onep : onepl) {
1039 NodeEdgePoint nep = new NodeEdgePointBuilder()
1040 .setTopologyUuid(this.tapiTopoUuid)
1041 .setNodeUuid(nodeUuid)
1042 .setNodeEdgePointUuid(onep.key().getUuid())
1044 nepMap.put(nep.key(), nep);
1046 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1047 Map<RuleKey, Rule> ruleList = new HashMap<>();
1048 Rule rule = new RuleBuilder()
1049 .setLocalId("forward")
1050 .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
1051 .setRuleType(RuleType.FORWARDING)
1053 ruleList.put(rule.key(), rule);
1054 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1055 .setUuid(new Uuid(UUID.nameUUIDFromBytes((orNodeId + " node rule group")
1056 .getBytes(StandardCharsets.UTF_8)).toString()))
1058 .setNodeEdgePoint(nepMap)
1060 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1061 return nodeRuleGroupMap;
1064 private Map<LinkKey, Link> createTapiTransitionalLinks(String nodeId, List<Mapping> xpdrNetMaps) {
1065 Map<LinkKey, Link> linkMap = new HashMap<>();
1066 for (Mapping mapping : xpdrNetMaps) {
1067 Link transiLink = tapiLink.createTapiLink(nodeId, mapping.getLogicalConnectionPoint(), nodeId,
1068 mapping.getLogicalConnectionPoint(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
1069 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
1070 "inService", "inService", Set.of(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA),
1071 Set.of(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
1073 linkMap.put(transiLink.key(), transiLink);
1075 // return a map of links and then we can do merge the corresponding link map into the topology context
1079 private OduSwitchingPools createTpdrSwitchPool(List<Mapping> xpdrNetMaps) {
1080 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
1082 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1083 LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1084 LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1085 TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint());
1086 TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp());
1087 Set<TpId> tpList = new HashSet<>();
1090 NonBlockingList nbl = new NonBlockingListBuilder()
1091 .setNblNumber(Uint16.valueOf(count))
1094 nblMap.put(nbl.key(), nbl);
1097 return new OduSwitchingPoolsBuilder()
1098 .setNonBlockingList(nblMap)
1099 .setSwitchingPoolNumber(Uint16.valueOf(1))
1103 private OduSwitchingPools createSwtchSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps,
1105 Set<TpId> tpl = new HashSet<>();
1107 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1108 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1111 for (int i = 1; i <= xpdrNetMaps.size(); i++) {
1112 tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i);
1115 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1116 NonBlockingList nbl = new NonBlockingListBuilder()
1117 .setNblNumber(Uint16.valueOf(1))
1120 nbMap.put(nbl.key(),nbl);
1122 return new OduSwitchingPoolsBuilder()
1123 .setSwitchingPoolNumber(Uint16.valueOf(1))
1124 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1125 .setNonBlockingList(nbMap)
1129 private OduSwitchingPools createMuxSwitchPool(List<Mapping> xpdrClMaps, List<Mapping> xpdrNetMaps, Integer xpdrNb) {
1130 Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
1131 for (int i = 1; i <= xpdrClMaps.size(); i++) {
1132 Set<TpId> tpList = new HashSet<>();
1133 TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i);
1135 tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1");
1137 NonBlockingList nbl = new NonBlockingListBuilder()
1138 .setNblNumber(Uint16.valueOf(i))
1140 .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L))
1141 .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000))
1143 nbMap.put(nbl.key(),nbl);
1145 return new OduSwitchingPoolsBuilder()
1146 .setSwitchingPoolNumber(Uint16.valueOf(1))
1147 .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking)
1148 .setNonBlockingList(nbMap)
1152 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForOtsiNode(String nodeId,
1153 List<Mapping> xpdrNetMaps,
1154 Map<RuleKey, Rule> ruleList) {
1155 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1156 // create NodeRuleGroup
1158 for (Mapping tpMapping : xpdrNetMaps) {
1159 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1160 NodeEdgePoint inep = new NodeEdgePointBuilder()
1161 .setTopologyUuid(this.tapiTopoUuid)
1162 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1163 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1164 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1165 TapiStringConstants.I_OTSI, tpMapping.getLogicalConnectionPoint()))
1166 .getBytes(StandardCharsets.UTF_8)).toString()))
1168 NodeEdgePoint enep = new NodeEdgePointBuilder()
1169 .setTopologyUuid(this.tapiTopoUuid)
1170 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1171 TapiStringConstants.OTSI)).getBytes(StandardCharsets.UTF_8)).toString()))
1172 .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
1173 (String.join("+", nodeId, TapiStringConstants.E_OTSI,
1174 tpMapping.getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()))
1176 nepList.put(inep.key(), inep);
1177 nepList.put(enep.key(), enep);
1178 // Empty random creation of mandatory fields for avoiding errors....
1179 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1180 .setCostAlgorithm("Restricted Shortest Path - RSP")
1181 .setCostName("HOP_COUNT")
1182 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1184 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1185 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1186 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1187 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1188 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1189 .setTrafficPropertyName("FIXED_LATENCY")
1191 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1192 .setRiskCharacteristicName("risk characteristic")
1193 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1195 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1197 UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(StandardCharsets.UTF_8))
1200 .setNodeEdgePoint(nepList)
1201 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1202 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1203 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1205 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1208 return nodeRuleGroupMap;
1211 private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForDsrNode(String nodeId,
1212 OduSwitchingPools oorOduSwitchingPool,
1213 Map<RuleKey, Rule> ruleList,
1214 Map<OwnedNodeEdgePointKey,
1215 OwnedNodeEdgePoint> onepl) {
1216 // create NodeRuleGroup
1217 if (oorOduSwitchingPool == null) {
1218 LOG.info("No switching pool created for node = {}", nodeId);
1219 return new HashMap<>();
1221 LOG.info("ONEPL = {}", onepl.values());
1222 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
1224 for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1225 LOG.info("Non blocking list = {}", nbl);
1226 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1227 for (TpId tp : nbl.getTpList()) {
1228 LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue()));
1229 LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue()));
1230 Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1231 TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1232 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId,
1233 TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString());
1234 if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid))
1235 && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) {
1236 NodeEdgePoint nep1 = new NodeEdgePointBuilder()
1237 .setTopologyUuid(this.tapiTopoUuid)
1238 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1239 (String.join("+", nodeId,TapiStringConstants. DSR))
1240 .getBytes(StandardCharsets.UTF_8)).toString()))
1241 .setNodeEdgePointUuid(tp1Uuid)
1243 NodeEdgePoint nep2 = new NodeEdgePointBuilder()
1244 .setTopologyUuid(this.tapiTopoUuid)
1245 .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
1246 (String.join("+", nodeId,TapiStringConstants. DSR))
1247 .getBytes(StandardCharsets.UTF_8)).toString()))
1248 .setNodeEdgePointUuid(tpUuid)
1250 nepList.put(nep1.key(), nep1);
1251 nepList.put(nep2.key(), nep2);
1254 // Empty random creation of mandatory fields for avoiding errors....
1255 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1256 .setCostAlgorithm("Restricted Shortest Path - RSP")
1257 .setCostName("HOP_COUNT")
1258 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1260 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1261 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1262 .setQueingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1263 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1264 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1265 .setTrafficPropertyName("FIXED_LATENCY")
1267 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1268 .setRiskCharacteristicName("risk characteristic")
1269 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1271 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
1273 UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8))
1276 .setNodeEdgePoint(nepList)
1277 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1278 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1279 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1281 nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
1284 return nodeRuleGroupMap;
1287 private Set<LAYERPROTOCOLQUALIFIER> createSupportedLayerProtocolQualifier(
1288 List<SupportedIfCapability> sicList, LayerProtocolName lpn) {
1289 if (sicList == null) {
1290 return Set.of(PHOTONICLAYERQUALIFIEROMS.VALUE);
1292 Map<SupportedInterfaceCapabilityKey, SupportedInterfaceCapability> supIfMap = new HashMap<>();
1293 LOG.info("SIC list = {}", sicList);
1294 for (SupportedIfCapability supInterCapa : sicList) {
1295 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
1296 .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa.toString())))
1297 .setIfCapType(convertSupIfCapa(supInterCapa.toString()))
1299 supIfMap.put(supIfCapa.key(), supIfCapa);
1301 Set<LAYERPROTOCOLQUALIFIER> sclpqList = new HashSet<>();
1302 for (SupportedInterfaceCapability sic : supIfMap.values()) {
1303 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1304 switch (lpn.getName()) {
1306 switch (ifCapType) {
1307 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1308 // port are extended in the config file
1310 sclpqList.add(ODUTYPEODU0.VALUE);
1311 sclpqList.add(DIGITALSIGNALTYPEGigE.VALUE);
1314 sclpqList.add(ODUTYPEODU2E.VALUE);
1315 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1318 sclpqList.add(ODUTYPEODU2.VALUE);
1319 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1322 sclpqList.add(DIGITALSIGNALTYPE10GigELAN.VALUE);
1325 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1326 sclpqList.add(ODUTYPEODU4.VALUE);
1329 sclpqList.add(DIGITALSIGNALTYPE100GigE.VALUE);
1331 case "IfOCHOTU4ODU4":
1333 sclpqList.add(ODUTYPEODU4.VALUE);
1336 LOG.error("IfCapability type not managed");
1341 switch (ifCapType) {
1342 // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1343 // port are extended in the config file
1345 sclpqList.add(ODUTYPEODU0.VALUE);
1348 sclpqList.add(ODUTYPEODU2E.VALUE);
1352 sclpqList.add(ODUTYPEODU2.VALUE);
1356 case "IfOCHOTU4ODU4":
1358 sclpqList.add(ODUTYPEODU4.VALUE);
1361 LOG.error("IfCapability type not managed");
1365 case "PHOTONIC_MEDIA":
1366 if (ifCapType.equals("IfOCHOTU4ODU4") || ifCapType.equals("IfOCH")) {
1367 sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.VALUE);
1368 sclpqList.add(PHOTONICLAYERQUALIFIEROMS.VALUE);
1372 LOG.error("Layer Protocol Name is unknown {}", lpn.getName());
1379 private String getNodeType(XpdrNodeTypes xponderType) {
1380 switch (xponderType.getIntValue()) {
1382 return OpenroadmNodeType.TPDR.getName();
1384 return OpenroadmNodeType.MUXPDR.getName();
1386 return OpenroadmNodeType.SWITCH.getName();
1388 LOG.info("XpdrType {} not supported", xponderType);
1394 private void mergeNodeinTopology(Map<NodeKey, Node> nodeMap) {
1395 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1396 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1397 LOG.info("Creating tapi node in TAPI topology context");
1398 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1399 .augmentation(Context1.class).child(TopologyContext.class)
1400 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1403 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build();
1405 // merge in datastore
1406 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1409 this.networkTransactionService.commit().get();
1410 } catch (InterruptedException | ExecutionException e) {
1411 LOG.error("Error populating TAPI topology: ", e);
1413 LOG.info("Node added succesfully.");
1416 private void mergeLinkinTopology(Map<LinkKey, Link> linkMap) {
1417 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1418 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1419 LOG.info("Creating tapi node in TAPI topology context");
1420 InstanceIdentifier<Topology> topoIID = InstanceIdentifier.builder(Context.class)
1421 .augmentation(Context1.class).child(TopologyContext.class)
1422 .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
1425 Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build();
1427 // merge in datastore
1428 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID,
1431 this.networkTransactionService.commit().get();
1432 } catch (InterruptedException | ExecutionException e) {
1433 LOG.error("Error populating TAPI topology: ", e);
1435 LOG.info("Roadm Link added succesfully.");
1438 private void mergeSipsinContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips) {
1439 // TODO is this merge correct? Should we just merge topology by changing the nodes map??
1440 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
1442 ContextBuilder contextBuilder = new ContextBuilder();
1443 contextBuilder.setServiceInterfacePoint(sips);
1444 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
1445 // merge in datastore
1446 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
1447 contextBuilder.build());
1448 this.networkTransactionService.commit().get();
1449 LOG.info("TAPI SIPs merged successfully.");
1450 } catch (InterruptedException | ExecutionException e) {
1451 LOG.error("Failed to merge TAPI Sips", e);
1455 private void deleteLinkFromTopo(Uuid linkUuid) {
1456 // TODO: check if this IID is correct
1458 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
1459 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1460 new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build();
1461 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID);
1462 this.networkTransactionService.commit().get();
1463 LOG.info("TAPI link deleted successfully.");
1464 } catch (InterruptedException | ExecutionException e) {
1465 LOG.error("Failed to delete TAPI link", e);
1469 private void deleteNodeFromTopo(Uuid nodeUuid) {
1470 // TODO: check if this IID is correct
1472 InstanceIdentifier<Node> nodeIDD = InstanceIdentifier.builder(Context.class)
1473 .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class,
1474 new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build();
1475 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD);
1476 this.networkTransactionService.commit().get();
1477 LOG.info("TAPI Node deleted successfully.");
1478 } catch (InterruptedException | ExecutionException e) {
1479 LOG.error("Failed to delete TAPI Node", e);
1483 private void deleteSipFromTopo(Uuid sipUuid) {
1484 // TODO: check if this IID is correct
1486 InstanceIdentifier<ServiceInterfacePoint> sipIID = InstanceIdentifier.builder(Context.class)
1487 .child(ServiceInterfacePoint.class, new ServiceInterfacePointKey(sipUuid)).build();
1488 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, sipIID);
1489 this.networkTransactionService.commit().get();
1490 LOG.info("TAPI SIP deleted successfully.");
1491 } catch (InterruptedException | ExecutionException e) {
1492 LOG.error("Failed to delete TAPI SIP", e);
1496 private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) {
1497 // TODO: check if this IID is correct
1498 InstanceIdentifier<ConnectivityContext> connectivitycontextIID = InstanceIdentifier.builder(Context.class)
1499 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1500 .child(ConnectivityContext.class)
1502 ConnectivityContext connContext = null;
1504 Optional<ConnectivityContext> optConnContext =
1505 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID)
1507 if (!optConnContext.isPresent()) {
1508 LOG.error("Couldnt retrieve connectivity context from datastore");
1511 connContext = optConnContext.orElseThrow();
1512 } catch (InterruptedException | ExecutionException e) {
1513 LOG.error("Couldnt read connectivity context from datastore", e);
1515 if (connContext == null) {
1516 LOG.error("Connectivity context is empty");
1519 // Loop through services, check if the endpoint uuid is equal to the sip.
1520 // If so update state.
1521 Map<ConnectivityServiceKey, ConnectivityService> connServMap = connContext.getConnectivityService();
1522 Map<ConnectionKey, Connection> connMap = connContext.getConnection();
1523 if (connServMap != null) {
1524 for (ConnectivityService service:connServMap.values()) {
1525 Map<EndPointKey, EndPoint> serviceEndPoints = service.getEndPoint();
1526 if (serviceEndPoints.values().stream().anyMatch(endPoint -> endPoint.getServiceInterfacePoint()
1527 .getServiceInterfacePointUuid().equals(sipUuid))) {
1528 LOG.info("Service using SIP of node {} identified. Update state of service", nodeId);
1529 ConnectivityService updService = new ConnectivityServiceBuilder(service)
1530 .setAdministrativeState(AdministrativeState.LOCKED)
1531 .setOperationalState(OperationalState.DISABLED)
1532 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1534 updateConnectivityService(updService);
1538 // Update state of connections
1539 if (connMap != null) {
1540 for (Connection connection:connMap.values()) {
1541 if (connection.getName().values().stream().anyMatch(name -> name.getValue().contains(nodeId))) {
1542 Connection updConn = new ConnectionBuilder(connection)
1543 .setLifecycleState(LifecycleState.PENDINGREMOVAL)
1544 .setOperationalState(OperationalState.DISABLED)
1546 updateConnection(updConn);
1552 private void updateConnection(Connection updConn) {
1553 // TODO: check if this IID is correct
1554 InstanceIdentifier<Connection> connectionIID = InstanceIdentifier.builder(Context.class)
1555 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1556 .child(ConnectivityContext.class).child(Connection.class,
1557 new ConnectionKey(updConn.getUuid())).build();
1558 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn);
1560 this.networkTransactionService.commit().get();
1561 } catch (InterruptedException | ExecutionException e) {
1562 LOG.error("Error committing into datastore", e);
1566 private void updateConnectivityService(ConnectivityService updService) {
1567 // TODO: check if this IID is correct
1568 InstanceIdentifier<ConnectivityService> connectivityserviceIID = InstanceIdentifier.builder(Context.class)
1569 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class)
1570 .child(ConnectivityContext.class).child(ConnectivityService.class,
1571 new ConnectivityServiceKey(updService.getUuid())).build();
1572 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService);
1574 this.networkTransactionService.commit().get();
1575 } catch (InterruptedException | ExecutionException e) {
1576 LOG.error("Error committing into datastore", e);
1580 private static org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability
1581 convertSupIfCapa(String ifCapType) {
1582 ImmutableMap<String, org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability>
1583 capTypeMap = ImmutableMap.<String,
1584 org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability>builder()
1585 .put("If400GE{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-400GE}", If400GE.VALUE)
1586 .put("IfOTU4ODU4{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-OTU4-ODU4}",
1588 .put("IfOtsiOtsigroup{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-otsi-otsigroup}",
1589 IfOtsiOtsigroup.VALUE)
1590 .put("IfOCH{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-OCH}", IfOCH.VALUE)
1591 .put("IfOCHOTU4ODU4{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-OCH-OTU4-ODU4}",
1592 IfOCHOTU4ODU4.VALUE)
1593 .put("If1GEODU0{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-1GE-ODU0}",
1595 .put("If10GE{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-10GE}", If10GE.VALUE)
1596 .put("If10GEODU2{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-10GE-ODU2}",
1598 .put("If10GEODU2e{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-10GE-ODU2e}",
1600 .put("If100GE{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-100GE}", If100GE.VALUE)
1601 .put("If100GEODU4{qname=(http://org/openroadm/port/types?revision=2023-05-26)if-100GE-ODU4}",
1604 if (!capTypeMap.containsKey(ifCapType)) {
1605 LOG.error("supported-if-capability {} not supported", ifCapType);
1608 return capTypeMap.get(ifCapType);