@Test public void testConvertIpv4UnicastAddressFamily_deactivated() { NetworkFactory nf = new NetworkFactory(); Configuration viConfig = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CUMULUS_NCLU).build(); RoutingPolicy policy = nf.routingPolicyBuilder().build(); CumulusNcluConfiguration vsConfig = new CumulusNcluConfiguration(); vsConfig.setConfiguration(viConfig); BgpNeighborIpv4UnicastAddressFamily af = new BgpNeighborIpv4UnicastAddressFamily(); af.setRouteReflectorClient(true); af.setActivated(false); assertNull(convertIpv4UnicastAddressFamily(af, true, policy, null)); assertNull(convertIpv4UnicastAddressFamily(af, false, policy, null)); af.setActivated(true); assertNotNull(convertIpv4UnicastAddressFamily(af, true, policy, null)); assertNotNull(convertIpv4UnicastAddressFamily(af, false, policy, null)); af.setActivated(null); assertNotNull(convertIpv4UnicastAddressFamily(af, true, policy, null)); assertNull(convertIpv4UnicastAddressFamily(af, false, policy, null)); }
@VisibleForTesting @Nullable static Ipv4UnicastAddressFamily convertIpv4UnicastAddressFamily( @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily, boolean defaultIpv4Unicast, RoutingPolicy exportRoutingPolicy, @Nullable RoutingPolicy importRoutingPolicy) { boolean explicitActivationSetting = ipv4UnicastAddressFamily != null && ipv4UnicastAddressFamily.getActivated() != null; if ((explicitActivationSetting && !ipv4UnicastAddressFamily.getActivated()) || (!explicitActivationSetting && !defaultIpv4Unicast)) { return null; } boolean routeReflectorClient = Optional.ofNullable(ipv4UnicastAddressFamily) .map(af -> Boolean.TRUE.equals(af.getRouteReflectorClient())) .orElse(false); return Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities( AddressFamilyCapabilities.builder() .setSendCommunity(true) .setSendExtendedCommunity(true) .setAllowLocalAsIn( (ipv4UnicastAddressFamily != null && (firstNonNull(ipv4UnicastAddressFamily.getAllowAsIn(), 0) > 0))) .setAllowRemoteAsOut(true) .build()) .setExportPolicy(exportRoutingPolicy.getName()) .setImportPolicy(importRoutingPolicy == null ? null : importRoutingPolicy.getName()) .setRouteReflectorClient(routeReflectorClient) .build(); }
CumulusConversions { @VisibleForTesting @Nullable static Ipv4UnicastAddressFamily convertIpv4UnicastAddressFamily( @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily, boolean defaultIpv4Unicast, RoutingPolicy exportRoutingPolicy, @Nullable RoutingPolicy importRoutingPolicy) { boolean explicitActivationSetting = ipv4UnicastAddressFamily != null && ipv4UnicastAddressFamily.getActivated() != null; if ((explicitActivationSetting && !ipv4UnicastAddressFamily.getActivated()) || (!explicitActivationSetting && !defaultIpv4Unicast)) { return null; } boolean routeReflectorClient = Optional.ofNullable(ipv4UnicastAddressFamily) .map(af -> Boolean.TRUE.equals(af.getRouteReflectorClient())) .orElse(false); return Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities( AddressFamilyCapabilities.builder() .setSendCommunity(true) .setSendExtendedCommunity(true) .setAllowLocalAsIn( (ipv4UnicastAddressFamily != null && (firstNonNull(ipv4UnicastAddressFamily.getAllowAsIn(), 0) > 0))) .setAllowRemoteAsOut(true) .build()) .setExportPolicy(exportRoutingPolicy.getName()) .setImportPolicy(importRoutingPolicy == null ? null : importRoutingPolicy.getName()) .setRouteReflectorClient(routeReflectorClient) .build(); } }
CumulusConversions { @VisibleForTesting @Nullable static Ipv4UnicastAddressFamily convertIpv4UnicastAddressFamily( @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily, boolean defaultIpv4Unicast, RoutingPolicy exportRoutingPolicy, @Nullable RoutingPolicy importRoutingPolicy) { boolean explicitActivationSetting = ipv4UnicastAddressFamily != null && ipv4UnicastAddressFamily.getActivated() != null; if ((explicitActivationSetting && !ipv4UnicastAddressFamily.getActivated()) || (!explicitActivationSetting && !defaultIpv4Unicast)) { return null; } boolean routeReflectorClient = Optional.ofNullable(ipv4UnicastAddressFamily) .map(af -> Boolean.TRUE.equals(af.getRouteReflectorClient())) .orElse(false); return Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities( AddressFamilyCapabilities.builder() .setSendCommunity(true) .setSendExtendedCommunity(true) .setAllowLocalAsIn( (ipv4UnicastAddressFamily != null && (firstNonNull(ipv4UnicastAddressFamily.getAllowAsIn(), 0) > 0))) .setAllowRemoteAsOut(true) .build()) .setExportPolicy(exportRoutingPolicy.getName()) .setImportPolicy(importRoutingPolicy == null ? null : importRoutingPolicy.getName()) .setRouteReflectorClient(routeReflectorClient) .build(); }  }
CumulusConversions { @VisibleForTesting @Nullable static Ipv4UnicastAddressFamily convertIpv4UnicastAddressFamily( @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily, boolean defaultIpv4Unicast, RoutingPolicy exportRoutingPolicy, @Nullable RoutingPolicy importRoutingPolicy) { boolean explicitActivationSetting = ipv4UnicastAddressFamily != null && ipv4UnicastAddressFamily.getActivated() != null; if ((explicitActivationSetting && !ipv4UnicastAddressFamily.getActivated()) || (!explicitActivationSetting && !defaultIpv4Unicast)) { return null; } boolean routeReflectorClient = Optional.ofNullable(ipv4UnicastAddressFamily) .map(af -> Boolean.TRUE.equals(af.getRouteReflectorClient())) .orElse(false); return Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities( AddressFamilyCapabilities.builder() .setSendCommunity(true) .setSendExtendedCommunity(true) .setAllowLocalAsIn( (ipv4UnicastAddressFamily != null && (firstNonNull(ipv4UnicastAddressFamily.getAllowAsIn(), 0) > 0))) .setAllowRemoteAsOut(true) .build()) .setExportPolicy(exportRoutingPolicy.getName()) .setImportPolicy(importRoutingPolicy == null ? null : importRoutingPolicy.getName()) .setRouteReflectorClient(routeReflectorClient) .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 @Nullable static Ipv4UnicastAddressFamily convertIpv4UnicastAddressFamily( @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily, boolean defaultIpv4Unicast, RoutingPolicy exportRoutingPolicy, @Nullable RoutingPolicy importRoutingPolicy) { boolean explicitActivationSetting = ipv4UnicastAddressFamily != null && ipv4UnicastAddressFamily.getActivated() != null; if ((explicitActivationSetting && !ipv4UnicastAddressFamily.getActivated()) || (!explicitActivationSetting && !defaultIpv4Unicast)) { return null; } boolean routeReflectorClient = Optional.ofNullable(ipv4UnicastAddressFamily) .map(af -> Boolean.TRUE.equals(af.getRouteReflectorClient())) .orElse(false); return Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities( AddressFamilyCapabilities.builder() .setSendCommunity(true) .setSendExtendedCommunity(true) .setAllowLocalAsIn( (ipv4UnicastAddressFamily != null && (firstNonNull(ipv4UnicastAddressFamily.getAllowAsIn(), 0) > 0))) .setAllowRemoteAsOut(true) .build()) .setExportPolicy(exportRoutingPolicy.getName()) .setImportPolicy(importRoutingPolicy == null ? null : importRoutingPolicy.getName()) .setRouteReflectorClient(routeReflectorClient) .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; }