mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Add disable operation for netscaler_servicegroup (#28327)
This commit is contained in:
parent
2281a6676b
commit
c01dd6470c
5 changed files with 111 additions and 5 deletions
|
@ -314,6 +314,16 @@ options:
|
|||
description:
|
||||
- Weight to assign to the binding between the monitor and servicegroup.
|
||||
|
||||
disabled:
|
||||
description:
|
||||
- When set to C(yes) the service group state will be set to DISABLED.
|
||||
- When set to C(no) the service group state will be set to ENABLED.
|
||||
- >-
|
||||
Note that due to limitations of the underlying NITRO API a C(disabled) state change alone
|
||||
does not cause the module result to report a changed status.
|
||||
type: bool
|
||||
default: false
|
||||
|
||||
|
||||
extends_documentation_fragment: netscaler
|
||||
requirements:
|
||||
|
@ -618,6 +628,16 @@ def diff(client, module, servicegroup_proxy):
|
|||
return diff_object
|
||||
|
||||
|
||||
def do_state_change(client, module, servicegroup_proxy):
|
||||
if module.params['disabled']:
|
||||
log('Disabling service')
|
||||
result = servicegroup.disable(client, servicegroup_proxy.actual)
|
||||
else:
|
||||
log('Enabling service')
|
||||
result = servicegroup.enable(client, servicegroup_proxy.actual)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module_specific_arguments = dict(
|
||||
|
@ -730,6 +750,10 @@ def main():
|
|||
hand_inserted_arguments = dict(
|
||||
servicemembers=dict(type='list'),
|
||||
monitorbindings=dict(type='list'),
|
||||
disabled=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
)
|
||||
|
||||
argument_spec = dict()
|
||||
|
@ -912,6 +936,12 @@ def main():
|
|||
client.save_config()
|
||||
module_result['changed'] = True
|
||||
|
||||
if not module.check_mode:
|
||||
res = do_state_change(client, module, servicegroup_proxy)
|
||||
if res.errorcode != 0:
|
||||
msg = 'Error when setting disabled state. errorcode: %s message: %s' % (res.errorcode, res.message)
|
||||
module.fail_json(msg=msg, **module_result)
|
||||
|
||||
# Sanity check for state
|
||||
if not module.check_mode:
|
||||
log('Sanity checks for state present')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue