@Test public void testGetInternetAndIspsCaseInsensitive() { NetworkFactory nf = new NetworkFactory(); Configuration.Builder cb = nf.configurationBuilder(); Configuration configuration = cb.setHostname("conf").setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); nf.vrfBuilder().setName(DEFAULT_VRF_NAME).setOwner(configuration).build(); nf.interfaceBuilder() .setName("Interface") .setOwner(configuration) .setAddress(ConcreteInterfaceAddress.create(Ip.parse("2.2.2.2"), 24)) .build(); BgpActivePeerConfig peer = BgpActivePeerConfig.builder() .setPeerAddress(Ip.parse("1.1.1.1")) .setRemoteAs(1L) .setLocalIp(Ip.parse("2.2.2.2")) .setLocalAs(2L) .setIpv4UnicastAddressFamily(Ipv4UnicastAddressFamily.builder().build()) .build(); BgpProcess bgpProcess = new BgpProcess(Ip.ZERO, ConfigurationFormat.CISCO_IOS); bgpProcess.getActiveNeighbors().put(Prefix.parse("1.1.1.1/32"), peer); configuration.getDefaultVrf().setBgpProcess(bgpProcess); Map<String, Configuration> internetAndIsps = IspModelingUtils.getInternetAndIspNodes( ImmutableMap.of(configuration.getHostname(), configuration), ImmutableList.of( new IspConfiguration( ImmutableList.of( new BorderInterfaceInfo(NodeInterfacePair.of("CoNf", "InTeRfAcE"))), IspFilter.ALLOW_ALL)), new BatfishLogger("output", false), new Warnings()) .getConfigurations(); assertThat(internetAndIsps, hasKey("isp_1")); assertThat(internetAndIsps, hasKey("internet")); }
public static ModeledNodes getInternetAndIspNodes( @Nonnull Map<String, Configuration> configurations, @Nonnull List<IspConfiguration> ispConfigurations, @Nonnull BatfishLogger logger, @Nonnull Warnings warnings) { NetworkFactory nf = new NetworkFactory(); Map<Long, IspModel> asnToIspInfos = combineIspConfigurations(configurations, ispConfigurations, warnings); List<String> conflicts = ispNameConflicts(configurations, asnToIspInfos); if (!conflicts.isEmpty()) { conflicts.forEach(warnings::redFlag); return new ModeledNodes(); } return createInternetAndIspNodes(asnToIspInfos, nf, logger); }
IspModelingUtils { public static ModeledNodes getInternetAndIspNodes( @Nonnull Map<String, Configuration> configurations, @Nonnull List<IspConfiguration> ispConfigurations, @Nonnull BatfishLogger logger, @Nonnull Warnings warnings) { NetworkFactory nf = new NetworkFactory(); Map<Long, IspModel> asnToIspInfos = combineIspConfigurations(configurations, ispConfigurations, warnings); List<String> conflicts = ispNameConflicts(configurations, asnToIspInfos); if (!conflicts.isEmpty()) { conflicts.forEach(warnings::redFlag); return new ModeledNodes(); } return createInternetAndIspNodes(asnToIspInfos, nf, logger); } }
IspModelingUtils { public static ModeledNodes getInternetAndIspNodes( @Nonnull Map<String, Configuration> configurations, @Nonnull List<IspConfiguration> ispConfigurations, @Nonnull BatfishLogger logger, @Nonnull Warnings warnings) { NetworkFactory nf = new NetworkFactory(); Map<Long, IspModel> asnToIspInfos = combineIspConfigurations(configurations, ispConfigurations, warnings); List<String> conflicts = ispNameConflicts(configurations, asnToIspInfos); if (!conflicts.isEmpty()) { conflicts.forEach(warnings::redFlag); return new ModeledNodes(); } return createInternetAndIspNodes(asnToIspInfos, nf, logger); } private  IspModelingUtils(); }
IspModelingUtils { public static ModeledNodes getInternetAndIspNodes( @Nonnull Map<String, Configuration> configurations, @Nonnull List<IspConfiguration> ispConfigurations, @Nonnull BatfishLogger logger, @Nonnull Warnings warnings) { NetworkFactory nf = new NetworkFactory(); Map<Long, IspModel> asnToIspInfos = combineIspConfigurations(configurations, ispConfigurations, warnings); List<String> conflicts = ispNameConflicts(configurations, asnToIspInfos); if (!conflicts.isEmpty()) { conflicts.forEach(warnings::redFlag); return new ModeledNodes(); } return createInternetAndIspNodes(asnToIspInfos, nf, logger); } private  IspModelingUtils(); static String getDefaultIspNodeName(long asn); static String internetToIspInterfaceName(String ispHostname); static String ispToRemoteInterfaceName(String remoteHostname, String remoteInterfaceName); static ModeledNodes getInternetAndIspNodes(
      @Nonnull Map<String, Configuration> configurations,
      @Nonnull List<IspConfiguration> ispConfigurations,
      @Nonnull BatfishLogger logger,
      @Nonnull Warnings warnings); static RoutingPolicy installRoutingPolicyAdvertiseStatic(
      String policyName, Configuration node, PrefixSpace prefixSpace); static Statement getAdvertiseStaticStatement(PrefixSpace prefixSpace); static Statement getAdvertiseBgpStatement(); }
IspModelingUtils { public static ModeledNodes getInternetAndIspNodes( @Nonnull Map<String, Configuration> configurations, @Nonnull List<IspConfiguration> ispConfigurations, @Nonnull BatfishLogger logger, @Nonnull Warnings warnings) { NetworkFactory nf = new NetworkFactory(); Map<Long, IspModel> asnToIspInfos = combineIspConfigurations(configurations, ispConfigurations, warnings); List<String> conflicts = ispNameConflicts(configurations, asnToIspInfos); if (!conflicts.isEmpty()) { conflicts.forEach(warnings::redFlag); return new ModeledNodes(); } return createInternetAndIspNodes(asnToIspInfos, nf, logger); } private  IspModelingUtils(); static String getDefaultIspNodeName(long asn); static String internetToIspInterfaceName(String ispHostname); static String ispToRemoteInterfaceName(String remoteHostname, String remoteInterfaceName); static ModeledNodes getInternetAndIspNodes(
      @Nonnull Map<String, Configuration> configurations,
      @Nonnull List<IspConfiguration> ispConfigurations,
      @Nonnull BatfishLogger logger,
      @Nonnull Warnings warnings); static RoutingPolicy installRoutingPolicyAdvertiseStatic(
      String policyName, Configuration node, PrefixSpace prefixSpace); static Statement getAdvertiseStaticStatement(PrefixSpace prefixSpace); static Statement getAdvertiseBgpStatement(); static final String INTERNET_HOST_NAME; static final String INTERNET_OUT_INTERFACE; static final Set<Prefix> INTERNET_NULL_ROUTED_PREFIXES; }