@Test public void testAddBgpNeighbor_numberedInterface() { org.batfish.datamodel.BgpProcess bgpProc = new org.batfish.datamodel.BgpProcess( Ip.parse("0.0.0.0"), ConfigurationFormat.CUMULUS_CONCATENATED); Vrf viVrf = Vrf.builder().setName("vrf").build(); viVrf.setBgpProcess(bgpProc); ConcreteInterfaceAddress ifaceAddress = ConcreteInterfaceAddress.parse("1.1.1.1/31"); Configuration c = new Configuration("c", ConfigurationFormat.CUMULUS_CONCATENATED); org.batfish.datamodel.Interface viIface = org.batfish.datamodel.Interface.builder() .setName("iface") .setOwner(c) .setAddress(ifaceAddress) .build(); c.getAllInterfaces().put(viIface.getName(), viIface); c.getVrfs().put(viVrf.getName(), viVrf); BgpNeighbor neighbor = new BgpInterfaceNeighbor("iface"); neighbor.setRemoteAs(123L); addBgpNeighbor( c, CumulusConcatenatedConfiguration.builder().setHostname("c").build(), new BgpVrf(viVrf.getName()), neighbor, new Warnings()); Prefix peerPrefix = Prefix.parse("1.1.1.0/32"); assertTrue(bgpProc.getActiveNeighbors().containsKey(peerPrefix)); assertEquals(bgpProc.getActiveNeighbors().get(peerPrefix).getLocalIp(), ifaceAddress.getIp()); }
@VisibleForTesting static void addBgpNeighbor( Configuration c, CumulusNodeConfiguration vsConfig, BgpVrf bgpVrf, BgpNeighbor neighbor, Warnings w) { org.batfish.datamodel.BgpProcess viBgpProcess = c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess(); neighbor.inheritFrom(bgpVrf.getNeighbors()); Long localAs = null; if (neighbor.getLocalAs() != null) { localAs = neighbor.getLocalAs(); } else if (bgpVrf.getAutonomousSystem() != null) { localAs = bgpVrf.getAutonomousSystem(); } if (neighbor instanceof BgpInterfaceNeighbor) { BgpInterfaceNeighbor interfaceNeighbor = (BgpInterfaceNeighbor) neighbor; if (interfaceNeighbor.getLocalAs() != null) { localAs = interfaceNeighbor.getLocalAs(); } addInterfaceBgpNeighbor(c, vsConfig, interfaceNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (neighbor instanceof BgpIpNeighbor) { BgpIpNeighbor ipNeighbor = (BgpIpNeighbor) neighbor; if (ipNeighbor.getLocalAs() != null) { localAs = ipNeighbor.getLocalAs(); } addIpv4BgpNeighbor(c, vsConfig, ipNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (!(neighbor instanceof BgpPeerGroupNeighbor)) { throw new IllegalArgumentException( "Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName()); } }
CumulusConversions { @VisibleForTesting static void addBgpNeighbor( Configuration c, CumulusNodeConfiguration vsConfig, BgpVrf bgpVrf, BgpNeighbor neighbor, Warnings w) { org.batfish.datamodel.BgpProcess viBgpProcess = c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess(); neighbor.inheritFrom(bgpVrf.getNeighbors()); Long localAs = null; if (neighbor.getLocalAs() != null) { localAs = neighbor.getLocalAs(); } else if (bgpVrf.getAutonomousSystem() != null) { localAs = bgpVrf.getAutonomousSystem(); } if (neighbor instanceof BgpInterfaceNeighbor) { BgpInterfaceNeighbor interfaceNeighbor = (BgpInterfaceNeighbor) neighbor; if (interfaceNeighbor.getLocalAs() != null) { localAs = interfaceNeighbor.getLocalAs(); } addInterfaceBgpNeighbor(c, vsConfig, interfaceNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (neighbor instanceof BgpIpNeighbor) { BgpIpNeighbor ipNeighbor = (BgpIpNeighbor) neighbor; if (ipNeighbor.getLocalAs() != null) { localAs = ipNeighbor.getLocalAs(); } addIpv4BgpNeighbor(c, vsConfig, ipNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (!(neighbor instanceof BgpPeerGroupNeighbor)) { throw new IllegalArgumentException( "Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName()); } } }
CumulusConversions { @VisibleForTesting static void addBgpNeighbor( Configuration c, CumulusNodeConfiguration vsConfig, BgpVrf bgpVrf, BgpNeighbor neighbor, Warnings w) { org.batfish.datamodel.BgpProcess viBgpProcess = c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess(); neighbor.inheritFrom(bgpVrf.getNeighbors()); Long localAs = null; if (neighbor.getLocalAs() != null) { localAs = neighbor.getLocalAs(); } else if (bgpVrf.getAutonomousSystem() != null) { localAs = bgpVrf.getAutonomousSystem(); } if (neighbor instanceof BgpInterfaceNeighbor) { BgpInterfaceNeighbor interfaceNeighbor = (BgpInterfaceNeighbor) neighbor; if (interfaceNeighbor.getLocalAs() != null) { localAs = interfaceNeighbor.getLocalAs(); } addInterfaceBgpNeighbor(c, vsConfig, interfaceNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (neighbor instanceof BgpIpNeighbor) { BgpIpNeighbor ipNeighbor = (BgpIpNeighbor) neighbor; if (ipNeighbor.getLocalAs() != null) { localAs = ipNeighbor.getLocalAs(); } addIpv4BgpNeighbor(c, vsConfig, ipNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (!(neighbor instanceof BgpPeerGroupNeighbor)) { throw new IllegalArgumentException( "Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName()); } }  }
CumulusConversions { @VisibleForTesting static void addBgpNeighbor( Configuration c, CumulusNodeConfiguration vsConfig, BgpVrf bgpVrf, BgpNeighbor neighbor, Warnings w) { org.batfish.datamodel.BgpProcess viBgpProcess = c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess(); neighbor.inheritFrom(bgpVrf.getNeighbors()); Long localAs = null; if (neighbor.getLocalAs() != null) { localAs = neighbor.getLocalAs(); } else if (bgpVrf.getAutonomousSystem() != null) { localAs = bgpVrf.getAutonomousSystem(); } if (neighbor instanceof BgpInterfaceNeighbor) { BgpInterfaceNeighbor interfaceNeighbor = (BgpInterfaceNeighbor) neighbor; if (interfaceNeighbor.getLocalAs() != null) { localAs = interfaceNeighbor.getLocalAs(); } addInterfaceBgpNeighbor(c, vsConfig, interfaceNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (neighbor instanceof BgpIpNeighbor) { BgpIpNeighbor ipNeighbor = (BgpIpNeighbor) neighbor; if (ipNeighbor.getLocalAs() != null) { localAs = ipNeighbor.getLocalAs(); } addIpv4BgpNeighbor(c, vsConfig, ipNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (!(neighbor instanceof BgpPeerGroupNeighbor)) { throw new IllegalArgumentException( "Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName()); } }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @VisibleForTesting static void addBgpNeighbor( Configuration c, CumulusNodeConfiguration vsConfig, BgpVrf bgpVrf, BgpNeighbor neighbor, Warnings w) { org.batfish.datamodel.BgpProcess viBgpProcess = c.getVrfs().get(bgpVrf.getVrfName()).getBgpProcess(); neighbor.inheritFrom(bgpVrf.getNeighbors()); Long localAs = null; if (neighbor.getLocalAs() != null) { localAs = neighbor.getLocalAs(); } else if (bgpVrf.getAutonomousSystem() != null) { localAs = bgpVrf.getAutonomousSystem(); } if (neighbor instanceof BgpInterfaceNeighbor) { BgpInterfaceNeighbor interfaceNeighbor = (BgpInterfaceNeighbor) neighbor; if (interfaceNeighbor.getLocalAs() != null) { localAs = interfaceNeighbor.getLocalAs(); } addInterfaceBgpNeighbor(c, vsConfig, interfaceNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (neighbor instanceof BgpIpNeighbor) { BgpIpNeighbor ipNeighbor = (BgpIpNeighbor) neighbor; if (ipNeighbor.getLocalAs() != null) { localAs = ipNeighbor.getLocalAs(); } addIpv4BgpNeighbor(c, vsConfig, ipNeighbor, localAs, bgpVrf, viBgpProcess, w); } else if (!(neighbor instanceof BgpPeerGroupNeighbor)) { throw new IllegalArgumentException( "Unsupported BGP neighbor type: " + neighbor.getClass().getSimpleName()); } }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }