2 * Copyright © 2017 AT&T 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
9 package org.opendaylight.transportpce.olm.service;
11 import com.google.common.base.Strings;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.math.BigDecimal;
14 import java.math.RoundingMode;
15 import java.util.ArrayList;
16 import java.util.Collections;
17 import java.util.HashMap;
18 import java.util.List;
20 import java.util.Map.Entry;
21 import java.util.Optional;
23 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.Future;
25 import java.util.concurrent.TimeUnit;
26 import java.util.concurrent.TimeoutException;
27 import java.util.stream.Collectors;
28 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
29 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
30 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
31 import org.opendaylight.transportpce.common.InstanceIdentifiers;
32 import org.opendaylight.transportpce.common.NetworkUtils;
33 import org.opendaylight.transportpce.common.Timeouts;
34 import org.opendaylight.transportpce.common.device.DeviceTransaction;
35 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
36 import org.opendaylight.transportpce.common.mapping.PortMapping;
37 import org.opendaylight.transportpce.olm.power.PowerMgmt;
38 import org.opendaylight.transportpce.olm.util.OlmUtils;
39 import org.opendaylight.transportpce.olm.util.OtsPmHolder;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseInput;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutput;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutputBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentInput;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentOutput;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentOutputBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutput;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetInput;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetOutput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutput;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownInput;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutput;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.calculate.spanloss.base.output.Spans;
59 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.calculate.spanloss.base.output.SpansBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
61 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev170228.network.nodes.Mapping;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RatioDB;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.Link1;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev170929.OpenroadmLinkType;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.Interface1;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.Interface1Builder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.Ots;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
75 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.get.pm.input.ResourceIdentifierBuilder;
76 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.Network;
77 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NetworkId;
78 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NetworkKey;
79 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NodeId;
80 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.Node;
81 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.NodeKey;
82 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.node.SupportingNode;
83 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.LinkId;
84 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.Network1;
85 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.network.Link;
86 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
87 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
88 import org.slf4j.Logger;
89 import org.slf4j.LoggerFactory;
91 public class OlmPowerServiceImpl implements OlmPowerService {
92 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceImpl.class);
93 private static final String SUCCESS = "Success";
94 private static final String FAILED = "Failed";
95 private final DataBroker dataBroker;
96 private final PowerMgmt powerMgmt;
97 private final DeviceTransactionManager deviceTransactionManager;
98 private final PortMapping portMapping;
100 public OlmPowerServiceImpl(DataBroker dataBroker, PowerMgmt powerMgmt,
101 DeviceTransactionManager deviceTransactionManager, PortMapping portMapping) {
102 this.dataBroker = dataBroker;
103 this.powerMgmt = powerMgmt;
104 this.portMapping = portMapping;
105 this.deviceTransactionManager = deviceTransactionManager;
109 LOG.info("init ...");
112 public void close() {
113 LOG.info("close ...");
118 public GetPmOutput getPm(GetPmInput pmInput) {
119 GetPmOutputBuilder pmOutputBuilder = OlmUtils.pmFetch(pmInput, this.deviceTransactionManager);
120 return pmOutputBuilder.build();
124 public ServicePowerSetupOutput servicePowerSetup(ServicePowerSetupInput powerSetupInput) {
125 ServicePowerSetupOutputBuilder powerSetupOutput = new ServicePowerSetupOutputBuilder();
126 boolean successValPowerCalculation = this.powerMgmt.setPower(powerSetupInput);
128 if (successValPowerCalculation) {
129 powerSetupOutput.setResult(SUCCESS);
131 powerSetupOutput.setResult(FAILED);
133 return powerSetupOutput.build();
137 public ServicePowerTurndownOutput servicePowerTurndown(
138 ServicePowerTurndownInput powerTurndownInput) {
140 ServicePowerTurndownOutputBuilder powerTurnDownOutput = new ServicePowerTurndownOutputBuilder();
141 // TODO add flag or return failure instead of string
142 if (this.powerMgmt.powerTurnDown(powerTurndownInput)) {
143 powerTurnDownOutput.setResult(SUCCESS);
145 powerTurnDownOutput.setResult(FAILED);
147 return powerTurnDownOutput.build();
151 public CalculateSpanlossBaseOutput calculateSpanlossBase(CalculateSpanlossBaseInput spanlossBaseInput) {
153 LOG.info("CalculateSpanlossBase Request received for source type {}", spanlossBaseInput.getSrcType());
154 List<Link> networkLinks = getNetworkLinks();
155 if (networkLinks.isEmpty()) {
156 LOG.warn("Failed to get links form {} topology.", NetworkUtils.OVERLAY_NETWORK_ID);
157 return new CalculateSpanlossBaseOutputBuilder().setResult(FAILED).build();
160 if (! CalculateSpanlossBaseInput.SrcType.All.equals(spanlossBaseInput.getSrcType())) {
161 networkLinks = networkLinks.stream()
162 .filter(link -> link.getLinkId().equals(spanlossBaseInput.getLinkId()))
163 .collect(Collectors.toList());
166 List<Link> roadmLinks = new ArrayList<>();
167 for (Link link : networkLinks) {
168 Link1 roadmLinkAugmentation = link.augmentation(Link1.class);
169 if (roadmLinkAugmentation == null) {
170 LOG.debug("Missing OpenRoadm link augmentation in link {} from {} topology.",
171 link.getLinkId().getValue(), NetworkUtils.OVERLAY_NETWORK_ID);
174 if (OpenroadmLinkType.ROADMTOROADM.equals(roadmLinkAugmentation.getLinkType())) {
175 // Only calculate spanloss for Roadm-to-Roadm links
176 roadmLinks.add(link);
180 if (roadmLinks.isEmpty()) {
181 LOG.warn("Topology {} does not have any Roadm-to-Roadm links.", NetworkUtils.OVERLAY_NETWORK_ID);
182 return new CalculateSpanlossBaseOutputBuilder().setResult(FAILED).build();
185 Map<LinkId, BigDecimal> spanLossResult = getLinkSpanloss(roadmLinks);
186 CalculateSpanlossBaseOutputBuilder spanLossBaseBuilder = new CalculateSpanlossBaseOutputBuilder();
188 if (spanLossResult != null && !spanLossResult.isEmpty()) {
189 spanLossBaseBuilder.setResult(SUCCESS);
190 List<Spans> listSpans = new ArrayList<>();
191 Set<Entry<LinkId, BigDecimal>> spanLossResultSet = spanLossResult.entrySet();
192 for (Entry<LinkId, BigDecimal> entry : spanLossResultSet) {
193 Spans span = new SpansBuilder().setLinkId(entry.getKey()).setSpanloss(entry.getValue().toString())
197 spanLossBaseBuilder.setSpans(listSpans);
198 return spanLossBaseBuilder.build();
200 LOG.warn("Spanloss calculation failed");
201 spanLossBaseBuilder.setResult(FAILED);
202 return spanLossBaseBuilder.build();
208 public CalculateSpanlossCurrentOutput calculateSpanlossCurrent(CalculateSpanlossCurrentInput input) {
209 LOG.info("calculateSpanlossCurrent Request received for all links in network model.");
210 List<Link> networkLinks = getNetworkLinks();
211 if (networkLinks.isEmpty()) {
212 LOG.warn("Failed to get links form {} topology.", NetworkUtils.OVERLAY_NETWORK_ID);
215 List<Link> roadmLinks = new ArrayList<>();
216 for (Link link : networkLinks) {
217 Link1 roadmLinkAugmentation = link.augmentation(Link1.class);
218 if (roadmLinkAugmentation == null) {
219 LOG.debug("Missing OpenRoadm link augmentation in link {} from {} topology.",
220 link.getLinkId().getValue(), NetworkUtils.OVERLAY_NETWORK_ID);
223 if (OpenroadmLinkType.ROADMTOROADM.equals(roadmLinkAugmentation.getLinkType())) {
224 // Only calculate spanloss for Roadm-to-Roadm links
225 roadmLinks.add(link);
229 if (roadmLinks.isEmpty()) {
230 LOG.warn("Topology {} does not have any Roadm-to-Roadm links.", NetworkUtils.OVERLAY_NETWORK_ID);
234 Map<LinkId, BigDecimal> spanLossResult = getLinkSpanloss(roadmLinks);
235 CalculateSpanlossCurrentOutputBuilder spanLossCurrentBuilder = new CalculateSpanlossCurrentOutputBuilder();
236 if (spanLossResult != null && !spanLossResult.isEmpty()) {
237 spanLossCurrentBuilder.setResult(SUCCESS);
238 return spanLossCurrentBuilder.build();
240 LOG.error("Spanloss Current calculation failed");
241 spanLossCurrentBuilder.setResult(FAILED);
242 return spanLossCurrentBuilder.build();
247 public ServicePowerResetOutput servicePowerReset(ServicePowerResetInput input) {
252 private List<Link> getNetworkLinks() {
253 NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
255 InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Network.class, overlayTopologyKey)
256 .augmentation(Network1.class)
258 Optional<Network1> networkOptional;
259 try (ReadOnlyTransaction rtx = this.dataBroker.newReadOnlyTransaction()) {
260 //TODO change to constant from Timeouts class when it will be merged.
261 networkOptional = rtx.read(LogicalDatastoreType.CONFIGURATION, networkIID).get(Timeouts.DATASTORE_READ,
262 TimeUnit.MILLISECONDS).toJavaUtil();
263 } catch (InterruptedException | ExecutionException | TimeoutException e) {
264 LOG.warn("Read of {} topology failed", NetworkUtils.OVERLAY_NETWORK_ID);
265 return Collections.emptyList();
268 if (! networkOptional.isPresent()) {
269 LOG.warn("Network augmentation with links data is not present in {} topology.",
270 NetworkUtils.OVERLAY_NETWORK_ID);
271 return Collections.emptyList();
274 List<Link> networkLinks = networkOptional.get().getLink();
275 if ((networkLinks == null) || networkLinks.isEmpty()) {
276 LOG.warn("Links are not present in {} topology.", NetworkUtils.OVERLAY_NETWORK_ID);
277 return Collections.emptyList();
283 * This method retrieves OTS PM from current PM list by nodeId and TPId: Steps:
286 * 1. Get OTS interface name from port mapping by TPId 2. Call getPm RPC to get OTS PM
290 * @param nodeId Node-id of the NE.
291 * @param tpID Termination point Name.
292 * @param pmName PM name which need to be retrieved
293 * @return reference to OtsPmHolder
295 private OtsPmHolder getPmMeasurements(String nodeId, String tpID, String pmName) {
296 String realNodeId = getRealNodeId(nodeId);
297 Mapping mapping = this.portMapping.getMapping(realNodeId, tpID);
298 if (mapping == null) {
301 GetPmInput getPmInput = new GetPmInputBuilder().setNodeId(realNodeId)
302 .setResourceType(ResourceTypeEnum.Interface).setGranularity(PmGranularity._15min)
303 .setResourceIdentifier(
304 new ResourceIdentifierBuilder().setResourceName(mapping.getSupportingOts()).build())
306 GetPmOutput otsPmOutput = getPm(getPmInput);
308 if (otsPmOutput == null) {
309 LOG.info("OTS PM not found for NodeId: {} TP Id:{} PMName:{}", realNodeId, tpID, pmName);
313 for (Measurements measurement : otsPmOutput.getMeasurements()) {
314 if (pmName.equals(measurement.getPmparameterName())) {
315 return new OtsPmHolder(pmName, Double.parseDouble(measurement.getPmparameterValue()),
316 mapping.getSupportingOts());
319 } catch (NumberFormatException e) {
320 LOG.warn("Unable to get PM for NodeId: {} TP Id:{} PMName:{}", realNodeId, tpID, pmName, e);
326 * This method Sets Spanloss on A-End and Z-End OTS interface: Steps:
329 * 1. Read existing interface details
334 * @param nodeId nodeId of NE on which spanloss need to be updated
335 * @param interfaceName OTS interface for NE on which spanloss is cacluated
336 * @param spanLoss calculated spanloss value
337 * @param direction for which spanloss is calculated.It can be either Tx or Rx
340 private boolean setSpanLoss(String nodeId, String interfaceName, BigDecimal spanLoss, String direction) {
341 String realNodeId = getRealNodeId(nodeId);
342 LOG.info("Setting Spanloss in device for {}, InterfaceName: {}", realNodeId, interfaceName);
345 LOG.info("Setting 'span-loss-transmit' in device: {}, Interface: {}", realNodeId, interfaceName);
348 LOG.info("Setting 'span-loss-receive' in device: {}, Interface: {}", realNodeId, interfaceName);
351 LOG.error("Impossible to set spanloss in device: {}, Interface: {}", realNodeId, interfaceName);
354 InstanceIdentifier<Interface> interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
355 .child(Interface.class, new InterfaceKey(interfaceName));
356 com.google.common.base.Optional<Interface> interfaceObject;
358 Future<Optional<DeviceTransaction>> deviceTxFuture =
359 this.deviceTransactionManager.getDeviceTransaction(realNodeId);
360 java.util.Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
361 DeviceTransaction deviceTx;
362 if (deviceTxOpt.isPresent()) {
363 deviceTx = deviceTxOpt.get();
365 LOG.error("Device transaction for device {} was not found!", nodeId);
368 interfaceObject = deviceTx.read(LogicalDatastoreType.CONFIGURATION, interfacesIID).get();
369 BigDecimal initialSpanloss = new BigDecimal(0);
370 RatioDB spanLossRx = new RatioDB(initialSpanloss);
371 RatioDB spanLossTx = new RatioDB(initialSpanloss);
372 if (interfaceObject.isPresent()) {
373 Interface intf = interfaceObject.get();
374 InterfaceBuilder interfaceBuilder = new InterfaceBuilder(intf);
375 OtsBuilder otsBuilder = new OtsBuilder();
376 if ((intf.augmentation(Interface1.class) != null)
377 && (intf.augmentation(Interface1.class).getOts() != null)) {
378 Ots ots = intf.augmentation(Interface1.class).getOts();
379 otsBuilder.setFiberType(ots.getFiberType());
380 spanLossRx = ots.getSpanLossReceive();
381 spanLossTx = ots.getSpanLossTransmit();
383 spanLossRx = new RatioDB(spanLoss);
384 spanLossTx = new RatioDB(spanLoss);
386 Interface1Builder intf1Builder = new Interface1Builder();
387 if (direction.equals("TX")) {
388 otsBuilder.setSpanLossTransmit(new RatioDB(spanLoss));
389 otsBuilder.setSpanLossReceive(spanLossRx);
391 otsBuilder.setSpanLossTransmit(spanLossTx).setSpanLossReceive(new RatioDB(spanLoss));
393 interfaceBuilder.addAugmentation(Interface1.class, intf1Builder.setOts(otsBuilder.build()).build());
394 deviceTx.put(LogicalDatastoreType.CONFIGURATION, interfacesIID, interfaceBuilder.build());
395 ListenableFuture<Void> submit =
396 deviceTx.submit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT);
398 LOG.info("Spanloss Value update completed successfully");
401 } catch (InterruptedException | ExecutionException e) {
402 LOG.warn("Unable to set spanloss", e);
408 * This method calculates Spanloss by TranmistPower - Receive Power Steps:
411 * 1. Read PM measurement
414 * 2. Set Spanloss value for interface
417 * reference to list of RoadmLinks
418 * @return map with list of spans with their spanloss value
420 private Map<LinkId, BigDecimal> getLinkSpanloss(List<Link> roadmLinks) {
421 Map<LinkId, BigDecimal> map = new HashMap<LinkId, BigDecimal>();
422 LOG.info("Executing GetLinkSpanLoss");
423 BigDecimal spanLoss = new BigDecimal(0);
424 for (Link link : roadmLinks) {
425 String sourceNodeId = link.getSource().getSourceNode().getValue();
426 String sourceTpId = link.getSource().getSourceTp().toString();
427 String destNodeId = link.getDestination().getDestNode().getValue();
428 String destTpId = link.getDestination().getDestTp().toString();
429 OtsPmHolder srcOtsPmHoler = getPmMeasurements(sourceNodeId, sourceTpId, "OpticalPowerOutput");
430 OtsPmHolder destOtsPmHoler = getPmMeasurements(destNodeId, destTpId, "OpticalPowerInput");
431 spanLoss = new BigDecimal(srcOtsPmHoler.getOtsParameterVal() - destOtsPmHoler.getOtsParameterVal())
432 .setScale(0, RoundingMode.HALF_UP);
433 LOG.info("Spanloss Calculated as :" + spanLoss + "=" + srcOtsPmHoler.getOtsParameterVal() + "-"
434 + destOtsPmHoler.getOtsParameterVal());
435 if ((spanLoss.doubleValue() < 28) && (spanLoss.doubleValue() > 0)) {
436 if (!setSpanLoss(sourceNodeId, srcOtsPmHoler.getOtsInterfaceName(), spanLoss, "TX")) {
437 LOG.info("Setting spanLoss failed for " + sourceNodeId);
440 if (!setSpanLoss(destNodeId, destOtsPmHoler.getOtsInterfaceName(), spanLoss, "RX")) {
441 LOG.info("Setting spanLoss failed for " + destNodeId);
444 map.put(link.getLinkId(), spanLoss);
450 private String getRealNodeId(String mappedNodeId) {
451 KeyedInstanceIdentifier<Node, NodeKey> mappedNodeII =
452 InstanceIdentifiers.OVERLAY_NETWORK_II.child(Node.class, new NodeKey(new NodeId(mappedNodeId)));
453 com.google.common.base.Optional<Node> realNode;
454 try (ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction()) {
455 realNode = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, mappedNodeII).get();
456 } catch (InterruptedException | ExecutionException e) {
457 LOG.error(e.getMessage(), e);
458 throw new IllegalStateException(e);
460 if (!realNode.isPresent() || (realNode.get().getSupportingNode() == null)) {
461 throw new IllegalArgumentException(
462 String.format("Could not find node %s, or supporting node is not present", mappedNodeId));
464 List<SupportingNode> collect = realNode.get().getSupportingNode().stream()
465 .filter(node -> (node.getNetworkRef() != null)
466 && NetworkUtils.UNDERLAY_NETWORK_ID.equals(node.getNetworkRef().getValue())
467 && (node.getNodeRef() != null) && !Strings.isNullOrEmpty(node.getNodeRef().getValue()))
468 .collect(Collectors.toList());
469 if (collect.isEmpty() || (collect.size() > 1)) {
470 throw new IllegalArgumentException(String.format("Invalid support node count [%d] was found for node %s",
471 collect.size(), mappedNodeId));
473 return collect.iterator().next().getNodeRef().getValue();