@Test public void testGenerateSharedGatewayOutgoingFilterIntraSg() { Vsys sharedGateway = new Vsys(VSYS_NAME); sharedGateway.getImportedInterfaces().add(SRC_INTERFACE_NAME); assertThat( generateSharedGatewayOutgoingFilter( sharedGateway, ImmutableList.of(sharedGateway), ImmutableList.of()), accepts( createFlow(SRC_IP, DST_IP, SRC_INTERFACE_NAME), SRC_INTERFACE_NAME, createInterVsysCrossZoneFilters(), ImmutableMap.of())); }
@VisibleForTesting static @Nonnull IpAccessList generateSharedGatewayOutgoingFilter( Vsys sharedGateway, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Stream<ExprAclLine> vsysSgLines = virtualSystems.stream() .flatMap(vsys -> generateVsysSharedGatewayCalls(sharedGateway, vsys)); Stream<ExprAclLine> sgSgLines = Stream.concat(Stream.of(sharedGateway), sharedGateways.stream()) .flatMap( ingressSharedGateway -> generateSgSgLines(sharedGateway, ingressSharedGateway)); return IpAccessList.builder() .setName( computeOutgoingFilterName( computeObjectName(sharedGateway.getName(), sharedGateway.getName()))) .setLines(Stream.concat(vsysSgLines, sgSgLines).collect(ImmutableList.toImmutableList())) .build(); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateSharedGatewayOutgoingFilter( Vsys sharedGateway, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Stream<ExprAclLine> vsysSgLines = virtualSystems.stream() .flatMap(vsys -> generateVsysSharedGatewayCalls(sharedGateway, vsys)); Stream<ExprAclLine> sgSgLines = Stream.concat(Stream.of(sharedGateway), sharedGateways.stream()) .flatMap( ingressSharedGateway -> generateSgSgLines(sharedGateway, ingressSharedGateway)); return IpAccessList.builder() .setName( computeOutgoingFilterName( computeObjectName(sharedGateway.getName(), sharedGateway.getName()))) .setLines(Stream.concat(vsysSgLines, sgSgLines).collect(ImmutableList.toImmutableList())) .build(); } }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateSharedGatewayOutgoingFilter( Vsys sharedGateway, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Stream<ExprAclLine> vsysSgLines = virtualSystems.stream() .flatMap(vsys -> generateVsysSharedGatewayCalls(sharedGateway, vsys)); Stream<ExprAclLine> sgSgLines = Stream.concat(Stream.of(sharedGateway), sharedGateways.stream()) .flatMap( ingressSharedGateway -> generateSgSgLines(sharedGateway, ingressSharedGateway)); return IpAccessList.builder() .setName( computeOutgoingFilterName( computeObjectName(sharedGateway.getName(), sharedGateway.getName()))) .setLines(Stream.concat(vsysSgLines, sgSgLines).collect(ImmutableList.toImmutableList())) .build(); } PaloAltoConfiguration(); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateSharedGatewayOutgoingFilter( Vsys sharedGateway, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Stream<ExprAclLine> vsysSgLines = virtualSystems.stream() .flatMap(vsys -> generateVsysSharedGatewayCalls(sharedGateway, vsys)); Stream<ExprAclLine> sgSgLines = Stream.concat(Stream.of(sharedGateway), sharedGateways.stream()) .flatMap( ingressSharedGateway -> generateSgSgLines(sharedGateway, ingressSharedGateway)); return IpAccessList.builder() .setName( computeOutgoingFilterName( computeObjectName(sharedGateway.getName(), sharedGateway.getName()))) .setLines(Stream.concat(vsysSgLines, sgSgLines).collect(ImmutableList.toImmutableList())) .build(); } 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 IpAccessList generateSharedGatewayOutgoingFilter( Vsys sharedGateway, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Stream<ExprAclLine> vsysSgLines = virtualSystems.stream() .flatMap(vsys -> generateVsysSharedGatewayCalls(sharedGateway, vsys)); Stream<ExprAclLine> sgSgLines = Stream.concat(Stream.of(sharedGateway), sharedGateways.stream()) .flatMap( ingressSharedGateway -> generateSgSgLines(sharedGateway, ingressSharedGateway)); return IpAccessList.builder() .setName( computeOutgoingFilterName( computeObjectName(sharedGateway.getName(), sharedGateway.getName()))) .setLines(Stream.concat(vsysSgLines, sgSgLines).collect(ImmutableList.toImmutableList())) .build(); } 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; }