mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Lots of formatting fixes
This commit is contained in:
parent
9c5d6f11f0
commit
3a635d2d26
11 changed files with 88 additions and 89 deletions
|
@ -107,7 +107,7 @@ def _get_quantum_client(module, kwargs):
|
|||
'endpoint_url': endpoint
|
||||
}
|
||||
try:
|
||||
quantum = client.Client('2.0', **kwargs)
|
||||
quantum = client.Client('2.0', **kwargs)
|
||||
except Exception as e:
|
||||
module.fail_json(msg = "Error in connecting to quantum: %s " % e.message)
|
||||
return quantum
|
||||
|
@ -119,30 +119,30 @@ def _get_server_state(module, nova):
|
|||
for server in nova.servers.list():
|
||||
if server:
|
||||
info = server._info
|
||||
if info['name'] == module.params['instance_name']:
|
||||
if info['status'] != 'ACTIVE' and module.params['state'] == 'present':
|
||||
module.fail_json( msg="The VM is available but not Active. state:" + info['status'])
|
||||
server_info = info
|
||||
break
|
||||
if info['name'] == module.params['instance_name']:
|
||||
if info['status'] != 'ACTIVE' and module.params['state'] == 'present':
|
||||
module.fail_json(msg="The VM is available but not Active. state:" + info['status'])
|
||||
server_info = info
|
||||
break
|
||||
except Exception as e:
|
||||
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
||||
return server_info, server
|
||||
|
||||
def _get_port_id(quantum, module, instance_id):
|
||||
kwargs = {
|
||||
device_id': instance_id,
|
||||
device_id': instance_id,
|
||||
}
|
||||
try:
|
||||
ports = quantum.list_ports(**kwargs)
|
||||
ports = quantum.list_ports(**kwargs)
|
||||
except Exception as e:
|
||||
module.fail_json( msg = "Error in listing ports: %s" % e.message)
|
||||
module.fail_json( msg = "Error in listing ports: %s" % e.message)
|
||||
if not ports['ports']:
|
||||
return None
|
||||
return None
|
||||
return ports['ports'][0]['id']
|
||||
|
||||
def _get_floating_ip_id(module, quantum):
|
||||
kwargs = {
|
||||
'floating_ip_address': module.params['ip_address']
|
||||
'floating_ip_address': module.params['ip_address']
|
||||
}
|
||||
try:
|
||||
ips = quantum.list_floatingips(**kwargs)
|
||||
|
@ -152,14 +152,14 @@ def _get_floating_ip_id(module, quantum):
|
|||
module.fail_json(msg = "Could find the ip specified in parameter, Please check")
|
||||
ip = ips['floatingips'][0]['id']
|
||||
if not ips['floatingips'][0]['port_id']:
|
||||
state = "detached"
|
||||
state = "detached"
|
||||
else:
|
||||
state = "attached"
|
||||
return state, ip
|
||||
|
||||
def _update_floating_ip(quantum, module, port_id, floating_ip_id):
|
||||
kwargs = {
|
||||
'port_id': port_id
|
||||
'port_id': port_id
|
||||
}
|
||||
try:
|
||||
result = quantum.update_floatingip(floating_ip_id, {'floatingip': kwargs})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue