@Test public void testFwTermToIpAccessList_traceElement() { JuniperConfiguration config = createConfig(); FwTerm term = new FwTerm("term"); term.getThens().add(FwThenAccept.INSTANCE); List<FwTerm> terms = ImmutableList.of(term); IpAccessList acl = config.fwTermsToIpAccessList("acl", terms, null, FIREWALL_FILTER); assertThat(acl.getLines(), hasSize(1)); TraceElement expected = TraceElement.builder() .add("Matched ") .add( "term", new VendorStructureId("file", FIREWALL_FILTER_TERM.getDescription(), "acl term")) .build(); TraceElement actual = acl.getLines().get(0).getTraceElement(); assertThat(actual, equalTo(expected)); assertThat(actual.getText(), equalTo("Matched term")); }
@VisibleForTesting @Nonnull IpAccessList fwTermsToIpAccessList( String aclName, Collection<FwTerm> terms, @Nullable AclLineMatchExpr conjunctMatchExpr, JuniperStructureType aclType) throws VendorConversionException { List<ExprAclLine> lines = terms.stream() .flatMap(term -> convertFwTermToExprAclLines(aclName, term, aclType).stream()) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(aclName) .setLines(mergeIpAccessListLines(lines, conjunctMatchExpr)) .setSourceName(aclName) .setSourceType(aclType.getDescription()) .build(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nonnull IpAccessList fwTermsToIpAccessList( String aclName, Collection<FwTerm> terms, @Nullable AclLineMatchExpr conjunctMatchExpr, JuniperStructureType aclType) throws VendorConversionException { List<ExprAclLine> lines = terms.stream() .flatMap(term -> convertFwTermToExprAclLines(aclName, term, aclType).stream()) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(aclName) .setLines(mergeIpAccessListLines(lines, conjunctMatchExpr)) .setSourceName(aclName) .setSourceType(aclType.getDescription()) .build(); } }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nonnull IpAccessList fwTermsToIpAccessList( String aclName, Collection<FwTerm> terms, @Nullable AclLineMatchExpr conjunctMatchExpr, JuniperStructureType aclType) throws VendorConversionException { List<ExprAclLine> lines = terms.stream() .flatMap(term -> convertFwTermToExprAclLines(aclName, term, aclType).stream()) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(aclName) .setLines(mergeIpAccessListLines(lines, conjunctMatchExpr)) .setSourceName(aclName) .setSourceType(aclType.getDescription()) .build(); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nonnull IpAccessList fwTermsToIpAccessList( String aclName, Collection<FwTerm> terms, @Nullable AclLineMatchExpr conjunctMatchExpr, JuniperStructureType aclType) throws VendorConversionException { List<ExprAclLine> lines = terms.stream() .flatMap(term -> convertFwTermToExprAclLines(aclName, term, aclType).stream()) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(aclName) .setLines(mergeIpAccessListLines(lines, conjunctMatchExpr)) .setSourceName(aclName) .setSourceType(aclType.getDescription()) .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 @Nonnull IpAccessList fwTermsToIpAccessList( String aclName, Collection<FwTerm> terms, @Nullable AclLineMatchExpr conjunctMatchExpr, JuniperStructureType aclType) throws VendorConversionException { List<ExprAclLine> lines = terms.stream() .flatMap(term -> convertFwTermToExprAclLines(aclName, term, aclType).stream()) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(aclName) .setLines(mergeIpAccessListLines(lines, conjunctMatchExpr)) .setSourceName(aclName) .setSourceType(aclType.getDescription()) .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; }