@Test public void testGenerateBgpCommonPeerConfig_L2vpnRouteReflector() { CumulusConcatenatedConfiguration vsConfig = CumulusConcatenatedConfiguration.builder() .setHostname("c") .setBgpProcess(new BgpProcess()) .build(); BgpVrf bgpVrf = new BgpVrf(DEFAULT_VRF_NAME); bgpVrf.setL2VpnEvpn(new BgpL2vpnEvpnAddressFamily()); BgpNeighbor neighbor = new BgpInterfaceNeighbor("swp1"); BgpNeighborL2vpnEvpnAddressFamily bgpNeighborL2vpnEvpnAddressFamily = new BgpNeighborL2vpnEvpnAddressFamily(); bgpNeighborL2vpnEvpnAddressFamily.setActivated(true); neighbor.setL2vpnEvpnAddressFamily(bgpNeighborL2vpnEvpnAddressFamily); neighbor.setRemoteAsType(RemoteAsType.EXTERNAL); BgpUnnumberedPeerConfig.Builder peerConfigBuilder = BgpUnnumberedPeerConfig.builder().setPeerInterface("swp1"); generateBgpCommonPeerConfig( new Configuration("c", ConfigurationFormat.CUMULUS_CONCATENATED), vsConfig, neighbor, 101L, bgpVrf, new org.batfish.datamodel.BgpProcess( Ip.parse("1.1.1.1"), ConfigurationFormat.CUMULUS_CONCATENATED), peerConfigBuilder, new Warnings()); assertFalse(peerConfigBuilder.build().getEvpnAddressFamily().getRouteReflectorClient()); bgpNeighborL2vpnEvpnAddressFamily.setRouteReflectorClient(true); generateBgpCommonPeerConfig( new Configuration("c", ConfigurationFormat.CUMULUS_CONCATENATED), vsConfig, neighbor, 101L, bgpVrf, new org.batfish.datamodel.BgpProcess( Ip.parse("1.1.1.1"), ConfigurationFormat.CUMULUS_CONCATENATED), peerConfigBuilder, new Warnings()); assertTrue(peerConfigBuilder.build().getEvpnAddressFamily().getRouteReflectorClient()); }
@VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); } }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  }
CumulusConversions { @VisibleForTesting static void generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  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 generateBgpCommonPeerConfig( Configuration c, CumulusNodeConfiguration vsConfig, BgpNeighbor neighbor, @Nullable Long localAs, BgpVrf bgpVrf, org.batfish.datamodel.BgpProcess newProc, BgpPeerConfig.Builder<?, ?> peerConfigBuilder, Warnings w) { RoutingPolicy exportRoutingPolicy = computeBgpNeighborExportRoutingPolicy(c, neighbor, bgpVrf); @Nullable RoutingPolicy importRoutingPolicy = computeBgpNeighborImportRoutingPolicy(c, neighbor, bgpVrf); peerConfigBuilder .setBgpProcess(newProc) .setClusterId(inferClusterId(bgpVrf, newProc.getRouterId(), neighbor)) .setConfederation(bgpVrf.getConfederationId()) .setDescription(neighbor.getDescription()) .setGroup(neighbor.getPeerGroup()) .setLocalAs(localAs) .setRemoteAsns(computeRemoteAsns(neighbor, localAs)) .setEbgpMultihop(neighbor.getEbgpMultihop() != null) .setGeneratedRoutes( bgpDefaultOriginate(neighbor) ? ImmutableSet.of(GENERATED_DEFAULT_ROUTE) : null) .setIpv4UnicastAddressFamily( convertIpv4UnicastAddressFamily( neighbor.getIpv4UnicastAddressFamily(), bgpVrf.getDefaultIpv4Unicast(), exportRoutingPolicy, importRoutingPolicy)) .setEvpnAddressFamily( toEvpnAddressFamily( c, vsConfig, neighbor, localAs, bgpVrf, newProc, exportRoutingPolicy, w)) .build(); }  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; }