Merge "Edge driver: Improve exception handling"

This commit is contained in:
Jenkins 2014-04-13 12:16:22 +00:00 committed by Gerrit Code Review
commit b4f136f19f
1 changed files with 22 additions and 22 deletions

View File

@ -165,15 +165,15 @@ class EdgeApplianceDriver(object):
try: try:
self.vcns.update_interface(edge_id, config) self.vcns.update_interface(edge_id, config)
except exceptions.VcnsApiException as e: except exceptions.VcnsApiException as e:
LOG.exception(_("VCNS: Failed to update vnic %(config)s:\n" with excutils.save_and_reraise_exception():
"%(response)s"), { LOG.exception(_("VCNS: Failed to update vnic %(config)s:\n"
'config': config, "%(response)s"), {
'response': e.response}) 'config': config,
raise e 'response': e.response})
except Exception as e: except Exception:
LOG.exception(_("VCNS: Failed to update vnic %d"), with excutils.save_and_reraise_exception():
config['index']) LOG.exception(_("VCNS: Failed to update vnic %d"),
raise e config['index'])
return TaskStatus.COMPLETED return TaskStatus.COMPLETED
@ -221,10 +221,10 @@ class EdgeApplianceDriver(object):
LOG.debug(_("VCNS: deploying edge %s"), edge_id) LOG.debug(_("VCNS: deploying edge %s"), edge_id)
userdata['edge_id'] = edge_id userdata['edge_id'] = edge_id
status = TaskStatus.PENDING status = TaskStatus.PENDING
except exceptions.VcnsApiException as e: except exceptions.VcnsApiException:
LOG.exception(_("VCNS: deploy edge failed for router %s."), with excutils.save_and_reraise_exception():
name) LOG.exception(_("VCNS: deploy edge failed for router %s."),
raise e name)
return status return status
@ -240,10 +240,10 @@ class EdgeApplianceDriver(object):
status = TaskStatus.COMPLETED status = TaskStatus.COMPLETED
else: else:
status = TaskStatus.ERROR status = TaskStatus.ERROR
except exceptions.VcnsApiException as e: except exceptions.VcnsApiException:
LOG.exception(_("VCNS: Edge %s status query failed."), edge_id) with excutils.save_and_reraise_exception():
raise e LOG.exception(_("VCNS: Edge %s status query failed."), edge_id)
except Exception as e: except Exception:
retries = task.userdata.get('retries', 0) + 1 retries = task.userdata.get('retries', 0) + 1
if retries < 3: if retries < 3:
task.userdata['retries'] = retries task.userdata['retries'] = retries
@ -302,8 +302,8 @@ class EdgeApplianceDriver(object):
try: try:
return self.vcns.get_edges()[1] return self.vcns.get_edges()[1]
except exceptions.VcnsApiException as e: except exceptions.VcnsApiException as e:
LOG.exception(_("VCNS: Failed to get edges:\n%s"), e.response) with excutils.save_and_reraise_exception():
raise e LOG.exception(_("VCNS: Failed to get edges:\n%s"), e.response)
def deploy_edge(self, router_id, name, internal_network, jobdata=None, def deploy_edge(self, router_id, name, internal_network, jobdata=None,
wait_for_exec=False, loadbalancer_enable=True): wait_for_exec=False, loadbalancer_enable=True):
@ -380,9 +380,9 @@ class EdgeApplianceDriver(object):
try: try:
return self.vcns.get_nat_config(edge_id)[1] return self.vcns.get_nat_config(edge_id)[1]
except exceptions.VcnsApiException as e: except exceptions.VcnsApiException as e:
LOG.exception(_("VCNS: Failed to get nat config:\n%s"), with excutils.save_and_reraise_exception():
e.response) LOG.exception(_("VCNS: Failed to get nat config:\n%s"),
raise e e.response)
def _create_nat_rule(self, task): def _create_nat_rule(self, task):
# TODO(fank): use POST for optimization # TODO(fank): use POST for optimization