@Test public void testIsRouteReflector() { BgpProcess emptyProcess = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); assertFalse("no rr clients", isIpv4UnicastRouteReflector(emptyProcess)); Ipv4UnicastAddressFamily.Builder v4afBuilder = Ipv4UnicastAddressFamily.builder(); Builder builder = BgpActivePeerConfig.builder(); BgpActivePeerConfig activePeerWithRRC = builder .setIpv4UnicastAddressFamily(v4afBuilder.setRouteReflectorClient(true).build()) .build(); BgpActivePeerConfig activePeerWithoutRRC = builder .setIpv4UnicastAddressFamily(v4afBuilder.setRouteReflectorClient(false).build()) .build(); BgpPassivePeerConfig passivePeerWithRRC = BgpPassivePeerConfig.builder() .setIpv4UnicastAddressFamily(v4afBuilder.setRouteReflectorClient(true).build()) .build(); BgpPassivePeerConfig passivePeerWithoutRRC = BgpPassivePeerConfig.builder() .setIpv4UnicastAddressFamily(v4afBuilder.setRouteReflectorClient(false).build()) .build(); String peerInterface = "iface"; BgpUnnumberedPeerConfig unnumberedPeerWithRRC = BgpUnnumberedPeerConfig.builder() .setPeerInterface(peerInterface) .setIpv4UnicastAddressFamily(v4afBuilder.setRouteReflectorClient(true).build()) .build(); Prefix p32a = Prefix.parse("1.2.3.4/32"); Prefix p32b = Prefix.parse("1.2.3.5/32"); Prefix p30a = Prefix.parse("1.2.3.4/30"); Prefix p30b = Prefix.parse("1.2.3.8/30"); BgpProcess hasActiveNeighbor = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); hasActiveNeighbor.setNeighbors(ImmutableSortedMap.of(p32a, activePeerWithRRC)); assertTrue("has active rr client", isIpv4UnicastRouteReflector(hasActiveNeighbor)); BgpProcess hasPassiveNeighbor = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); hasPassiveNeighbor.setPassiveNeighbors(ImmutableSortedMap.of(p30a, passivePeerWithRRC)); assertTrue("has passive rr client", isIpv4UnicastRouteReflector(hasPassiveNeighbor)); BgpProcess hasUnnumberedNeighbor = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); hasUnnumberedNeighbor.setInterfaceNeighbors( ImmutableSortedMap.of(peerInterface, unnumberedPeerWithRRC)); assertTrue("has unnumbered rr client", isIpv4UnicastRouteReflector(hasUnnumberedNeighbor)); BgpProcess hasNeighborMix = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); hasNeighborMix.setNeighbors( ImmutableSortedMap.of(p32a, activePeerWithoutRRC, p32b, activePeerWithRRC)); hasNeighborMix.setPassiveNeighbors( ImmutableSortedMap.of(p30a, passivePeerWithoutRRC, p30b, passivePeerWithRRC)); assertTrue( "has mix of active and inactive rr client", isIpv4UnicastRouteReflector(hasNeighborMix)); BgpProcess hasAllInactive = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); hasAllInactive.setNeighbors(ImmutableSortedMap.of(p32a, activePeerWithoutRRC)); hasAllInactive.setPassiveNeighbors(ImmutableSortedMap.of(p30a, passivePeerWithoutRRC)); assertFalse("has multiple inactive rr clients", isIpv4UnicastRouteReflector(hasAllInactive)); }
public static boolean isIpv4UnicastRouteReflector(BgpProcess p) { return StreamSupport.stream(p.getAllPeerConfigs().spliterator(), false) .map(BgpPeerConfig::getIpv4UnicastAddressFamily) .filter(Objects::nonNull) .anyMatch(AddressFamily::getRouteReflectorClient); }
BgpProcessPropertySpecifier extends PropertySpecifier { public static boolean isIpv4UnicastRouteReflector(BgpProcess p) { return StreamSupport.stream(p.getAllPeerConfigs().spliterator(), false) .map(BgpPeerConfig::getIpv4UnicastAddressFamily) .filter(Objects::nonNull) .anyMatch(AddressFamily::getRouteReflectorClient); } }
BgpProcessPropertySpecifier extends PropertySpecifier { public static boolean isIpv4UnicastRouteReflector(BgpProcess p) { return StreamSupport.stream(p.getAllPeerConfigs().spliterator(), false) .map(BgpPeerConfig::getIpv4UnicastAddressFamily) .filter(Objects::nonNull) .anyMatch(AddressFamily::getRouteReflectorClient); } BgpProcessPropertySpecifier(Set<String> properties); }
BgpProcessPropertySpecifier extends PropertySpecifier { public static boolean isIpv4UnicastRouteReflector(BgpProcess p) { return StreamSupport.stream(p.getAllPeerConfigs().spliterator(), false) .map(BgpPeerConfig::getIpv4UnicastAddressFamily) .filter(Objects::nonNull) .anyMatch(AddressFamily::getRouteReflectorClient); } BgpProcessPropertySpecifier(Set<String> properties); static PropertyDescriptor<BgpProcess> getPropertyDescriptor(String property); static BgpProcessPropertySpecifier create(@Nullable String expression); @Nonnull @Override List<String> getMatchingProperties(); static boolean isIpv4UnicastRouteReflector(BgpProcess p); @Override boolean equals(Object o); @Override int hashCode(); }
BgpProcessPropertySpecifier extends PropertySpecifier { public static boolean isIpv4UnicastRouteReflector(BgpProcess p) { return StreamSupport.stream(p.getAllPeerConfigs().spliterator(), false) .map(BgpPeerConfig::getIpv4UnicastAddressFamily) .filter(Objects::nonNull) .anyMatch(AddressFamily::getRouteReflectorClient); } BgpProcessPropertySpecifier(Set<String> properties); static PropertyDescriptor<BgpProcess> getPropertyDescriptor(String property); static BgpProcessPropertySpecifier create(@Nullable String expression); @Nonnull @Override List<String> getMatchingProperties(); static boolean isIpv4UnicastRouteReflector(BgpProcess p); @Override boolean equals(Object o); @Override int hashCode(); static final String CONFEDERATION_ID; static final String CONFEDERATION_MEMBERS; static final String MULTIPATH_EQUIVALENT_AS_PATH_MATCH_MODE; static final String MULTIPATH_EBGP; static final String MULTIPATH_IBGP; static final String NEIGHBORS; static final String ROUTE_REFLECTOR; static final String TIE_BREAKER; static final BgpProcessPropertySpecifier ALL; }