@Test public void testInitNeighborConfigs() { NetworkFactory nf = new NetworkFactory(); Configuration configuration = nf.configurationBuilder() .setHostname("conf") .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .build(); Vrf vrf = nf.vrfBuilder().setName("vrf").setOwner(configuration).build(); EigrpMetric metric = WideMetric.builder() .setValues(EigrpMetricValues.builder().setBandwidth(1d).setDelay(1d).build()) .build(); nf.interfaceBuilder() .setName("iface1") .setOwner(configuration) .setVrf(vrf) .setAddress(ConcreteInterfaceAddress.create(Ip.parse("1.1.1.1"), 24)) .setEigrp( EigrpInterfaceSettings.builder() .setAsn(1L) .setExportPolicy("ep") .setEnabled(true) .setPassive(true) .setMetric(metric) .build()) .build(); nf.interfaceBuilder() .setName("iface2") .setOwner(configuration) .setVrf(vrf) .setAddress(ConcreteInterfaceAddress.create(Ip.parse("2.2.2.2"), 24)) .setEigrp( EigrpInterfaceSettings.builder() .setAsn(2L) .setExportPolicy("ep") .setEnabled(true) .setPassive(true) .setMetric(metric) .build()) .build(); vrf.addEigrpProcess( EigrpProcess.builder() .setAsNumber(1L) .setExportPolicy("ep") .setMode(EigrpProcessMode.NAMED) .setRouterId(Ip.parse("1.1.1.1")) .setExportPolicy("policy") .build()); EigrpTopologyUtils.initNeighborConfigs( NetworkConfigurations.of(ImmutableMap.of(configuration.getHostname(), configuration))); assertThat( configuration.getVrfs().get("vrf").getEigrpProcesses().get(1L).getNeighbors(), equalTo( ImmutableMap.of( "iface1", EigrpNeighborConfig.builder() .setAsn(1L) .setInterfaceName("iface1") .setPassive(true) .setExportPolicy("ep") .setHostname("conf") .setVrfName("vrf") .setIp(Ip.parse("1.1.1.1")) .build()))); }
public static void initNeighborConfigs(NetworkConfigurations configurations) { for (Configuration config : configurations.all()) { for (Vrf vrf : config.getVrfs().values()) { for (EigrpProcess proc : vrf.getEigrpProcesses().values()) { ImmutableList.Builder<EigrpNeighborConfig> neighborsBuilder = ImmutableList.builder(); for (Interface iface : config.getAllInterfaces(vrf.getName()).values()) { if (iface.getConcreteAddress() == null || iface.getEigrp() == null || !iface.getEigrp().getEnabled() || iface.getEigrp().getAsn() != proc.getAsn()) { continue; } String exportPolicyName = iface.getEigrp().getExportPolicy(); assert exportPolicyName != null; neighborsBuilder.add( EigrpNeighborConfig.builder() .setExportPolicy(exportPolicyName) .setHostname(config.getHostname()) .setInterfaceName(iface.getName()) .setIp(iface.getConcreteAddress().getIp()) .setVrfName(vrf.getName()) .setAsn(iface.getEigrp().getAsn()) .setPassive(iface.getEigrp().getPassive()) .build()); } proc.addNeighbors(neighborsBuilder.build()); } } } }
EigrpTopologyUtils { public static void initNeighborConfigs(NetworkConfigurations configurations) { for (Configuration config : configurations.all()) { for (Vrf vrf : config.getVrfs().values()) { for (EigrpProcess proc : vrf.getEigrpProcesses().values()) { ImmutableList.Builder<EigrpNeighborConfig> neighborsBuilder = ImmutableList.builder(); for (Interface iface : config.getAllInterfaces(vrf.getName()).values()) { if (iface.getConcreteAddress() == null || iface.getEigrp() == null || !iface.getEigrp().getEnabled() || iface.getEigrp().getAsn() != proc.getAsn()) { continue; } String exportPolicyName = iface.getEigrp().getExportPolicy(); assert exportPolicyName != null; neighborsBuilder.add( EigrpNeighborConfig.builder() .setExportPolicy(exportPolicyName) .setHostname(config.getHostname()) .setInterfaceName(iface.getName()) .setIp(iface.getConcreteAddress().getIp()) .setVrfName(vrf.getName()) .setAsn(iface.getEigrp().getAsn()) .setPassive(iface.getEigrp().getPassive()) .build()); } proc.addNeighbors(neighborsBuilder.build()); } } } } }
EigrpTopologyUtils { public static void initNeighborConfigs(NetworkConfigurations configurations) { for (Configuration config : configurations.all()) { for (Vrf vrf : config.getVrfs().values()) { for (EigrpProcess proc : vrf.getEigrpProcesses().values()) { ImmutableList.Builder<EigrpNeighborConfig> neighborsBuilder = ImmutableList.builder(); for (Interface iface : config.getAllInterfaces(vrf.getName()).values()) { if (iface.getConcreteAddress() == null || iface.getEigrp() == null || !iface.getEigrp().getEnabled() || iface.getEigrp().getAsn() != proc.getAsn()) { continue; } String exportPolicyName = iface.getEigrp().getExportPolicy(); assert exportPolicyName != null; neighborsBuilder.add( EigrpNeighborConfig.builder() .setExportPolicy(exportPolicyName) .setHostname(config.getHostname()) .setInterfaceName(iface.getName()) .setIp(iface.getConcreteAddress().getIp()) .setVrfName(vrf.getName()) .setAsn(iface.getEigrp().getAsn()) .setPassive(iface.getEigrp().getPassive()) .build()); } proc.addNeighbors(neighborsBuilder.build()); } } } }  }
EigrpTopologyUtils { public static void initNeighborConfigs(NetworkConfigurations configurations) { for (Configuration config : configurations.all()) { for (Vrf vrf : config.getVrfs().values()) { for (EigrpProcess proc : vrf.getEigrpProcesses().values()) { ImmutableList.Builder<EigrpNeighborConfig> neighborsBuilder = ImmutableList.builder(); for (Interface iface : config.getAllInterfaces(vrf.getName()).values()) { if (iface.getConcreteAddress() == null || iface.getEigrp() == null || !iface.getEigrp().getEnabled() || iface.getEigrp().getAsn() != proc.getAsn()) { continue; } String exportPolicyName = iface.getEigrp().getExportPolicy(); assert exportPolicyName != null; neighborsBuilder.add( EigrpNeighborConfig.builder() .setExportPolicy(exportPolicyName) .setHostname(config.getHostname()) .setInterfaceName(iface.getName()) .setIp(iface.getConcreteAddress().getIp()) .setVrfName(vrf.getName()) .setAsn(iface.getEigrp().getAsn()) .setPassive(iface.getEigrp().getPassive()) .build()); } proc.addNeighbors(neighborsBuilder.build()); } } } }  static @Nonnull EigrpTopology initEigrpTopology(
      Map<String, Configuration> configurations, Topology topology); static void initNeighborConfigs(NetworkConfigurations configurations); }
