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

@ -88,16 +88,14 @@ def main():
if state == 'present':
if not net:
net = cloud.create_network(name, shared, admin_state_up)
module.exit_json(changed=True, result="Created", id=net['id'])
else:
module.exit_json(changed=False, result="Success", id=net['id'])
module.exit_json(changed=False, network=net, id=net['id'])
elif state == 'absent':
if not net:
module.exit_json(changed=False, result="Success")
module.exit_json(changed=False)
else:
cloud.delete_network(name)
module.exit_json(changed=True, result="Deleted")
module.exit_json(changed=True)
except shade.OpenStackCloudException as e:
module.fail_json(msg=e.message)