mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
reword "except Error as e:" into "except Error, e:" to be compatible with Python 2.5 (#5852)
This commit is contained in:
parent
2d0e9cd75d
commit
658c15930e
27 changed files with 118 additions and 118 deletions
|
@ -96,7 +96,7 @@ def _get_ksclient(module, kwargs):
|
|||
password=kwargs.get('login_password'),
|
||||
tenant_name=kwargs.get('login_tenant_name'),
|
||||
auth_url=kwargs.get('auth_url'))
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg = "Error authenticating to the keystone: %s " % e.message)
|
||||
global _os_keystone
|
||||
_os_keystone = kclient
|
||||
|
@ -106,7 +106,7 @@ def _get_ksclient(module, kwargs):
|
|||
def _get_endpoint(module, ksclient):
|
||||
try:
|
||||
endpoint = ksclient.service_catalog.url_for(service_type='network', endpoint_type='publicURL')
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg = "Error getting network endpoint: %s" % e.message)
|
||||
return endpoint
|
||||
|
||||
|
@ -120,7 +120,7 @@ def _get_neutron_client(module, kwargs):
|
|||
}
|
||||
try:
|
||||
neutron = client.Client('2.0', **kwargs)
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg = "Error in connecting to neutron: %s " % e.message)
|
||||
return neutron
|
||||
|
||||
|
@ -136,7 +136,7 @@ def _get_server_state(module, nova):
|
|||
module.fail_json( msg="The VM is available but not Active. state:" + info['status'])
|
||||
server_info = info
|
||||
break
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg = "Error in getting the server list: %s" % e.message)
|
||||
return server_info, server
|
||||
|
||||
|
@ -152,7 +152,7 @@ def _get_port_info(neutron, module, instance_id, internal_network_name=None):
|
|||
}
|
||||
try:
|
||||
ports = neutron.list_ports(**kwargs)
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json( msg = "Error in listing ports: %s" % e.message)
|
||||
if subnet_id:
|
||||
port = next(port for port in ports['ports'] if port['fixed_ips'][0]['subnet_id'] == subnet_id)
|
||||
|
@ -171,7 +171,7 @@ def _get_floating_ip(module, neutron, fixed_ip_address):
|
|||
}
|
||||
try:
|
||||
ips = neutron.list_floatingips(**kwargs)
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg = "error in fetching the floatingips's %s" % e.message)
|
||||
if not ips['floatingips']:
|
||||
return None, None
|
||||
|
@ -184,7 +184,7 @@ def _create_floating_ip(neutron, module, port_id, net_id):
|
|||
}
|
||||
try:
|
||||
result = neutron.create_floatingip({'floatingip': kwargs})
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg="There was an error in updating the floating ip address: %s" % e.message)
|
||||
module.exit_json(changed=True, result=result, public_ip=result['floatingip']['floating_ip_address'])
|
||||
|
||||
|
@ -194,7 +194,7 @@ def _get_net_id(neutron, module):
|
|||
}
|
||||
try:
|
||||
networks = neutron.list_networks(**kwargs)
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json("Error in listing neutron networks: %s" % e.message)
|
||||
if not networks['networks']:
|
||||
return None
|
||||
|
@ -206,7 +206,7 @@ def _update_floating_ip(neutron, module, port_id, floating_ip_id):
|
|||
}
|
||||
try:
|
||||
result = neutron.update_floatingip(floating_ip_id, {'floatingip': kwargs})
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg="There was an error in updating the floating ip address: %s" % e.message)
|
||||
module.exit_json(changed=True, result=result)
|
||||
|
||||
|
@ -231,7 +231,7 @@ def main():
|
|||
nova = nova_client.Client(module.params['login_username'], module.params['login_password'],
|
||||
module.params['login_tenant_name'], module.params['auth_url'], service_type='compute')
|
||||
neutron = _get_neutron_client(module, module.params)
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
module.fail_json(msg="Error in authenticating to nova: %s" % e.message)
|
||||
|
||||
server_info, server_obj = _get_server_state(module, nova)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue