@Test public void testComputeInterfaceHostSubnetIpsWithPrefixLength31() { Configuration c1 = _cb.build(); Map<String, Configuration> configs = ImmutableMap.of(c1.getHostname(), c1); Vrf vrf1 = _vb.setOwner(c1).build(); Prefix prefix = Prefix.parse("1.0.0.1/31"); Interface i1 = _ib.setOwner(c1) .setVrf(vrf1) .setAddress( ConcreteInterfaceAddress.create(prefix.getStartIp(), prefix.getPrefixLength())) .build(); Map<String, Map<String, IpSpace>> interfaceHostSubnetIps = computeInterfaceHostSubnetIps(configs, false); assertThat( interfaceHostSubnetIps, hasEntry( equalTo(c1.getHostname()), hasEntry( equalTo(i1.getName()), allOf(containsIp(prefix.getStartIp()), containsIp(prefix.getEndIp()))))); }
@VisibleForTesting static Map<String, Map<String, IpSpace>> computeInterfaceHostSubnetIps( Map<String, Configuration> configs, boolean excludeInactive) { Span span = GlobalTracer.get().buildSpan("IpOwners.computeInterfaceHostSubnetIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configs, Entry::getKey, nodeEntry -> toImmutableMap( excludeInactive ? nodeEntry.getValue().getActiveInterfaces() : nodeEntry.getValue().getAllInterfaces(), Entry::getKey, ifaceEntry -> firstNonNull( AclIpSpace.union( ifaceEntry.getValue().getAllConcreteAddresses().stream() .map(ConcreteInterfaceAddress::getPrefix) .map(Prefix::toHostIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE))); } finally { span.finish(); } }
IpOwners { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeInterfaceHostSubnetIps( Map<String, Configuration> configs, boolean excludeInactive) { Span span = GlobalTracer.get().buildSpan("IpOwners.computeInterfaceHostSubnetIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configs, Entry::getKey, nodeEntry -> toImmutableMap( excludeInactive ? nodeEntry.getValue().getActiveInterfaces() : nodeEntry.getValue().getAllInterfaces(), Entry::getKey, ifaceEntry -> firstNonNull( AclIpSpace.union( ifaceEntry.getValue().getAllConcreteAddresses().stream() .map(ConcreteInterfaceAddress::getPrefix) .map(Prefix::toHostIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE))); } finally { span.finish(); } } }
IpOwners { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeInterfaceHostSubnetIps( Map<String, Configuration> configs, boolean excludeInactive) { Span span = GlobalTracer.get().buildSpan("IpOwners.computeInterfaceHostSubnetIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configs, Entry::getKey, nodeEntry -> toImmutableMap( excludeInactive ? nodeEntry.getValue().getActiveInterfaces() : nodeEntry.getValue().getAllInterfaces(), Entry::getKey, ifaceEntry -> firstNonNull( AclIpSpace.union( ifaceEntry.getValue().getAllConcreteAddresses().stream() .map(ConcreteInterfaceAddress::getPrefix) .map(Prefix::toHostIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE))); } finally { span.finish(); } } IpOwners(Map<String, Configuration> configurations); }
IpOwners { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeInterfaceHostSubnetIps( Map<String, Configuration> configs, boolean excludeInactive) { Span span = GlobalTracer.get().buildSpan("IpOwners.computeInterfaceHostSubnetIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configs, Entry::getKey, nodeEntry -> toImmutableMap( excludeInactive ? nodeEntry.getValue().getActiveInterfaces() : nodeEntry.getValue().getAllInterfaces(), Entry::getKey, ifaceEntry -> firstNonNull( AclIpSpace.union( ifaceEntry.getValue().getAllConcreteAddresses().stream() .map(ConcreteInterfaceAddress::getPrefix) .map(Prefix::toHostIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE))); } finally { span.finish(); } } IpOwners(Map<String, Configuration> configurations); static Map<String, Map<String, Set<Ip>>> computeInterfaceOwnedIps(
      Map<String, Configuration> configurations, boolean excludeInactive); static Map<Ip, Set<String>> computeIpNodeOwners(
      Map<String, Configuration> configurations, boolean excludeInactive); Map<Ip, Map<String, Set<String>>> getActiveDeviceOwnedIps(); Map<Ip, Map<String, Set<String>>> getAllDeviceOwnedIps(); Map<String, Map<String, IpSpace>> getAllInterfaceHostIps(); Map<String, Map<String, IpSpace>> getInterfaceOwnedIpSpaces(); Map<Ip, Map<String, Set<String>>> getIpVrfOwners(); Map<String, Map<String, Map<String, IpSpace>>> getVrfIfaceOwnedIpSpaces(); }
IpOwners { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeInterfaceHostSubnetIps( Map<String, Configuration> configs, boolean excludeInactive) { Span span = GlobalTracer.get().buildSpan("IpOwners.computeInterfaceHostSubnetIps").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( configs, Entry::getKey, nodeEntry -> toImmutableMap( excludeInactive ? nodeEntry.getValue().getActiveInterfaces() : nodeEntry.getValue().getAllInterfaces(), Entry::getKey, ifaceEntry -> firstNonNull( AclIpSpace.union( ifaceEntry.getValue().getAllConcreteAddresses().stream() .map(ConcreteInterfaceAddress::getPrefix) .map(Prefix::toHostIpSpace) .collect(ImmutableList.toImmutableList())), EmptyIpSpace.INSTANCE))); } finally { span.finish(); } } IpOwners(Map<String, Configuration> configurations); static Map<String, Map<String, Set<Ip>>> computeInterfaceOwnedIps(
      Map<String, Configuration> configurations, boolean excludeInactive); static Map<Ip, Set<String>> computeIpNodeOwners(
      Map<String, Configuration> configurations, boolean excludeInactive); Map<Ip, Map<String, Set<String>>> getActiveDeviceOwnedIps(); Map<Ip, Map<String, Set<String>>> getAllDeviceOwnedIps(); Map<String, Map<String, IpSpace>> getAllInterfaceHostIps(); Map<String, Map<String, IpSpace>> getInterfaceOwnedIpSpaces(); Map<Ip, Map<String, Set<String>>> getIpVrfOwners(); Map<String, Map<String, Map<String, IpSpace>>> getVrfIfaceOwnedIpSpaces();  }