Bug 9048: Vpp node reconnect bug in oxygen
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / manager / VppNodeManager.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.groupbasedpolicy.renderer.vpp.manager;
10
11 import static org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus.Connected;
12 import static org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus.Connecting;
13 import static org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus.UnableToConnect;
14
15 import java.util.ArrayList;
16 import java.util.Arrays;
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Objects;
21 import java.util.stream.Collectors;
22
23 import javax.annotation.Nonnull;
24 import javax.annotation.Nullable;
25
26 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
27 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
28 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
29 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
30 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
31 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
32 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
33 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
34 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
35 import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.HostRelatedInfoContainer;
36 import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.states.PhysicalInterfaces;
37 import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.NatUtil;
38 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProvider;
39 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
40 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppRendererProcessingException;
41 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.RendererNodes;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.nodes.RendererNode;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.nodes.RendererNodeBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.nodes.RendererNodeKey;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.VppInterfaceAugmentation;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.VppInterfaceAugmentationBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.renderers.renderer.renderer.nodes.renderer.node.PhysicalInterface;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.renderers.renderer.renderer.nodes.renderer.node.PhysicalInterfaceBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.renderers.renderer.renderer.nodes.renderer.node.PhysicalInterfaceKey;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
59 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
60 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
61 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
62 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
63 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
64 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
65 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
66 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
67 import org.slf4j.Logger;
68 import org.slf4j.LoggerFactory;
69
70 import com.google.common.base.Optional;
71 import com.google.common.base.Preconditions;
72 import com.google.common.base.Splitter;
73 import com.google.common.base.Strings;
74 import com.google.common.collect.Lists;
75 import com.google.common.collect.Sets;
76 import com.google.common.util.concurrent.CheckedFuture;
77 import com.google.common.util.concurrent.FutureCallback;
78 import com.google.common.util.concurrent.Futures;
79 import com.google.common.util.concurrent.ListenableFuture;
80 import com.google.common.util.concurrent.MoreExecutors;
81
82 public class VppNodeManager {
83
84     private static final TopologyId TOPOLOGY_ID = new TopologyId("topology-netconf");
85     private static final Logger LOG = LoggerFactory.getLogger(VppNodeManager.class);
86     private static final String V3PO_CAPABILITY = "(urn:opendaylight:params:xml:ns:yang:v3po?revision=2017-06-07)v3po";
87     private static final String INTERFACES_CAPABILITY = "(urn:ietf:params:xml:ns:yang:ietf-interfaces?revision=2014-05-08)ietf-interfaces";
88     private static final NodeId CONTROLLER_CONFIG_NODE = new NodeId("controller-config");
89     private static final String NO_PUBLIC_INT_SPECIFIED = "unspecified";
90     private static final String PUBLIC_INTERFACE = "public-interface";
91     private final Map<NodeId, PhysicalInterfaceKey> extInterfaces = new HashMap<>();
92     private final DataBroker dataBroker;
93     private final List<String> requiredCapabilities;
94     private final MountPointService mountService;
95     private final HostRelatedInfoContainer hostRelatedInfoContainer = HostRelatedInfoContainer.getInstance();
96     private final MountedDataBrokerProvider mountProvider;
97
98     public VppNodeManager(@Nonnull final DataBroker dataBroker,
99             @Nonnull final BindingAwareBroker.ProviderContext session, @Nullable String physicalInterfaces) {
100         this.dataBroker = Preconditions.checkNotNull(dataBroker);
101         this.mountService = Preconditions.checkNotNull(session.getSALService(MountPointService.class));
102         this.mountProvider = new MountedDataBrokerProvider(mountService, dataBroker);
103         requiredCapabilities = initializeRequiredCapabilities();
104         if (!Strings.isNullOrEmpty(physicalInterfaces) && !Objects.equals(physicalInterfaces, NO_PUBLIC_INT_SPECIFIED)) {
105             loadPhysicalInterfaces(physicalInterfaces);
106         }
107     }
108
109     /**
110      * Caches list of physical interfaces.
111      */
112     private void loadPhysicalInterfaces(@Nonnull String physicalInterfaces) {
113         for (String intfOnNode : Sets.newConcurrentHashSet(Splitter.on(",").split(physicalInterfaces))) {
114             List<String> entries = Lists.newArrayList(Splitter.on(":").split(intfOnNode));
115             if (entries.size() != 2) {
116                 LOG.warn("Cannot resolve {} initial configuration for physical interfaces.", intfOnNode);
117                 continue;
118             }
119             NodeId nodeId = new NodeId(entries.get(0));
120             PhysicalInterfaceKey infaceKey = new PhysicalInterfaceKey(entries.get(1));
121             LOG.info("Interface %s on node %swill be considered as external", infaceKey, nodeId);
122             extInterfaces.put(nodeId, infaceKey);
123         }
124     }
125
126     /**
127      * Synchronizes nodes to DataStore based on their modification state which results in
128      * create/update/remove of Node.
129      * @param dataAfter data after modification
130      * @param dataBefore data Before modification
131      */
132     public void syncNodes(final Node dataAfter, final Node dataBefore) {
133         if (isControllerConfigNode(dataAfter, dataBefore)) {
134             LOG.trace("{} is ignored by VPP-renderer", CONTROLLER_CONFIG_NODE);
135             return;
136         }
137         ListenableFuture<String> syncFuture = Futures.immediateFuture(null);
138         // New node
139         if (dataBefore == null && dataAfter != null) {
140             syncFuture = createNode(dataAfter);
141         }
142         // Connected/disconnected node
143         else if (dataBefore != null && dataAfter != null) {
144             syncFuture = updateNode(dataAfter);
145         }
146         // Removed node
147         else if (dataBefore != null) {
148             syncFuture = removeNode(dataBefore);
149         }
150         Futures.addCallback(syncFuture, new FutureCallback<String>() {
151             @Override
152             public void onSuccess(@Nullable String message) {
153                 LOG.info("Node synchronization completed. {} ", message);
154             }
155
156             @Override
157             public void onFailure(@Nonnull Throwable t) {
158                 LOG.warn("Node synchronization failed. Data before: {} after {}", dataBefore, dataAfter);
159             }
160         }, MoreExecutors.directExecutor());
161     }
162
163     private boolean isControllerConfigNode(final Node dataAfter, final Node dataBefore) {
164         if (dataAfter != null) {
165             return CONTROLLER_CONFIG_NODE.equals(dataAfter.getNodeId());
166         }
167         return CONTROLLER_CONFIG_NODE.equals(dataBefore.getNodeId());
168     }
169
170     private ListenableFuture<String> createNode(final Node node) {
171         final String nodeId = node.getNodeId().getValue();
172         LOG.info("Registering new node {}", nodeId);
173         final NetconfNode netconfNode = getNodeAugmentation(node);
174         if (netconfNode == null) {
175             final String message = String.format("Node %s is not an netconf node", nodeId);
176             return Futures.immediateFuture(message);
177         }
178         final NetconfNodeConnectionStatus.ConnectionStatus connectionStatus = netconfNode.getConnectionStatus();
179         switch (connectionStatus) {
180             case Connecting: {
181                 final String message = String.format("Connecting device %s ...", nodeId);
182                 return Futures.immediateFuture(message);
183             }
184             case Connected: {
185                 return resolveConnectedNode(node, netconfNode);
186             }
187             case UnableToConnect: {
188                 final String message = String.format("Connection status is unable to connect for node %s", nodeId);
189                 return Futures.immediateFuture(message);
190             }
191             default: {
192                 final String message = String.format("Unknown connection status for node %s", nodeId);
193                 return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
194             }
195         }
196     }
197
198     private ListenableFuture<String> updateNode(final Node node) {
199         final String nodeId = node.getNodeId().getValue();
200         LOG.info("Updating node {}", nodeId);
201         final NetconfNode netconfNode = getNodeAugmentation(node);
202         if (netconfNode == null) {
203             final String message = String.format("Node %s is not an netconf node", nodeId);
204             return Futures.immediateFuture(message);
205         }
206         final NetconfNodeConnectionStatus.ConnectionStatus afterNodeStatus = netconfNode.getConnectionStatus();
207         if (Connected.equals(afterNodeStatus)) {
208             return resolveConnectedNode(node, netconfNode);
209         } else if (Connecting.equals(afterNodeStatus)) {
210             final String cause = String.format("Node %s is disconnected, removing from available nodes", nodeId);
211             return resolveDisconnectedNode(node, cause);
212         } else if (UnableToConnect.equals(afterNodeStatus)) {
213             final String cause = String.format("New node %s status is unable to connect, removing from available nodes",
214                     nodeId);
215             return resolveDisconnectedNode(node, cause);
216         } else {
217             final String cause = String.format("New node status is unknown. Node %s will be removed from available nodes",
218                     nodeId);
219             return resolveDisconnectedNode(node, cause);
220         }
221     }
222
223     private ListenableFuture<String> removeNode(final Node node) {
224         final String cause = String.format("Node %s is removed", node.getNodeId().getValue());
225         return resolveDisconnectedNode(node, cause);
226     }
227
228     private ListenableFuture<String> resolveConnectedNode(final Node node, final NetconfNode netconfNode) {
229         final String nodeId = node.getNodeId().getValue();
230         final InstanceIdentifier<Node> mountPointIid = getMountpointIid(node);
231         final RendererNode rendererNode = remapNode(mountPointIid);
232         if (!isCapableNetconfDevice(node, netconfNode)) {
233             final String message = String.format("Node %s is not connected", nodeId);
234             return Futures.immediateFuture(message);
235         }
236         final Optional<DataBroker> mountpoint = mountProvider.resolveDataBrokerForMountPoint(mountPointIid);
237         if (!mountpoint.isPresent()) {
238             final String message = String.format("Mountpoint not available for node %s", nodeId);
239             return Futures.immediateFuture(message);
240         }
241         final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
242         wTx.put(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getRendererNodeIid(rendererNode), rendererNode, true);
243         final boolean submit = DataStoreHelper.submitToDs(wTx);
244         if (submit) {
245             final String message = String.format("Node %s is capable and ready", nodeId);
246             syncPhysicalInterfacesInLocalDs(mountpoint.get(), mountPointIid);
247             NatUtil.resolveOutboundNatInterface(mountPointIid, node.getNodeId(), extInterfaces);
248             return Futures.immediateFuture(message);
249         } else {
250             final String message = String.format("Failed to resolve connected node %s", nodeId);
251             return Futures.immediateFuture(message);
252         }
253     }
254
255     private ListenableFuture<String> resolveDisconnectedNode(final Node node, final String cause) {
256         final InstanceIdentifier<Node> mountPointIid = getMountpointIid(node);
257         final RendererNode rendererNode = remapNode(mountPointIid);
258         final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
259         wTx.delete(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getRendererNodeIid(rendererNode));
260         final CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = wTx.submit();
261         try {
262             checkedFuture.checkedGet();
263             mountProvider.deleteDataBrokerForMountPoint(mountPointIid);
264             return Futures.immediateFuture(cause);
265         } catch (TransactionCommitFailedException e) {
266             final String message = String.format("Failed to resolve disconnected node %s", node.getNodeId().getValue());
267             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
268         }
269     }
270
271     private RendererNode remapNode(final InstanceIdentifier<Node> path) {
272         final RendererNodeBuilder rendererNodeBuilder = new RendererNodeBuilder();
273         rendererNodeBuilder.setKey(new RendererNodeKey(path)).setNodePath(path);
274         return rendererNodeBuilder.build();
275     }
276
277     private InstanceIdentifier<Node> getMountpointIid(final Node node) {
278         return InstanceIdentifier.builder(NetworkTopology.class)
279                 .child(Topology.class, new TopologyKey(TOPOLOGY_ID))
280                 .child(Node.class, new NodeKey(node.getNodeId()))
281                 .build();
282     }
283
284     private boolean isCapableNetconfDevice(final Node node, final NetconfNode netconfAugmentation) {
285         if (netconfAugmentation.getAvailableCapabilities() == null
286                 || netconfAugmentation.getAvailableCapabilities().getAvailableCapability() == null
287                 || netconfAugmentation.getAvailableCapabilities().getAvailableCapability().isEmpty()) {
288             LOG.warn("Node {} does not contain any capabilities", node.getNodeId().getValue());
289             return false;
290         }
291         if (!capabilityCheck(netconfAugmentation.getAvailableCapabilities().getAvailableCapability())) {
292             LOG.warn("Node {} does not contain all capabilities required by vpp-renderer", node.getNodeId().getValue());
293             return false;
294         }
295         return true;
296     }
297
298     private boolean capabilityCheck(final List<AvailableCapability> capabilities) {
299         final List<String> availableCapabilities = capabilities.stream()
300                 .map(AvailableCapability::getCapability)
301                 .collect(Collectors.toList());
302         return requiredCapabilities.stream()
303                 .allMatch(availableCapabilities::contains);
304     }
305
306     private NetconfNode getNodeAugmentation(final Node node) {
307         final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
308         if (netconfNode == null) {
309             LOG.warn("Node {} is not a netconf device", node.getNodeId().getValue());
310             return null;
311         }
312         return netconfNode;
313     }
314
315     /**
316      * Initialize all common capabilities required by VPP renderer. Any connected node is examined
317      * whether it's
318      * an appropriate device to handle configuration created by this renderer. A device must support
319      * all capabilities
320      * in list below.
321      *
322      * @return list of string representations of required capabilities
323      */
324     private List<String> initializeRequiredCapabilities() {
325         // Required device capabilities
326         String[] capabilityEntries = {V3PO_CAPABILITY, INTERFACES_CAPABILITY};
327         return Arrays.asList(capabilityEntries);
328     }
329
330     private void syncPhysicalInterfacesInLocalDs(DataBroker mountPointDataBroker, InstanceIdentifier<Node> nodeIid) {
331         ReadWriteTransaction rwTx = dataBroker.newReadWriteTransaction();
332         ReadOnlyTransaction rTx = mountPointDataBroker.newReadOnlyTransaction();
333         Optional<Interfaces> readIfaces = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
334                 InstanceIdentifier.create(Interfaces.class), rTx);
335         if (readIfaces.isPresent()) {
336             InstanceIdentifier<RendererNode> rendererNodeIid = VppIidFactory.getRendererNodesIid()
337                 .builder()
338                 .child(RendererNode.class, new RendererNodeKey(nodeIid))
339                 .build();
340             Optional<RendererNode> optRendNode = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
341                     rendererNodeIid, rwTx);
342             NodeId nodeId = nodeIid.firstKeyOf(Node.class).getNodeId();
343             RendererNode rendNode = new RendererNodeBuilder(optRendNode.get())
344                 .addAugmentation(VppInterfaceAugmentation.class, resolveTerminationPoints(nodeId, readIfaces.get()))
345                 .build();
346             rwTx.put(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getRendererNodeIid(optRendNode.get()), rendNode,
347                     true);
348         }
349         rTx.close();
350         DataStoreHelper.submitToDs(rwTx);
351     }
352
353     private VppInterfaceAugmentation resolveTerminationPoints(NodeId nodeId, Interfaces interfaces) {
354         List<PhysicalInterface> phIfaces = new ArrayList<>();
355         if (interfaces != null && interfaces.getInterface() != null) {
356             interfaces.getInterface()
357                 .stream()
358                 .filter(iface -> iface.getType().equals(EthernetCsmacd.class))
359                 .filter(iface -> iface.getAugmentation(Interface1.class) != null)
360                 .forEach(iface -> {
361                     PhysicalInterfaceBuilder phIface = new PhysicalInterfaceBuilder();
362                     phIface.setInterfaceName(iface.getName());
363                     phIface.setType(iface.getType());
364                     phIface.setAddress(resolveIpAddress(iface.getAugmentation(Interface1.class)));
365                     PhysicalInterfaces physicalInterfaces = hostRelatedInfoContainer
366                                                                         .getPhysicalInterfaceState(nodeId.getValue());
367                     if (physicalInterfaces == null) {
368                         physicalInterfaces = new PhysicalInterfaces();
369                         hostRelatedInfoContainer.setPhysicalInterfaceStateOfHost(nodeId.getValue(), physicalInterfaces);
370                     }
371
372
373                     if (extInterfaces.get(nodeId) != null
374                             && extInterfaces.get(nodeId).getInterfaceName().equals(phIface.getInterfaceName())) {
375                         phIface.setExternal(true);
376                         extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
377                         physicalInterfaces
378                                 .addPhysicalInterfaceInfo(PhysicalInterfaces.PhysicalInterfaceType.PUBLIC,
379                                         phIface.getInterfaceName(), phIface.getAddress().get(0));
380                         LOG.info("Interface {} is marked as public interface based on bundle configuration.",
381                                 iface.getName());
382                     }
383                     if (PUBLIC_INTERFACE.equals(iface.getDescription())) {
384                         phIface.setExternal(true);
385                         extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
386                         physicalInterfaces
387                                 .addPhysicalInterfaceInfo(PhysicalInterfaces.PhysicalInterfaceType.PUBLIC,
388                                         phIface.getInterfaceName(), phIface.getAddress().get(0));
389                         LOG.info("Interface {} is marked as public interface based on HC configuration.",
390                                 iface.getName());
391                     }
392                     phIfaces.add(phIface.build());
393                 });
394         }
395         return new VppInterfaceAugmentationBuilder().setPhysicalInterface(phIfaces).build();
396     }
397
398     private List<IpAddress> resolveIpAddress(Interface1 iface) {
399         if (iface.getIpv4() != null && iface.getIpv4().getAddress() != null) {
400             return iface.getIpv4().getAddress().stream().map(ipv4 ->
401                     new IpAddress(new Ipv4Address(ipv4.getIp().getValue()))).collect(Collectors.toList());
402         } else if (iface.getIpv6() != null && iface.getIpv6().getAddress() != null) {
403             return iface.getIpv6().getAddress().stream().map(ipv6 ->
404                     new IpAddress(new Ipv4Address(ipv6.getIp().getValue()))).collect(Collectors.toList());
405         }
406         return Lists.newArrayList();
407     }
408
409     public static Map<NodeId, String> resolvePublicInterfaces(ReadTransaction rTx) {
410         Map<NodeId, String> nodes = new HashMap<>();
411         Optional<RendererNodes> rendNodes =
412                 DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getRendererNodesIid(), rTx);
413         if (!rendNodes.isPresent()) {
414             return nodes;
415         }
416         rendNodes.get()
417             .getRendererNode()
418             .stream()
419             .filter(rn -> rn.getAugmentation(VppInterfaceAugmentation.class) != null)
420             .filter(rn -> rn.getAugmentation(VppInterfaceAugmentation.class).getPhysicalInterface() != null)
421             .forEach(rn -> {
422                 java.util.Optional<PhysicalInterface> pubInt = rn.getAugmentation(VppInterfaceAugmentation.class)
423                     .getPhysicalInterface()
424                     .stream()
425                     .filter(PhysicalInterface::isExternal)
426                     .findFirst();
427                 if (pubInt.isPresent()) {
428                     nodes.put(rn.getNodePath().firstKeyOf(Node.class).getNodeId(), pubInt.get().getInterfaceName());
429                 }
430             });
431         return nodes;
432     }
433 }