1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Lots of formatting fixes

This commit is contained in:
Michael DeHaan 2013-05-24 23:46:23 -04:00
parent 9c5d6f11f0
commit 3a635d2d26
11 changed files with 88 additions and 89 deletions

View file

@ -179,7 +179,7 @@ def _glance_image_create(module, params, client):
break break
time.sleep(5) time.sleep(5)
except Exception as e: except Exception as e:
module.fail_json(msg = "Error in creating image: %s" %e.message ) module.fail_json(msg = "Error in creating image: %s" %e.message)
if image.status == 'active': if image.status == 'active':
module.exit_json(changed = True, result = image.status, id=image.id) module.exit_json(changed = True, result = image.status, id=image.id)
else: else:

View file

@ -152,7 +152,7 @@ def _create_server(module, nova):
if not module.params['key_name']: if not module.params['key_name']:
del bootkwargs['key_name'] del bootkwargs['key_name']
try: try:
server = nova.servers.create(*bootargs, **bootkwargs ) server = nova.servers.create(*bootargs, **bootkwargs)
server = nova.servers.get(server.id) server = nova.servers.get(server.id)
except Exception as e: except Exception as e:
module.fail_json( msg = "Error in creating instance: %s " % e.message) module.fail_json( msg = "Error in creating instance: %s " % e.message)

View file

@ -121,7 +121,7 @@ def _get_server_state(module, nova):
info = server._info info = server._info
if info['name'] == module.params['instance_name']: if info['name'] == module.params['instance_name']:
if info['status'] != 'ACTIVE' and module.params['state'] == 'present': if info['status'] != 'ACTIVE' and module.params['state'] == 'present':
module.fail_json( msg="The VM is available but not Active. state:" + info['status']) module.fail_json(msg="The VM is available but not Active. state:" + info['status'])
server_info = info server_info = info
break break
except Exception as e: except Exception as e:

View file

@ -154,7 +154,7 @@ def _set_tenant_id(module):
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break; break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the paramters") module.fail_json(msg = "The tenant id cannot be found, please check the paramters")

View file

@ -127,7 +127,7 @@ def _set_tenant_id(module):
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == login_tenant_name: if tenant.name == login_tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break; break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the paramters") module.fail_json(msg = "The tenant id cannot be found, please check the paramters")
@ -152,7 +152,7 @@ def _create_router(module, quantum):
'admin_state_up': module.params['admin_state_up'], 'admin_state_up': module.params['admin_state_up'],
} }
try: try:
new_router = quantum.create_router({'router': router }) new_router = quantum.create_router(dict(router=router))
except Exception as e: except Exception as e:
module.fail_json( msg = "Error in creating router: %s" % e.message) module.fail_json( msg = "Error in creating router: %s" % e.message)
return new_router['router']['id'] return new_router['router']['id']
@ -191,13 +191,10 @@ def main():
else: else:
router_id = _get_router_id(module, quantum) router_id = _get_router_id(module, quantum)
if not router_id: if not router_id:
module.exit_json(changed = False, result = "success" ) module.exit_json(changed = False, result = "success")
else: else:
_delete_router(module, quantum, router_id) _delete_router(module, quantum, router_id)
module.exit_json(changed = True, result = "deleted" ) module.exit_json(changed = True, result = "deleted")
# this is magic, see lib/ansible/module.params['common.py # this is magic, see lib/ansible/module.params['common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>

View file

@ -127,7 +127,7 @@ def _set_tenant_id(module):
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == login_tenant_name: if tenant.name == login_tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break; break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the paramters") module.fail_json(msg = "The tenant id cannot be found, please check the paramters")

View file

@ -155,7 +155,7 @@ def _set_tenant_id(module):
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break; break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the paramters") module.fail_json(msg = "The tenant id cannot be found, please check the paramters")
@ -205,16 +205,18 @@ def _create_subnet(module, quantum):
} }
if module.params['allocation_pool_start'] and module.params['allocation_pool_end']: if module.params['allocation_pool_start'] and module.params['allocation_pool_end']:
allocation_pools = [ allocation_pools = [
{'start': module.params['allocation_pool_start'], {
'end': module.params['allocation_pool_end']} 'start' : module.params['allocation_pool_start'],
'end' : module.params['allocation_pool_end']
}
] ]
subnet.update({'allocation_pools': allocation_pools}) subnet.update({'allocation_pools': allocation_pools})
if not module.params['gateway_ip']: if not module.params['gateway_ip']:
subnet.pop('gateway_ip') subnet.pop('gateway_ip')
try: try:
new_subnet = quantum.create_subnet({'subnet': subnet }) new_subnet = quantum.create_subnet(dict(subnet=subnet))
except Exception as e: except Exception, e:
module.fail_json( msg = "Failure in creating subnet: %s" %e.message) module.fail_json(msg = "Failure in creating subnet: %s" % e.message)
return new_subnet['subnet']['id'] return new_subnet['subnet']['id']
@ -259,10 +261,10 @@ def main():
else: else:
subnet_id = _get_subnet_id(module, quantum) subnet_id = _get_subnet_id(module, quantum)
if not subnet_id: if not subnet_id:
module.exit_json(changed = False, result = "success" ) module.exit_json(changed = False, result = "success")
else: else:
_delete_subnet(module, quantum, subnet_id) _delete_subnet(module, quantum, subnet_id)
module.exit_json(changed = True, result = "deleted" ) module.exit_json(changed = True, result = "deleted")
# this is magic, see lib/ansible/module.params['common.py # this is magic, see lib/ansible/module.params['common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>