mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Handled string/dict the ansible way
This commit is contained in:
parent
c372007b49
commit
64f7f6726d
1 changed files with 3 additions and 13 deletions
|
@ -104,22 +104,12 @@ class RabbitMqPolicy(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _dump_json(self, d):
|
|
||||||
import json
|
|
||||||
return json.dumps(d)
|
|
||||||
|
|
||||||
def _make_params(self):
|
|
||||||
if type(self._tags) is dict:
|
|
||||||
return self._dump_json(self._tags)
|
|
||||||
else:
|
|
||||||
d = dict([x.split('=') for x in self._tags.split()])
|
|
||||||
return self._dump_json(d)
|
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
|
import json
|
||||||
args = ['set_policy']
|
args = ['set_policy']
|
||||||
args.append(self._name)
|
args.append(self._name)
|
||||||
args.append(self._pattern)
|
args.append(self._pattern)
|
||||||
args.append(self._make_params())
|
args.append(json.dumps(self._tags))
|
||||||
args.append('--priority')
|
args.append('--priority')
|
||||||
args.append(self._priority)
|
args.append(self._priority)
|
||||||
return self._exec(args)
|
return self._exec(args)
|
||||||
|
@ -133,7 +123,7 @@ def main():
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
vhost=dict(default='/'),
|
vhost=dict(default='/'),
|
||||||
pattern=dict(required=True),
|
pattern=dict(required=True),
|
||||||
tags=dict(required=True),
|
tags=dict(type='dict', required=True),
|
||||||
priority=dict(default='0'),
|
priority=dict(default='0'),
|
||||||
node=dict(default='rabbit'),
|
node=dict(default='rabbit'),
|
||||||
state=dict(default='present', choices=['present', 'absent']),
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
|
Loading…
Reference in a new issue