Return resource objects from OpenStack modules

It's not uncommon for people to want to do additional things after
creating a module. Also, add a note about it to the dev notes.
This commit is contained in:
Monty Taylor 2015-06-17 05:24:08 -04:00 committed by Matt Clay
parent 89f95471f8
commit b955b2f5c8
7 changed files with 30 additions and 22 deletions

View file

@ -227,7 +227,7 @@ def main():
dns_nameservers=dns,
allocation_pools=pool,
host_routes=host_routes)
module.exit_json(changed=True, result="created")
changed = True
else:
if _needs_update(subnet, module):
cloud.update_subnet(subnet['id'],
@ -237,16 +237,18 @@ def main():
dns_nameservers=dns,
allocation_pools=pool,
host_routes=host_routes)
module.exit_json(changed=True, result="updated")
changed = True
else:
module.exit_json(changed=False, result="success")
changed = False
module.exit_json(changed=changed)
elif state == 'absent':
if not subnet:
module.exit_json(changed=False, result="success")
changed = False
else:
changed = True
cloud.delete_subnet(subnet_name)
module.exit_json(changed=True, result="deleted")
module.exit_json(changed=changed)
except shade.OpenStackCloudException as e:
module.fail_json(msg=e.message)