1
0
Fork 0
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:
John Dewey 2013-11-20 20:21:04 -08:00
parent c372007b49
commit 64f7f6726d

View file

@ -104,22 +104,12 @@ class RabbitMqPolicy(object):
return True
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):
import json
args = ['set_policy']
args.append(self._name)
args.append(self._pattern)
args.append(self._make_params())
args.append(json.dumps(self._tags))
args.append('--priority')
args.append(self._priority)
return self._exec(args)
@ -133,7 +123,7 @@ def main():
name=dict(required=True),
vhost=dict(default='/'),
pattern=dict(required=True),
tags=dict(required=True),
tags=dict(type='dict', required=True),
priority=dict(default='0'),
node=dict(default='rabbit'),
state=dict(default='present', choices=['present', 'absent']),