@Test public void testToRibId() { String hostname = "host"; assertThat( toRibId(hostname, "inet.0", null), equalTo(new RibId(hostname, Configuration.DEFAULT_VRF_NAME, RibId.DEFAULT_RIB_NAME))); assertThat( toRibId(hostname, "inet.1", null), equalTo(new RibId(hostname, Configuration.DEFAULT_VRF_NAME, "inet.1"))); assertThat( toRibId(hostname, "VRF1.inet.0", null), equalTo(new RibId(hostname, "VRF1", RibId.DEFAULT_RIB_NAME))); assertThat( toRibId(hostname, "VRF1.inet.1", null), equalTo(new RibId(hostname, "VRF1", "inet.1"))); Warnings w = new Warnings(true, true, true); assertThat(toRibId(hostname, "inet6.0", w), nullValue()); assertThat( w.getUnimplementedWarnings(), equalTo( ImmutableList.of( new Warning( "Rib name conversion: inet6 address family is not supported", TAG_UNIMPLEMENTED)))); }
@VisibleForTesting @Nullable static RibId toRibId(String hostname, String rib, @Nullable Warnings w) { String[] parts = rib.split("\\."); if (parts.length < 2 || parts.length > 3) { throw new VendorConversionException(String.format("Invalid RIB identifier %s", rib)); } String vrfName; String addressFamily; String ribNumber; if (parts.length == 3) { vrfName = parts[0]; addressFamily = parts[1]; ribNumber = parts[2]; } else { vrfName = Configuration.DEFAULT_VRF_NAME; addressFamily = parts[0]; ribNumber = parts[1]; } String ribName = addressFamily + "." + ribNumber; if (ribName.equals(RIB_IPV4_UNICAST)) { ribName = RibId.DEFAULT_RIB_NAME; } if (!addressFamily.equals("inet") && w != null) { w.unimplemented( String.format("Rib name conversion: %s address family is not supported", addressFamily)); return null; } return new RibId(hostname, vrfName, ribName); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nullable static RibId toRibId(String hostname, String rib, @Nullable Warnings w) { String[] parts = rib.split("\\."); if (parts.length < 2 || parts.length > 3) { throw new VendorConversionException(String.format("Invalid RIB identifier %s", rib)); } String vrfName; String addressFamily; String ribNumber; if (parts.length == 3) { vrfName = parts[0]; addressFamily = parts[1]; ribNumber = parts[2]; } else { vrfName = Configuration.DEFAULT_VRF_NAME; addressFamily = parts[0]; ribNumber = parts[1]; } String ribName = addressFamily + "." + ribNumber; if (ribName.equals(RIB_IPV4_UNICAST)) { ribName = RibId.DEFAULT_RIB_NAME; } if (!addressFamily.equals("inet") && w != null) { w.unimplemented( String.format("Rib name conversion: %s address family is not supported", addressFamily)); return null; } return new RibId(hostname, vrfName, ribName); } }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nullable static RibId toRibId(String hostname, String rib, @Nullable Warnings w) { String[] parts = rib.split("\\."); if (parts.length < 2 || parts.length > 3) { throw new VendorConversionException(String.format("Invalid RIB identifier %s", rib)); } String vrfName; String addressFamily; String ribNumber; if (parts.length == 3) { vrfName = parts[0]; addressFamily = parts[1]; ribNumber = parts[2]; } else { vrfName = Configuration.DEFAULT_VRF_NAME; addressFamily = parts[0]; ribNumber = parts[1]; } String ribName = addressFamily + "." + ribNumber; if (ribName.equals(RIB_IPV4_UNICAST)) { ribName = RibId.DEFAULT_RIB_NAME; } if (!addressFamily.equals("inet") && w != null) { w.unimplemented( String.format("Rib name conversion: %s address family is not supported", addressFamily)); return null; } return new RibId(hostname, vrfName, ribName); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting @Nullable static RibId toRibId(String hostname, String rib, @Nullable Warnings w) { String[] parts = rib.split("\\."); if (parts.length < 2 || parts.length > 3) { throw new VendorConversionException(String.format("Invalid RIB identifier %s", rib)); } String vrfName; String addressFamily; String ribNumber; if (parts.length == 3) { vrfName = parts[0]; addressFamily = parts[1]; ribNumber = parts[2]; } else { vrfName = Configuration.DEFAULT_VRF_NAME; addressFamily = parts[0]; ribNumber = parts[1]; } String ribName = addressFamily + "." + ribNumber; if (ribName.equals(RIB_IPV4_UNICAST)) { ribName = RibId.DEFAULT_RIB_NAME; } if (!addressFamily.equals("inet") && w != null) { w.unimplemented( String.format("Rib name conversion: %s address family is not supported", addressFamily)); return null; } return new RibId(hostname, vrfName, ribName); } 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 @Nullable static RibId toRibId(String hostname, String rib, @Nullable Warnings w) { String[] parts = rib.split("\\."); if (parts.length < 2 || parts.length > 3) { throw new VendorConversionException(String.format("Invalid RIB identifier %s", rib)); } String vrfName; String addressFamily; String ribNumber; if (parts.length == 3) { vrfName = parts[0]; addressFamily = parts[1]; ribNumber = parts[2]; } else { vrfName = Configuration.DEFAULT_VRF_NAME; addressFamily = parts[0]; ribNumber = parts[1]; } String ribName = addressFamily + "." + ribNumber; if (ribName.equals(RIB_IPV4_UNICAST)) { ribName = RibId.DEFAULT_RIB_NAME; } if (!addressFamily.equals("inet") && w != null) { w.unimplemented( String.format("Rib name conversion: %s address family is not supported", addressFamily)); return null; } return new RibId(hostname, vrfName, ribName); } 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; }