@Test public void testGenerateInterVsysCrossZoneCallsNoMatchingExternal() { Vsys vsys = new Vsys(VSYS_NAME); Vsys externalVsys = new Vsys(EXTERNAL_VSYS_NAME); Zone externalFromZone = new Zone(EXTERNAL_FROM_ZONE_NAME, externalVsys); externalFromZone.setType(Type.LAYER3); externalFromZone.getInterfaceNames().add(SRC_INTERFACE_NAME); externalVsys.getZones().put(EXTERNAL_FROM_ZONE_NAME, externalFromZone); Zone externalToZone = new Zone(EXTERNAL_TO_ZONE_NAME, externalVsys); externalToZone.setType(Type.EXTERNAL); externalVsys.getZones().put(EXTERNAL_TO_ZONE_NAME, externalToZone); assertEquals( generateInterVsysCrossZoneCalls( new Zone(FROM_ZONE_NAME, vsys), new Zone(TO_ZONE_NAME, vsys), externalVsys) .count(), 0L); }
@VisibleForTesting static @Nonnull Stream<ExprAclLine> generateInterVsysCrossZoneCalls( Zone fromZone, Zone toZone, Vsys externalVsys) { Vsys vsys = fromZone.getVsys(); assert vsys == toZone.getVsys() && vsys != externalVsys; String vsysName = vsys.getName(); return externalVsys.getZones().values().stream() .filter( externalVsysToZone -> externalVsysToZone.getType() == Type.EXTERNAL && externalVsysToZone.getExternalNames().contains(vsysName)) .flatMap( externalVsysToZone -> externalVsys.getZones().values().stream() .filter(externalVsysFromZone -> externalVsysFromZone.getType() == Type.LAYER3) .flatMap( externalVsysFromZone -> generateDoubleCrossZoneCalls( fromZone, toZone, externalVsysFromZone, externalVsysToZone))); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull Stream<ExprAclLine> generateInterVsysCrossZoneCalls( Zone fromZone, Zone toZone, Vsys externalVsys) { Vsys vsys = fromZone.getVsys(); assert vsys == toZone.getVsys() && vsys != externalVsys; String vsysName = vsys.getName(); return externalVsys.getZones().values().stream() .filter( externalVsysToZone -> externalVsysToZone.getType() == Type.EXTERNAL && externalVsysToZone.getExternalNames().contains(vsysName)) .flatMap( externalVsysToZone -> externalVsys.getZones().values().stream() .filter(externalVsysFromZone -> externalVsysFromZone.getType() == Type.LAYER3) .flatMap( externalVsysFromZone -> generateDoubleCrossZoneCalls( fromZone, toZone, externalVsysFromZone, externalVsysToZone))); } }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull Stream<ExprAclLine> generateInterVsysCrossZoneCalls( Zone fromZone, Zone toZone, Vsys externalVsys) { Vsys vsys = fromZone.getVsys(); assert vsys == toZone.getVsys() && vsys != externalVsys; String vsysName = vsys.getName(); return externalVsys.getZones().values().stream() .filter( externalVsysToZone -> externalVsysToZone.getType() == Type.EXTERNAL && externalVsysToZone.getExternalNames().contains(vsysName)) .flatMap( externalVsysToZone -> externalVsys.getZones().values().stream() .filter(externalVsysFromZone -> externalVsysFromZone.getType() == Type.LAYER3) .flatMap( externalVsysFromZone -> generateDoubleCrossZoneCalls( fromZone, toZone, externalVsysFromZone, externalVsysToZone))); } PaloAltoConfiguration(); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull Stream<ExprAclLine> generateInterVsysCrossZoneCalls( Zone fromZone, Zone toZone, Vsys externalVsys) { Vsys vsys = fromZone.getVsys(); assert vsys == toZone.getVsys() && vsys != externalVsys; String vsysName = vsys.getName(); return externalVsys.getZones().values().stream() .filter( externalVsysToZone -> externalVsysToZone.getType() == Type.EXTERNAL && externalVsysToZone.getExternalNames().contains(vsysName)) .flatMap( externalVsysToZone -> externalVsys.getZones().values().stream() .filter(externalVsysFromZone -> externalVsysFromZone.getType() == Type.LAYER3) .flatMap( externalVsysFromZone -> generateDoubleCrossZoneCalls( fromZone, toZone, externalVsysFromZone, externalVsysToZone))); } PaloAltoConfiguration(); void addHostnameMapping(String deviceId, String hostname); List<CryptoProfile> getCryptoProfiles(); CryptoProfile getCryptoProfileOrCreate(String name, CryptoProfile.Type cpType); @Override String getHostname(); @Nullable DeviceGroup getDeviceGroup(String name); DeviceGroup getOrCreateDeviceGroup(String name); Template getOrCreateTemplate(String name); TemplateStack getOrCreateTemplateStack(String name); SortedMap<String, Interface> getInterfaces(); Ip getMgmtIfaceAddress(); Ip getMgmtIfaceGateway(); Ip getMgmtIfaceNetmask(); @Nonnull SortedMap<String, Vsys> getSharedGateways(); @Nullable Template getTemplate(String name); SortedMap<String, VirtualRouter> getVirtualRouters(); SortedMap<String, Vsys> getVirtualSystems(); void setDnsServerPrimary(String dnsServerPrimary); void setDnsServerSecondary(String dnsServerSecondary); @Override void setHostname(String hostname); void setMgmtIfaceAddress(Ip ip); void setMgmtIfaceGateway(Ip ip); void setMgmtIfaceNetmask(Ip ip); void setNtpServerPrimary(String ntpServerPrimary); void setNtpServerSecondary(String ntpServerSecondary); @Override void setVendor(ConfigurationFormat format); static String computeObjectName(String vsysName, String objectName); static String computeObjectName(@Nullable Vsys vsys, String objectName); static String computeOutgoingFilterName(String interfaceOrZoneName); static String computePacketPolicyName(Zone zone); @VisibleForTesting static String computeServiceGroupMemberAclName(
      String vsysName, String serviceGroupMemberName); @VisibleForTesting List<PaloAltoConfiguration> getManagedConfigurations(); @Override List<Configuration> toVendorIndependentConfigurations(); @Nullable Vsys getPanorama(); @Nullable Vsys getShared(); void setPanorama(@Nullable Vsys panorama); void setShared(@Nullable Vsys shared); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull Stream<ExprAclLine> generateInterVsysCrossZoneCalls( Zone fromZone, Zone toZone, Vsys externalVsys) { Vsys vsys = fromZone.getVsys(); assert vsys == toZone.getVsys() && vsys != externalVsys; String vsysName = vsys.getName(); return externalVsys.getZones().values().stream() .filter( externalVsysToZone -> externalVsysToZone.getType() == Type.EXTERNAL && externalVsysToZone.getExternalNames().contains(vsysName)) .flatMap( externalVsysToZone -> externalVsys.getZones().values().stream() .filter(externalVsysFromZone -> externalVsysFromZone.getType() == Type.LAYER3) .flatMap( externalVsysFromZone -> generateDoubleCrossZoneCalls( fromZone, toZone, externalVsysFromZone, externalVsysToZone))); } PaloAltoConfiguration(); void addHostnameMapping(String deviceId, String hostname); List<CryptoProfile> getCryptoProfiles(); CryptoProfile getCryptoProfileOrCreate(String name, CryptoProfile.Type cpType); @Override String getHostname(); @Nullable DeviceGroup getDeviceGroup(String name); DeviceGroup getOrCreateDeviceGroup(String name); Template getOrCreateTemplate(String name); TemplateStack getOrCreateTemplateStack(String name); SortedMap<String, Interface> getInterfaces(); Ip getMgmtIfaceAddress(); Ip getMgmtIfaceGateway(); Ip getMgmtIfaceNetmask(); @Nonnull SortedMap<String, Vsys> getSharedGateways(); @Nullable Template getTemplate(String name); SortedMap<String, VirtualRouter> getVirtualRouters(); SortedMap<String, Vsys> getVirtualSystems(); void setDnsServerPrimary(String dnsServerPrimary); void setDnsServerSecondary(String dnsServerSecondary); @Override void setHostname(String hostname); void setMgmtIfaceAddress(Ip ip); void setMgmtIfaceGateway(Ip ip); void setMgmtIfaceNetmask(Ip ip); void setNtpServerPrimary(String ntpServerPrimary); void setNtpServerSecondary(String ntpServerSecondary); @Override void setVendor(ConfigurationFormat format); static String computeObjectName(String vsysName, String objectName); static String computeObjectName(@Nullable Vsys vsys, String objectName); static String computeOutgoingFilterName(String interfaceOrZoneName); static String computePacketPolicyName(Zone zone); @VisibleForTesting static String computeServiceGroupMemberAclName(
      String vsysName, String serviceGroupMemberName); @VisibleForTesting List<PaloAltoConfiguration> getManagedConfigurations(); @Override List<Configuration> toVendorIndependentConfigurations(); @Nullable Vsys getPanorama(); @Nullable Vsys getShared(); void setPanorama(@Nullable Vsys panorama); void setShared(@Nullable Vsys shared); static final String CATCHALL_APPLICATION_NAME; static final String CATCHALL_ENDPOINT_NAME; static final String CATCHALL_ZONE_NAME; static final String DEFAULT_VSYS_NAME; static final String NULL_VRF_NAME; static final String PANORAMA_VSYS_NAME; static final String SHARED_VSYS_NAME; }