|
|
|
|
@ -134,6 +134,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
if not HAS_REQUESTS:
|
|
|
|
|
module.fail_json(msg="requests library is required for this module. To install, use `pip install requests`")
|
|
|
|
|
result = dict(changed=False, name=module.params['name'])
|
|
|
|
|
|
|
|
|
|
if module.params['destination_type'] == "queue":
|
|
|
|
|
dest_type = "q"
|
|
|
|
|
@ -145,9 +146,9 @@ def main():
|
|
|
|
|
else:
|
|
|
|
|
props = urllib_parse.quote(module.params['routing_key'], '')
|
|
|
|
|
|
|
|
|
|
url = "http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s" % (
|
|
|
|
|
module.params['login_host'],
|
|
|
|
|
module.params['login_port'],
|
|
|
|
|
base_url = "http://%s:%s/api/bindings" % (module.params['login_host'], module.params['login_port'])
|
|
|
|
|
|
|
|
|
|
url = "%s/%s/e/%s/%s/%s/%s" % (base_url,
|
|
|
|
|
urllib_parse.quote(module.params['vhost'], ''),
|
|
|
|
|
urllib_parse.quote(module.params['name'], ''),
|
|
|
|
|
dest_type,
|
|
|
|
|
@ -177,19 +178,16 @@ def main():
|
|
|
|
|
|
|
|
|
|
# Exit if check_mode
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
module.exit_json(
|
|
|
|
|
changed= change_required,
|
|
|
|
|
name = module.params['name'],
|
|
|
|
|
details = response,
|
|
|
|
|
arguments = module.params['arguments']
|
|
|
|
|
)
|
|
|
|
|
result['changed'] = change_required
|
|
|
|
|
result['details'] = response
|
|
|
|
|
result['arguments'] = module.params['arguments']
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
|
|
|
|
|
# Do changes
|
|
|
|
|
if change_required:
|
|
|
|
|
if module.params['state'] == 'present':
|
|
|
|
|
url = "http://%s:%s/api/bindings/%s/e/%s/%s/%s" % (
|
|
|
|
|
module.params['login_host'],
|
|
|
|
|
module.params['login_port'],
|
|
|
|
|
url = "%s/%s/e/%s/%s/%s" % (
|
|
|
|
|
base_url,
|
|
|
|
|
urllib_parse.quote(module.params['vhost'], ''),
|
|
|
|
|
urllib_parse.quote(module.params['name'], ''),
|
|
|
|
|
dest_type,
|
|
|
|
|
@ -209,11 +207,9 @@ def main():
|
|
|
|
|
r = requests.delete(url, auth=(module.params['login_user'], module.params['login_password']))
|
|
|
|
|
|
|
|
|
|
if r.status_code == 204 or r.status_code == 201:
|
|
|
|
|
module.exit_json(
|
|
|
|
|
changed = True,
|
|
|
|
|
name = module.params['name'],
|
|
|
|
|
destination = module.params['destination']
|
|
|
|
|
)
|
|
|
|
|
result['changed'] = True
|
|
|
|
|
result['destination'] = module.params['destination']
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
else:
|
|
|
|
|
module.fail_json(
|
|
|
|
|
msg="Error creating exchange",
|
|
|
|
|
@ -222,11 +218,8 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
module.exit_json(
|
|
|
|
|
changed = False,
|
|
|
|
|
name = module.params['name']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result['changed'] = False
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|
|
|
|
|
|