mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds support for setting a virtual server's "source address translation" policy to a specific SNAT pool, in addition to the 'None' or 'Automap' options. (#3158)
This commit is contained in:
parent
f60e0d88da
commit
15f32cf3d5
1 changed files with 27 additions and 0 deletions
|
@ -102,6 +102,10 @@ options:
|
|||
description:
|
||||
- Source network address policy
|
||||
required: false
|
||||
choices:
|
||||
- None
|
||||
- Automap
|
||||
- Name of a SNAT pool (eg "/Common/snat_pool_name") to enable SNAT with the specific pool
|
||||
default: None
|
||||
default_persistence_profile:
|
||||
description:
|
||||
|
@ -355,6 +359,7 @@ def set_snat(api, name, snat):
|
|||
updated = False
|
||||
try:
|
||||
current_state = get_snat_type(api, name)
|
||||
current_snat_pool = get_snat_pool(api, name)
|
||||
if snat is None:
|
||||
return updated
|
||||
elif snat == 'None' and current_state != 'SRC_TRANS_NONE':
|
||||
|
@ -367,6 +372,11 @@ def set_snat(api, name, snat):
|
|||
virtual_servers=[name]
|
||||
)
|
||||
updated = True
|
||||
elif snat_settings_need_updating(snat, current_state, current_snat_pool):
|
||||
api.LocalLB.VirtualServer.set_source_address_translation_snat_pool(
|
||||
virtual_servers=[name],
|
||||
pools=[snat]
|
||||
)
|
||||
return updated
|
||||
except bigsuds.OperationFailed as e:
|
||||
raise Exception('Error on setting snat : %s' % e)
|
||||
|
@ -378,6 +388,23 @@ def get_snat_type(api, name):
|
|||
)[0]
|
||||
|
||||
|
||||
def get_snat_pool(api, name):
|
||||
return api.LocalLB.VirtualServer.get_source_address_translation_snat_pool(
|
||||
virtual_servers=[name]
|
||||
)[0]
|
||||
|
||||
|
||||
def snat_settings_need_updating(snat, current_state, current_snat_pool):
|
||||
if snat == 'None' or snat == 'Automap':
|
||||
return False
|
||||
elif snat and current_state != 'SRC_TRANS_SNATPOOL':
|
||||
return True
|
||||
elif snat and current_state == 'SRC_TRANS_SNATPOOL' and current_snat_pool != snat:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def get_pool(api, name):
|
||||
return api.LocalLB.VirtualServer.get_default_pool_name(
|
||||
virtual_servers=[name]
|
||||
|
|
Loading…
Reference in a new issue