private static SortedSet<VerboseEigrpEdge> getEigrpEdges( Map<String, Configuration> configs, Topology topology) { Network<EigrpInterface, EigrpEdge> eigrpTopology = EigrpTopology.initEigrpTopology(configs, topology); NetworkConfigurations nc = NetworkConfigurations.of(configs); SortedSet<VerboseEigrpEdge> eigrpEdges = new TreeSet<>(); for (Configuration c : configs.values()) { String hostname = c.getHostname(); for (Vrf vrf : c.getVrfs().values()) { eigrpEdges.addAll( vrf.getInterfaceNames().stream() .map(ifaceName -> new EigrpInterface(hostname, ifaceName, vrf.getName())) .filter(eigrpTopology.nodes()::contains) .flatMap(n -> eigrpTopology.inEdges(n).stream()) .map(edge -> new VerboseEigrpEdge(edge, edge.toIpEdge(nc))) .collect(ImmutableSortedSet.toImmutableSortedSet(Comparator.naturalOrder()))); } } return eigrpEdges; }
/** Return an {@link EigrpEdge} if there is an EIGRP adjacency on {@code edge}. */ @Nonnull static Optional<EigrpEdge> edgeIfAdjacent(Edge edge, Map<String, Configuration> configurations) { // vertex1 Configuration c1 = configurations.get(edge.getNode1()); Interface iface1 = c1.getAllInterfaces().get(edge.getInt1()); EigrpInterfaceSettings eigrp1 = iface1.getEigrp(); // vertex2 Configuration c2 = configurations.get(edge.getNode2()); Interface iface2 = c2.getAllInterfaces().get(edge.getInt2()); EigrpInterfaceSettings eigrp2 = iface2.getEigrp(); if (eigrp1 == null || eigrp2 == null || !eigrp1.getEnabled() || !eigrp2.getEnabled() || eigrp1.getAsn() != eigrp2.getAsn() || eigrp1.getPassive() || eigrp2.getPassive()) { return empty(); } return Optional.of( new EigrpEdge( new EigrpInterface(c1.getHostname(), iface1), new EigrpInterface(c2.getHostname(), iface2))); }
@Test public void testEigrpToRow() { EigrpEdge testEdge = new EigrpEdge( new EigrpInterface("host1", "int1", "vrf1"), new EigrpInterface("host2", "int2", "vrf2")); Row row = eigrpEdgeToRow(testEdge); assertThat( row, allOf( hasColumn( COL_INTERFACE, equalTo(new NodeInterfacePair("host1", "int1")), Schema.INTERFACE), hasColumn( COL_REMOTE_INTERFACE, equalTo(new NodeInterfacePair("host2", "int2")), Schema.INTERFACE))); }
@Test public void testGetEigrpEdges() { MutableNetwork<EigrpInterface, EigrpEdge> eigrpTopology = NetworkBuilder.directed().allowsParallelEdges(false).allowsSelfLoops(false).build(); EigrpInterface eigrpInterface1 = new EigrpInterface("host1", "int1", "vrf1"); EigrpInterface eigrpInterface2 = new EigrpInterface("host2", "int2", "vrf2"); eigrpTopology.addEdge( eigrpInterface1, eigrpInterface2, new EigrpEdge(eigrpInterface1, eigrpInterface2)); Multiset<Row> rows = getEigrpEdges(_includeNodes, _includeRemoteNodes, eigrpTopology); assertThat( rows, contains( allOf( hasColumn( COL_INTERFACE, equalTo(new NodeInterfacePair("host1", "int1")), Schema.INTERFACE), hasColumn( COL_REMOTE_INTERFACE, equalTo(new NodeInterfacePair("host2", "int2")), Schema.INTERFACE)))); }
&& iface.getEigrp().getAsn() == _asn && iface.getEigrp().getEnabled()) { _interfaces.add(new EigrpInterface(c.getHostname(), iface)); requireNonNull(iface.getEigrp()); Set<Prefix> allNetworkPrefixes =
vedges.addAll( vrf.getInterfaceNames().stream() .map(ifaceName -> new EigrpInterface(hostname, ifaceName, vrf.getName())) .filter(_eigrpTopology.nodes()::contains) .flatMap(n -> _eigrpTopology.inEdges(n).stream())