From b414a3af6f8b74dcb8a3f805adfd5416b070bba9 Mon Sep 17 00:00:00 2001 From: "Christopher H. Laco" Date: Sun, 20 Oct 2013 15:30:46 -0400 Subject: [PATCH] Update module based on upstream feedback - Remove deleted state - Use dict() instead of raw hash - Wrap or statements in parens instead of backslash line continuations - Change instances to networks in module return result --- cloud/rax_network | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cloud/rax_network b/cloud/rax_network index c7b6bb56a82..6c6fc5de6d0 100644 --- a/cloud/rax_network +++ b/cloud/rax_network @@ -25,7 +25,7 @@ options: state: description: - Indicate desired state of the resource - choices: ['present', 'absent', 'deleted'] + choices: ['present', 'absent'] default: present credentials: description: @@ -93,9 +93,9 @@ def cloud_network(module, state, label, cidr): if not arg: module.fail_json(msg='%s is required for cloud_networks' % arg) - instances = [] changed = False network = None + networks = [] if state == 'present': try: @@ -109,7 +109,7 @@ def cloud_network(module, state, label, cidr): except Exception: module.fail_json(msg='%s' % e.message) - elif state in ('absent', 'deleted'): + elif state == 'absent': try: network = pyrax.cloud_networks.find_network_by_label(label) network.delete() @@ -120,19 +120,19 @@ def cloud_network(module, state, label, cidr): module.fail_json(msg='%s' % e.message) if network: - instance = {'id': network.id, - 'label': network.label, - 'cidr': network.cidr} - instances.append(instance) + instance = dict(id=network.id, + label=network.label, + cidr=network.cidr) + networks.append(instance) - module.exit_json(changed=changed, instances=instances) + module.exit_json(changed=changed, networks=networks) def main(): module = AnsibleModule( argument_spec=dict( state=dict(default='present', - choices=['present', 'deleted', 'absent']), + choices=['present', 'absent']), credentials=dict(aliases=['creds_file']), api_key=dict(), username=dict(), @@ -153,9 +153,9 @@ def main(): try: username = username or os.environ.get('RAX_USERNAME') api_key = api_key or os.environ.get('RAX_API_KEY') - credentials = credentials or \ - os.environ.get('RAX_CREDENTIALS') or \ - os.environ.get('RAX_CREDS_FILE') + credentials = (credentials or + os.environ.get('RAX_CREDENTIALS') or + os.environ.get('RAX_CREDS_FILE')) region = region or os.environ.get('RAX_REGION') except KeyError, e: