@Test public void testActivateGeneratedRoute() { RibDelta<AnnotatedRoute<AbstractRoute>> delta = RibDelta.<AnnotatedRoute<AbstractRoute>>builder() .add( new AnnotatedRoute<>( StaticRoute.builder() .setAdministrativeCost(1) .setNetwork(Prefix.parse("1.1.1.0/24")) .setNextHopInterface("Null") .build(), VRF_NAME)) .build(); final GeneratedRoute.Builder generatedRoute = GeneratedRoute.builder().setNetwork(Prefix.ZERO); final String policyName = "GEN_POLICY"; RoutingPolicy.builder() .setOwner(_c) .setName(policyName) .setStatements(ImmutableList.of(Statements.ExitReject.toStaticStatement())) .build(); assertThat( _routingProcess.activateGeneratedRoute(delta, generatedRoute.build()), equalTo(generatedRoute.build())); assertThat( _routingProcess.activateGeneratedRoute( delta, generatedRoute.setGenerationPolicy(policyName).build()), nullValue()); assertThat( _routingProcess.activateGeneratedRoute( delta, generatedRoute.setGenerationPolicy("nonexistent").build()), nullValue()); }
@Nullable @VisibleForTesting GeneratedRoute activateGeneratedRoute( RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta, GeneratedRoute r) { String generationPolicyName = r.getGenerationPolicy(); if (generationPolicyName == null) { return r; } RoutingPolicy generationPolicy = _c.getRoutingPolicies().get(generationPolicyName); if (generationPolicy == null) { return null; } GeneratedRoute.Builder activatedRoute = GeneratedRouteHelper.activateGeneratedRoute( r, generationPolicy, mainRibDelta.getRoutesStream().collect(ImmutableSet.toImmutableSet())); return activatedRoute == null ? null : activatedRoute.build(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nullable @VisibleForTesting GeneratedRoute activateGeneratedRoute( RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta, GeneratedRoute r) { String generationPolicyName = r.getGenerationPolicy(); if (generationPolicyName == null) { return r; } RoutingPolicy generationPolicy = _c.getRoutingPolicies().get(generationPolicyName); if (generationPolicy == null) { return null; } GeneratedRoute.Builder activatedRoute = GeneratedRouteHelper.activateGeneratedRoute( r, generationPolicy, mainRibDelta.getRoutesStream().collect(ImmutableSet.toImmutableSet())); return activatedRoute == null ? null : activatedRoute.build(); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nullable @VisibleForTesting GeneratedRoute activateGeneratedRoute( RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta, GeneratedRoute r) { String generationPolicyName = r.getGenerationPolicy(); if (generationPolicyName == null) { return r; } RoutingPolicy generationPolicy = _c.getRoutingPolicies().get(generationPolicyName); if (generationPolicy == null) { return null; } GeneratedRoute.Builder activatedRoute = GeneratedRouteHelper.activateGeneratedRoute( r, generationPolicy, mainRibDelta.getRoutesStream().collect(ImmutableSet.toImmutableSet())); return activatedRoute == null ? null : activatedRoute.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nullable @VisibleForTesting GeneratedRoute activateGeneratedRoute( RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta, GeneratedRoute r) { String generationPolicyName = r.getGenerationPolicy(); if (generationPolicyName == null) { return r; } RoutingPolicy generationPolicy = _c.getRoutingPolicies().get(generationPolicyName); if (generationPolicy == null) { return null; } GeneratedRoute.Builder activatedRoute = GeneratedRouteHelper.activateGeneratedRoute( r, generationPolicy, mainRibDelta.getRoutesStream().collect(ImmutableSet.toImmutableSet())); return activatedRoute == null ? null : activatedRoute.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nullable @VisibleForTesting GeneratedRoute activateGeneratedRoute( RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta, GeneratedRoute r) { String generationPolicyName = r.getGenerationPolicy(); if (generationPolicyName == null) { return r; } RoutingPolicy generationPolicy = _c.getRoutingPolicies().get(generationPolicyName); if (generationPolicy == null) { return null; } GeneratedRoute.Builder activatedRoute = GeneratedRouteHelper.activateGeneratedRoute( r, generationPolicy, mainRibDelta.getRoutesStream().collect(ImmutableSet.toImmutableSet())); return activatedRoute == null ? null : activatedRoute.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty();  }