@Test public void testInferRouterID_LoopbackNotUsable() { assertThat( inferRouterId(getConfigurationWithLoopback(ConcreteInterfaceAddress.parse("127.0.0.2/31"))), equalTo(Ip.parse("0.0.0.0"))); }
@VisibleForTesting static Ip inferRouterId(Configuration c) { if (c.getAllInterfaces().containsKey(LOOPBACK_INTERFACE_NAME)) { Optional<ConcreteInterfaceAddress> maxLoIp = c.getAllInterfaces().get(LOOPBACK_INTERFACE_NAME).getAllConcreteAddresses().stream() .filter(addr -> !LOOPBACK_PREFIX.containsIp(addr.getIp())) .max(ConcreteInterfaceAddress::compareTo); if (maxLoIp.isPresent()) { return maxLoIp.get().getIp(); } } Optional<ConcreteInterfaceAddress> biggestInterfaceIp = c.getAllInterfaces().values().stream() .filter(iface -> !iface.getName().equals(LOOPBACK_INTERFACE_NAME)) .flatMap(iface -> iface.getAllConcreteAddresses().stream()) .max(InterfaceAddress::compareTo); return biggestInterfaceIp .map(ConcreteInterfaceAddress::getIp) .orElseGet(() -> Ip.parse("0.0.0.0")); }
CumulusConversions { @VisibleForTesting static Ip inferRouterId(Configuration c) { if (c.getAllInterfaces().containsKey(LOOPBACK_INTERFACE_NAME)) { Optional<ConcreteInterfaceAddress> maxLoIp = c.getAllInterfaces().get(LOOPBACK_INTERFACE_NAME).getAllConcreteAddresses().stream() .filter(addr -> !LOOPBACK_PREFIX.containsIp(addr.getIp())) .max(ConcreteInterfaceAddress::compareTo); if (maxLoIp.isPresent()) { return maxLoIp.get().getIp(); } } Optional<ConcreteInterfaceAddress> biggestInterfaceIp = c.getAllInterfaces().values().stream() .filter(iface -> !iface.getName().equals(LOOPBACK_INTERFACE_NAME)) .flatMap(iface -> iface.getAllConcreteAddresses().stream()) .max(InterfaceAddress::compareTo); return biggestInterfaceIp .map(ConcreteInterfaceAddress::getIp) .orElseGet(() -> Ip.parse("0.0.0.0")); } }
CumulusConversions { @VisibleForTesting static Ip inferRouterId(Configuration c) { if (c.getAllInterfaces().containsKey(LOOPBACK_INTERFACE_NAME)) { Optional<ConcreteInterfaceAddress> maxLoIp = c.getAllInterfaces().get(LOOPBACK_INTERFACE_NAME).getAllConcreteAddresses().stream() .filter(addr -> !LOOPBACK_PREFIX.containsIp(addr.getIp())) .max(ConcreteInterfaceAddress::compareTo); if (maxLoIp.isPresent()) { return maxLoIp.get().getIp(); } } Optional<ConcreteInterfaceAddress> biggestInterfaceIp = c.getAllInterfaces().values().stream() .filter(iface -> !iface.getName().equals(LOOPBACK_INTERFACE_NAME)) .flatMap(iface -> iface.getAllConcreteAddresses().stream()) .max(InterfaceAddress::compareTo); return biggestInterfaceIp .map(ConcreteInterfaceAddress::getIp) .orElseGet(() -> Ip.parse("0.0.0.0")); }  }
CumulusConversions { @VisibleForTesting static Ip inferRouterId(Configuration c) { if (c.getAllInterfaces().containsKey(LOOPBACK_INTERFACE_NAME)) { Optional<ConcreteInterfaceAddress> maxLoIp = c.getAllInterfaces().get(LOOPBACK_INTERFACE_NAME).getAllConcreteAddresses().stream() .filter(addr -> !LOOPBACK_PREFIX.containsIp(addr.getIp())) .max(ConcreteInterfaceAddress::compareTo); if (maxLoIp.isPresent()) { return maxLoIp.get().getIp(); } } Optional<ConcreteInterfaceAddress> biggestInterfaceIp = c.getAllInterfaces().values().stream() .filter(iface -> !iface.getName().equals(LOOPBACK_INTERFACE_NAME)) .flatMap(iface -> iface.getAllConcreteAddresses().stream()) .max(InterfaceAddress::compareTo); return biggestInterfaceIp .map(ConcreteInterfaceAddress::getIp) .orElseGet(() -> Ip.parse("0.0.0.0")); }  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 Ip inferRouterId(Configuration c) { if (c.getAllInterfaces().containsKey(LOOPBACK_INTERFACE_NAME)) { Optional<ConcreteInterfaceAddress> maxLoIp = c.getAllInterfaces().get(LOOPBACK_INTERFACE_NAME).getAllConcreteAddresses().stream() .filter(addr -> !LOOPBACK_PREFIX.containsIp(addr.getIp())) .max(ConcreteInterfaceAddress::compareTo); if (maxLoIp.isPresent()) { return maxLoIp.get().getIp(); } } Optional<ConcreteInterfaceAddress> biggestInterfaceIp = c.getAllInterfaces().values().stream() .filter(iface -> !iface.getName().equals(LOOPBACK_INTERFACE_NAME)) .flatMap(iface -> iface.getAllConcreteAddresses().stream()) .max(InterfaceAddress::compareTo); return biggestInterfaceIp .map(ConcreteInterfaceAddress::getIp) .orElseGet(() -> Ip.parse("0.0.0.0")); }  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; }