@Test public void testFromNatPacketLocationMatchExprs() { JuniperConfiguration config = createConfig(); Interface parent = new Interface("parent"); String interface1Name = "interface1"; parent.getUnits().put(interface1Name, new Interface(interface1Name)); config.getMasterLogicalSystem().getInterfaces().put(parent.getName(), parent); Zone zone = new Zone("zone", new AddressBook("global", null)); String zoneInterface1Name = "zoneInterface1"; zone.getInterfaces().add(zoneInterface1Name); String zoneInterface2Name = "zoneInterface2"; zone.getInterfaces().add(zoneInterface2Name); config.getMasterLogicalSystem().getZones().put(zone.getName(), zone); RoutingInstance routingInstance = config.getMasterLogicalSystem().getDefaultRoutingInstance(); String routingInstanceInterface1Name = "routingInstanceInterface1"; routingInstance .getInterfaces() .put(routingInstanceInterface1Name, new Interface(routingInstanceInterface1Name)); String routingInstanceInterface2Name = "routingInstanceInterface2"; routingInstance .getInterfaces() .put(routingInstanceInterface2Name, new Interface(routingInstanceInterface2Name)); Map<NatPacketLocation, AclLineMatchExpr> matchExprs = config.fromNatPacketLocationMatchExprs(); assertThat( matchExprs, equalTo( ImmutableMap.of( interfaceLocation(interface1Name), matchSrcInterface(interface1Name), zoneLocation(zone.getName()), matchSrcInterface(zoneInterface1Name, zoneInterface2Name), routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstanceInterface1Name, routingInstanceInterface2Name)))); }
@VisibleForTesting Map<NatPacketLocation, AclLineMatchExpr> fromNatPacketLocationMatchExprs() { ImmutableMap.Builder<NatPacketLocation, AclLineMatchExpr> builder = ImmutableMap.builder(); _masterLogicalSystem .getInterfaces() .values() .forEach( iface -> iface .getUnits() .keySet() .forEach( ifaceUnit -> builder.put( interfaceLocation(ifaceUnit), matchSrcInterface(ifaceUnit)))); _masterLogicalSystem .getZones() .values() .forEach( zone -> builder.put( zoneLocation(zone.getName()), new MatchSrcInterface(zone.getInterfaces()))); _masterLogicalSystem .getRoutingInstances() .values() .forEach( routingInstance -> builder.put( routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstance.getInterfaces().values().stream() .map(Interface::getName) .toArray(String[]::new)))); return builder.build(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting Map<NatPacketLocation, AclLineMatchExpr> fromNatPacketLocationMatchExprs() { ImmutableMap.Builder<NatPacketLocation, AclLineMatchExpr> builder = ImmutableMap.builder(); _masterLogicalSystem .getInterfaces() .values() .forEach( iface -> iface .getUnits() .keySet() .forEach( ifaceUnit -> builder.put( interfaceLocation(ifaceUnit), matchSrcInterface(ifaceUnit)))); _masterLogicalSystem .getZones() .values() .forEach( zone -> builder.put( zoneLocation(zone.getName()), new MatchSrcInterface(zone.getInterfaces()))); _masterLogicalSystem .getRoutingInstances() .values() .forEach( routingInstance -> builder.put( routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstance.getInterfaces().values().stream() .map(Interface::getName) .toArray(String[]::new)))); return builder.build(); } }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting Map<NatPacketLocation, AclLineMatchExpr> fromNatPacketLocationMatchExprs() { ImmutableMap.Builder<NatPacketLocation, AclLineMatchExpr> builder = ImmutableMap.builder(); _masterLogicalSystem .getInterfaces() .values() .forEach( iface -> iface .getUnits() .keySet() .forEach( ifaceUnit -> builder.put( interfaceLocation(ifaceUnit), matchSrcInterface(ifaceUnit)))); _masterLogicalSystem .getZones() .values() .forEach( zone -> builder.put( zoneLocation(zone.getName()), new MatchSrcInterface(zone.getInterfaces()))); _masterLogicalSystem .getRoutingInstances() .values() .forEach( routingInstance -> builder.put( routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstance.getInterfaces().values().stream() .map(Interface::getName) .toArray(String[]::new)))); return builder.build(); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting Map<NatPacketLocation, AclLineMatchExpr> fromNatPacketLocationMatchExprs() { ImmutableMap.Builder<NatPacketLocation, AclLineMatchExpr> builder = ImmutableMap.builder(); _masterLogicalSystem .getInterfaces() .values() .forEach( iface -> iface .getUnits() .keySet() .forEach( ifaceUnit -> builder.put( interfaceLocation(ifaceUnit), matchSrcInterface(ifaceUnit)))); _masterLogicalSystem .getZones() .values() .forEach( zone -> builder.put( zoneLocation(zone.getName()), new MatchSrcInterface(zone.getInterfaces()))); _masterLogicalSystem .getRoutingInstances() .values() .forEach( routingInstance -> builder.put( routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstance.getInterfaces().values().stream() .map(Interface::getName) .toArray(String[]::new)))); return builder.build(); } 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 Map<NatPacketLocation, AclLineMatchExpr> fromNatPacketLocationMatchExprs() { ImmutableMap.Builder<NatPacketLocation, AclLineMatchExpr> builder = ImmutableMap.builder(); _masterLogicalSystem .getInterfaces() .values() .forEach( iface -> iface .getUnits() .keySet() .forEach( ifaceUnit -> builder.put( interfaceLocation(ifaceUnit), matchSrcInterface(ifaceUnit)))); _masterLogicalSystem .getZones() .values() .forEach( zone -> builder.put( zoneLocation(zone.getName()), new MatchSrcInterface(zone.getInterfaces()))); _masterLogicalSystem .getRoutingInstances() .values() .forEach( routingInstance -> builder.put( routingInstanceLocation(routingInstance.getName()), matchSrcInterface( routingInstance.getInterfaces().values().stream() .map(Interface::getName) .toArray(String[]::new)))); return builder.build(); } 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; }