mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Add enable, disable operation in netscaler_service (#28321)
This commit is contained in:
parent
fbeb3b9ac5
commit
2281a6676b
7 changed files with 115 additions and 8 deletions
|
@ -356,6 +356,16 @@ options:
|
|||
description:
|
||||
- Weight to assign to the binding between the monitor and service.
|
||||
|
||||
disabled:
|
||||
description:
|
||||
- When set to C(yes) the service state will be set to DISABLED.
|
||||
- When set to C(no) the service 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:
|
||||
- nitro python sdk
|
||||
|
@ -538,6 +548,16 @@ def all_identical(client, module, service_proxy, monitor_bindings_rw_attrs):
|
|||
return service_identical(client, module, service_proxy) and monitor_bindings_identical(client, module, monitor_bindings_rw_attrs)
|
||||
|
||||
|
||||
def do_state_change(client, module, service_proxy):
|
||||
if module.params['disabled']:
|
||||
log('Disabling service')
|
||||
result = service.disable(client, service_proxy.actual)
|
||||
else:
|
||||
log('Enabling service')
|
||||
result = service.enable(client, service_proxy.actual)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module_specific_arguments = dict(
|
||||
|
@ -675,6 +695,10 @@ def main():
|
|||
|
||||
hand_inserted_arguments = dict(
|
||||
monitor_bindings=dict(type='list'),
|
||||
disabled=dict(
|
||||
type='bool',
|
||||
default=False,
|
||||
),
|
||||
)
|
||||
|
||||
argument_spec = dict()
|
||||
|
@ -883,6 +907,12 @@ def main():
|
|||
else:
|
||||
module_result['changed'] = False
|
||||
|
||||
if not module.check_mode:
|
||||
res = do_state_change(client, module, service_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