mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Pep8 fixes for rabbitmq modules (#24590)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
85fc4c67ef
commit
f7321a87ca
9 changed files with 192 additions and 207 deletions
|
@ -82,10 +82,13 @@ EXAMPLES = '''
|
|||
tags:
|
||||
ha-mode: all
|
||||
'''
|
||||
|
||||
import json
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
class RabbitMqPolicy(object):
|
||||
|
||||
def __init__(self, module, name):
|
||||
self._module = module
|
||||
self._name = name
|
||||
|
@ -116,14 +119,13 @@ class RabbitMqPolicy(object):
|
|||
return False
|
||||
|
||||
def set(self):
|
||||
import json
|
||||
args = ['set_policy']
|
||||
args.append(self._name)
|
||||
args.append(self._pattern)
|
||||
args.append(json.dumps(self._tags))
|
||||
args.append('--priority')
|
||||
args.append(self._priority)
|
||||
if (self._apply_to != 'all'):
|
||||
if self._apply_to != 'all':
|
||||
args.append('--apply-to')
|
||||
args.append(self._apply_to)
|
||||
return self._exec(args)
|
||||
|
@ -153,19 +155,18 @@ def main():
|
|||
state = module.params['state']
|
||||
rabbitmq_policy = RabbitMqPolicy(module, name)
|
||||
|
||||
changed = False
|
||||
result = dict(changed=False, name=name, state=state)
|
||||
if rabbitmq_policy.list():
|
||||
if state == 'absent':
|
||||
rabbitmq_policy.clear()
|
||||
changed = True
|
||||
result['changed'] = True
|
||||
else:
|
||||
changed = False
|
||||
result['changed'] = False
|
||||
elif state == 'present':
|
||||
rabbitmq_policy.set()
|
||||
changed = True
|
||||
|
||||
module.exit_json(changed=changed, name=name, state=state)
|
||||
result['changed'] = True
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue