@Test public void testConvertOspfRedistributionPolicy() { NetworkFactory nf = new NetworkFactory(); Configuration viConfig = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CUMULUS_NCLU).build(); nf.vrfBuilder().setOwner(viConfig).setName(DEFAULT_VRF_NAME).build(); CumulusNcluConfiguration vsConfig = new CumulusNcluConfiguration(); OspfVrf ospfVrf = new OspfVrf(DEFAULT_VRF_NAME); ospfVrf.setRouterId(Ip.parse("1.2.3.4")); OspfProcess vsOspf = new OspfProcess(); vsConfig.setOspfProcess(vsOspf); RedistributionPolicy rp = new RedistributionPolicy(CumulusRoutingProtocol.BGP, "some-map"); vsConfig.getRouteMaps().put("some-map", new RouteMap("some-map")); If policy = convertOspfRedistributionPolicy(rp, vsConfig.getRouteMaps()); List<BooleanExpr> guard = ((Conjunction) policy.getGuard()).getConjuncts(); assertThat(guard, contains(new MatchProtocol(BGP, IBGP), new CallExpr("some-map"))); assertThat(policy.getTrueStatements(), contains(ExitAccept.toStaticStatement())); }
@VisibleForTesting @Nonnull static If convertOspfRedistributionPolicy( RedistributionPolicy policy, Map<String, RouteMap> routeMaps) { CumulusRoutingProtocol protocol = policy.getCumulusRoutingProtocol(); Conjunction ospfExportConditions = new Conjunction(); ospfExportConditions.getConjuncts().add(new MatchProtocol(VI_PROTOCOLS_MAP.get(protocol))); ImmutableList.Builder<Statement> ospfExportStatements = ImmutableList.builder(); String exportRouteMapName = policy.getRouteMap(); if (exportRouteMapName != null) { RouteMap exportRouteMap = routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName)); } } ospfExportStatements.add(Statements.ExitAccept.toStaticStatement()); return new If( "OSPF export routes for " + protocol.name(), ospfExportConditions, ospfExportStatements.build(), ImmutableList.of()); }
CumulusConversions { @VisibleForTesting @Nonnull static If convertOspfRedistributionPolicy( RedistributionPolicy policy, Map<String, RouteMap> routeMaps) { CumulusRoutingProtocol protocol = policy.getCumulusRoutingProtocol(); Conjunction ospfExportConditions = new Conjunction(); ospfExportConditions.getConjuncts().add(new MatchProtocol(VI_PROTOCOLS_MAP.get(protocol))); ImmutableList.Builder<Statement> ospfExportStatements = ImmutableList.builder(); String exportRouteMapName = policy.getRouteMap(); if (exportRouteMapName != null) { RouteMap exportRouteMap = routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName)); } } ospfExportStatements.add(Statements.ExitAccept.toStaticStatement()); return new If( "OSPF export routes for " + protocol.name(), ospfExportConditions, ospfExportStatements.build(), ImmutableList.of()); } }
CumulusConversions { @VisibleForTesting @Nonnull static If convertOspfRedistributionPolicy( RedistributionPolicy policy, Map<String, RouteMap> routeMaps) { CumulusRoutingProtocol protocol = policy.getCumulusRoutingProtocol(); Conjunction ospfExportConditions = new Conjunction(); ospfExportConditions.getConjuncts().add(new MatchProtocol(VI_PROTOCOLS_MAP.get(protocol))); ImmutableList.Builder<Statement> ospfExportStatements = ImmutableList.builder(); String exportRouteMapName = policy.getRouteMap(); if (exportRouteMapName != null) { RouteMap exportRouteMap = routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName)); } } ospfExportStatements.add(Statements.ExitAccept.toStaticStatement()); return new If( "OSPF export routes for " + protocol.name(), ospfExportConditions, ospfExportStatements.build(), ImmutableList.of()); }  }
CumulusConversions { @VisibleForTesting @Nonnull static If convertOspfRedistributionPolicy( RedistributionPolicy policy, Map<String, RouteMap> routeMaps) { CumulusRoutingProtocol protocol = policy.getCumulusRoutingProtocol(); Conjunction ospfExportConditions = new Conjunction(); ospfExportConditions.getConjuncts().add(new MatchProtocol(VI_PROTOCOLS_MAP.get(protocol))); ImmutableList.Builder<Statement> ospfExportStatements = ImmutableList.builder(); String exportRouteMapName = policy.getRouteMap(); if (exportRouteMapName != null) { RouteMap exportRouteMap = routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName)); } } ospfExportStatements.add(Statements.ExitAccept.toStaticStatement()); return new If( "OSPF export routes for " + protocol.name(), ospfExportConditions, ospfExportStatements.build(), ImmutableList.of()); }  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 @Nonnull static If convertOspfRedistributionPolicy( RedistributionPolicy policy, Map<String, RouteMap> routeMaps) { CumulusRoutingProtocol protocol = policy.getCumulusRoutingProtocol(); Conjunction ospfExportConditions = new Conjunction(); ospfExportConditions.getConjuncts().add(new MatchProtocol(VI_PROTOCOLS_MAP.get(protocol))); ImmutableList.Builder<Statement> ospfExportStatements = ImmutableList.builder(); String exportRouteMapName = policy.getRouteMap(); if (exportRouteMapName != null) { RouteMap exportRouteMap = routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName)); } } ospfExportStatements.add(Statements.ExitAccept.toStaticStatement()); return new If( "OSPF export routes for " + protocol.name(), ospfExportConditions, ospfExportStatements.build(), ImmutableList.of()); }  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; }