EigrpTopologyUtils { public static void initNeighborConfigs(NetworkConfigurations configurations) { for (Configuration config : configurations.all()) { for (Vrf vrf : config.getVrfs().values()) { for (EigrpProcess proc : vrf.getEigrpProcesses().values()) { ImmutableList.Builder<EigrpNeighborConfig> neighborsBuilder = ImmutableList.builder(); for (Interface iface : config.getAllInterfaces(vrf.getName()).values()) { if (iface.getConcreteAddress() == null || iface.getEigrp() == null || !iface.getEigrp().getEnabled() || iface.getEigrp().getAsn() != proc.getAsn()) { continue; } String exportPolicyName = iface.getEigrp().getExportPolicy(); assert exportPolicyName != null; neighborsBuilder.add( EigrpNeighborConfig.builder() .setExportPolicy(exportPolicyName) .setHostname(config.getHostname()) .setInterfaceName(iface.getName()) .setIp(iface.getConcreteAddress().getIp()) .setVrfName(vrf.getName()) .setAsn(iface.getEigrp().getAsn()) .setPassive(iface.getEigrp().getPassive()) .build()); } proc.addNeighbors(neighborsBuilder.build()); } } } }  static @Nonnull EigrpTopology initEigrpTopology(
      Map<String, Configuration> configurations, Topology topology); static void initNeighborConfigs(NetworkConfigurations configurations);  }