mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds route advertisement state to the bigip_virtual_server module (#3273)
This commit is contained in:
parent
15f32cf3d5
commit
a27de3adcc
1 changed files with 31 additions and 0 deletions
|
@ -112,6 +112,12 @@ options:
|
|||
- Default Profile which manages the session persistence
|
||||
required: false
|
||||
default: None
|
||||
route_advertisement_state:
|
||||
description:
|
||||
- Enable route advertisement for destination
|
||||
required: false
|
||||
default: disabled
|
||||
version_added: "2.3"
|
||||
description:
|
||||
description:
|
||||
- Virtual server description
|
||||
|
@ -540,6 +546,27 @@ def set_default_persistence_profiles(api, name, persistence_profile):
|
|||
raise Exception('Error on setting default persistence profile : %s' % e)
|
||||
|
||||
|
||||
def get_route_advertisement_status(api, address):
|
||||
result = api.LocalLB.VirtualAddressV2.get_route_advertisement_state(virtual_addresses=[address]).pop(0)
|
||||
result = result.split("STATE_")[-1].lower()
|
||||
return result
|
||||
|
||||
|
||||
def set_route_advertisement_state(api, destination, partition, route_advertisement_state):
|
||||
updated = False
|
||||
|
||||
try:
|
||||
state = "STATE_%s" % route_advertisement_state.strip().upper()
|
||||
address = fq_name(partition, destination,)
|
||||
current_route_advertisement_state=get_route_advertisement_status(api,address)
|
||||
if current_route_advertisement_state != route_advertisement_state:
|
||||
api.LocalLB.VirtualAddressV2.set_route_advertisement_state(virtual_addresses=[address], states=[state])
|
||||
updated = True
|
||||
return updated
|
||||
except bigsuds.OperationFailed as e:
|
||||
raise Exception('Error on setting profiles : %s' % e)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = f5_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
|
@ -554,6 +581,7 @@ def main():
|
|||
pool=dict(type='str'),
|
||||
description=dict(type='str'),
|
||||
snat=dict(type='str'),
|
||||
route_advertisement_state=dict(type='str', default='disabled', choices=['enabled', 'disabled']),
|
||||
default_persistence_profile=dict(type='str')
|
||||
))
|
||||
|
||||
|
@ -593,6 +621,7 @@ def main():
|
|||
pool = fq_name(partition, module.params['pool'])
|
||||
description = module.params['description']
|
||||
snat = module.params['snat']
|
||||
route_advertisement_state = module.params['route_advertisement_state']
|
||||
default_persistence_profile = fq_name(partition, module.params['default_persistence_profile'])
|
||||
|
||||
if 1 > port > 65535:
|
||||
|
@ -639,6 +668,7 @@ def main():
|
|||
set_description(api, name, description)
|
||||
set_default_persistence_profiles(api, name, default_persistence_profile)
|
||||
set_state(api, name, state)
|
||||
set_route_advertisement_state(api, destination, partition, route_advertisement_state)
|
||||
result = {'changed': True}
|
||||
except bigsuds.OperationFailed as e:
|
||||
raise Exception('Error on creating Virtual Server : %s' % e)
|
||||
|
@ -663,6 +693,7 @@ def main():
|
|||
result['changed'] |= set_rules(api, name, all_rules)
|
||||
result['changed'] |= set_default_persistence_profiles(api, name, default_persistence_profile)
|
||||
result['changed'] |= set_state(api, name, state)
|
||||
result['changed'] |= set_route_advertisement_state(api, destination, partition, route_advertisement_state)
|
||||
api.System.Session.submit_transaction()
|
||||
except Exception as e:
|
||||
raise Exception("Error on updating Virtual Server : %s" % e)
|
||||
|
|
Loading…
Reference in a new issue