mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Fixing open stack compile time errors irt exception handling for Python 3 (#3848)
This commit is contained in:
@@ -142,7 +142,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, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error authenticating to the keystone: %s " % e.message)
|
||||
return client
|
||||
|
||||
@@ -150,7 +150,7 @@ def _get_ksclient(module, kwargs):
|
||||
def _get_endpoint(module, client, endpoint_type):
|
||||
try:
|
||||
endpoint = client.service_catalog.url_for(service_type='image', endpoint_type=endpoint_type)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error getting endpoint for glance: %s" % e.message)
|
||||
return endpoint
|
||||
|
||||
@@ -164,7 +164,7 @@ def _get_glance_client(module, kwargs):
|
||||
}
|
||||
try:
|
||||
client = glanceclient.Client('1', endpoint, **kwargs)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error in connecting to glance: %s" % e.message)
|
||||
return client
|
||||
|
||||
@@ -175,7 +175,7 @@ def _glance_image_present(module, params, client):
|
||||
if image.name == params['name']:
|
||||
return image.id
|
||||
return None
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error in fetching image list: %s" % e.message)
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ def _glance_image_create(module, params, client):
|
||||
if image.status == 'active':
|
||||
break
|
||||
time.sleep(5)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error in creating image: %s" % e.message)
|
||||
if image.status == 'active':
|
||||
module.exit_json(changed=True, result=image.status, id=image.id)
|
||||
@@ -212,7 +212,7 @@ def _glance_delete_image(module, params, client):
|
||||
for image in client.images.list():
|
||||
if image.name == params['name']:
|
||||
client.images.delete(image)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error in deleting image: %s" % e.message)
|
||||
module.exit_json(changed=True, result="Deleted")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user