Don't throw traceback for connection problems
Currently all API checks throw Python tracebacks in case of connection problem. This patch makes that only last exception message is reported. Change-Id: I6ac0ca5a0374eb569672c497f4c02d3480af9bea
This commit is contained in:
parent
a8f40fe2dc
commit
9f8354bbfe
|
@ -35,11 +35,12 @@ def _check_ceilometer_api():
|
|||
|
||||
def meters_list():
|
||||
try:
|
||||
result = client.meters.list()
|
||||
return client.meters.list()
|
||||
except exceptions.Gone as ex:
|
||||
msg = json.loads(ex.response.content)
|
||||
utils.warning(re.sub(r'\s\s*', ' ', msg['error_message']))
|
||||
return result
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, meters = utils.timeit(meters_list)
|
||||
if not meters:
|
||||
|
|
|
@ -39,7 +39,10 @@ def _check_cinder_api():
|
|||
options, args, client = cinder.setup()
|
||||
|
||||
def quotas_list():
|
||||
return client.quotas.get(options.os_tenant_name)
|
||||
try:
|
||||
return client.quotas.get(options.os_tenant_name)
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, quotas = utils.timeit(quotas_list)
|
||||
if not quotas:
|
||||
|
|
|
@ -30,7 +30,10 @@ def _check_glance_api():
|
|||
options, args, client = glance.setup()
|
||||
|
||||
def images_list():
|
||||
return list(client.images.list())
|
||||
try:
|
||||
return list(client.images.list())
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, images = utils.timeit(images_list)
|
||||
if not images:
|
||||
|
|
|
@ -25,7 +25,10 @@ def _check_keystone_api():
|
|||
keystone = utils.Keystone()
|
||||
|
||||
def check_token():
|
||||
return keystone.run()
|
||||
try:
|
||||
return keystone.run()
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, result = utils.timeit(check_token)
|
||||
rc, out = result
|
||||
|
|
|
@ -39,7 +39,13 @@ def _check_neutron_api():
|
|||
help='Critical timeout for neutron APIs calls')
|
||||
options, args, client = neutron.setup()
|
||||
|
||||
elapsed, networks = utils.timeit(client.list_networks)
|
||||
def network_list():
|
||||
try:
|
||||
return client.list_networks()
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, networks = utils.timeit(network_list)
|
||||
if not networks or len(networks.get('networks', [])) <= 0:
|
||||
utils.critical("Unable to contact neutron API.")
|
||||
|
||||
|
|
|
@ -40,7 +40,10 @@ def _check_nova_api():
|
|||
options, args, client = nova.setup()
|
||||
|
||||
def flavors_list():
|
||||
return list(client.flavors.list())
|
||||
try:
|
||||
return list(client.flavors.list())
|
||||
except Exception as ex:
|
||||
utils.critical(str(ex))
|
||||
|
||||
elapsed, flavors = utils.timeit(flavors_list)
|
||||
if not flavors:
|
||||
|
|
Loading…
Reference in New Issue