@Test public void testProcessIsisInterfaceSettings() { JuniperConfiguration config = createConfig(); String loopbackName = "lo0.0"; String iface1Name = "iface1"; String iface2Name = "iface2"; Vrf vrf = new Vrf("vrf"); org.batfish.datamodel.Interface.builder() .setOwner(config._c) .setName(loopbackName) .setVrf(vrf) .setType(InterfaceType.LOOPBACK) .build(); org.batfish.datamodel.Interface.builder() .setName(iface1Name) .setOwner(config._c) .setVrf(vrf) .build(); org.batfish.datamodel.Interface.builder() .setName(iface2Name) .setOwner(config._c) .setVrf(vrf) .build(); config._c.setVrfs(ImmutableMap.of("vrf", vrf)); RoutingInstance routingInstance = new RoutingInstance("vrf"); Interface vsLoopback = new Interface(loopbackName); vsLoopback.getOrInitIsisSettings(); routingInstance.getInterfaces().put(loopbackName, vsLoopback); { Interface vsIface1 = new Interface(iface1Name); Interface vsIface2 = new Interface(iface2Name); vsIface1.getOrInitIsisSettings().getLevel1Settings().setEnabled(false); vsIface2.getOrInitIsisSettings().getLevel2Settings().setEnabled(false); routingInstance.getInterfaces().put(iface1Name, vsIface1); routingInstance.getInterfaces().put(iface2Name, vsIface2); assertThat( config.processIsisInterfaceSettings(routingInstance, true, true), equalTo(IsisLevel.LEVEL_1_2)); assertThat( config.processIsisInterfaceSettings(routingInstance, true, false), equalTo(IsisLevel.LEVEL_1)); assertThat( config.processIsisInterfaceSettings(routingInstance, false, true), equalTo(IsisLevel.LEVEL_2)); } { Interface vsIface1 = new Interface(iface1Name); Interface vsIface2 = new Interface(iface2Name); vsIface1.getOrInitIsisSettings().getLevel2Settings().setEnabled(false); routingInstance.getInterfaces().put(iface1Name, vsIface1); routingInstance.getInterfaces().put(iface2Name, vsIface2); assertThat( config.processIsisInterfaceSettings(routingInstance, true, true), equalTo(IsisLevel.LEVEL_1)); } { Interface vsIface1 = new Interface(iface1Name); Interface vsIface2 = new Interface(iface2Name); vsIface1.getOrInitIsisSettings().getLevel1Settings().setEnabled(false); routingInstance.getInterfaces().put(iface1Name, vsIface1); routingInstance.getInterfaces().put(iface2Name, vsIface2); assertThat( config.processIsisInterfaceSettings(routingInstance, true, true), equalTo(IsisLevel.LEVEL_2)); } }
@VisibleForTesting IsisLevel processIsisInterfaceSettings( RoutingInstance routingInstance, boolean level1, boolean level2) { return _c.getAllInterfaces(routingInstance.getName()).entrySet().stream() .map( e -> { String ifaceName = e.getKey(); org.batfish.datamodel.Interface newIface = e.getValue(); org.batfish.datamodel.isis.IsisInterfaceSettings settings = toIsisInterfaceSettings( routingInstance.getIsisSettings(), routingInstance.getInterfaces().get(ifaceName), level1, level2, newIface.isLoopback()); newIface.setIsis(settings); if (settings == null || newIface.isLoopback()) { return null; } return settings.getEnabledLevels(); }) .filter(Objects::nonNull) .reduce(IsisLevel::union) .orElse(null); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting IsisLevel processIsisInterfaceSettings( RoutingInstance routingInstance, boolean level1, boolean level2) { return _c.getAllInterfaces(routingInstance.getName()).entrySet().stream() .map( e -> { String ifaceName = e.getKey(); org.batfish.datamodel.Interface newIface = e.getValue(); org.batfish.datamodel.isis.IsisInterfaceSettings settings = toIsisInterfaceSettings( routingInstance.getIsisSettings(), routingInstance.getInterfaces().get(ifaceName), level1, level2, newIface.isLoopback()); newIface.setIsis(settings); if (settings == null || newIface.isLoopback()) { return null; } return settings.getEnabledLevels(); }) .filter(Objects::nonNull) .reduce(IsisLevel::union) .orElse(null); } }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting IsisLevel processIsisInterfaceSettings( RoutingInstance routingInstance, boolean level1, boolean level2) { return _c.getAllInterfaces(routingInstance.getName()).entrySet().stream() .map( e -> { String ifaceName = e.getKey(); org.batfish.datamodel.Interface newIface = e.getValue(); org.batfish.datamodel.isis.IsisInterfaceSettings settings = toIsisInterfaceSettings( routingInstance.getIsisSettings(), routingInstance.getInterfaces().get(ifaceName), level1, level2, newIface.isLoopback()); newIface.setIsis(settings); if (settings == null || newIface.isLoopback()) { return null; } return settings.getEnabledLevels(); }) .filter(Objects::nonNull) .reduce(IsisLevel::union) .orElse(null); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting IsisLevel processIsisInterfaceSettings( RoutingInstance routingInstance, boolean level1, boolean level2) { return _c.getAllInterfaces(routingInstance.getName()).entrySet().stream() .map( e -> { String ifaceName = e.getKey(); org.batfish.datamodel.Interface newIface = e.getValue(); org.batfish.datamodel.isis.IsisInterfaceSettings settings = toIsisInterfaceSettings( routingInstance.getIsisSettings(), routingInstance.getInterfaces().get(ifaceName), level1, level2, newIface.isLoopback()); newIface.setIsis(settings); if (settings == null || newIface.isLoopback()) { return null; } return settings.getEnabledLevels(); }) .filter(Objects::nonNull) .reduce(IsisLevel::union) .orElse(null); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting IsisLevel processIsisInterfaceSettings( RoutingInstance routingInstance, boolean level1, boolean level2) { return _c.getAllInterfaces(routingInstance.getName()).entrySet().stream() .map( e -> { String ifaceName = e.getKey(); org.batfish.datamodel.Interface newIface = e.getValue(); org.batfish.datamodel.isis.IsisInterfaceSettings settings = toIsisInterfaceSettings( routingInstance.getIsisSettings(), routingInstance.getInterfaces().get(ifaceName), level1, level2, newIface.isLoopback()); newIface.setIsis(settings); if (settings == null || newIface.isLoopback()) { return null; } return settings.getEnabledLevels(); }) .filter(Objects::nonNull) .reduce(IsisLevel::union) .orElse(null); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); static final String ACL_NAME_COMBINED_INCOMING; static final String ACL_NAME_GLOBAL_POLICY; static final String ACL_NAME_SCREEN; static final String ACL_NAME_SCREEN_INTERFACE; static final String ACL_NAME_SCREEN_ZONE; static final String ACL_NAME_SECURITY_POLICY; @VisibleForTesting static final int DEFAULT_ISIS_COST; }