From 5e90a0a64ba5e9fa2823795dd8a1c09ba459058e Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Wed, 9 Apr 2014 02:46:52 -0700 Subject: [PATCH] Edge firewall: improve exception handling Improve the exception handling in the edge firewall Partial-Bug: #1305032 Change-Id: Ib095a48dd7cb958c0c5cf5682eeb7fc93f2b55dd --- .../vmware/vshield/edge_firewall_driver.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/neutron/plugins/vmware/vshield/edge_firewall_driver.py b/neutron/plugins/vmware/vshield/edge_firewall_driver.py index 582ce95f3..d07c0456a 100644 --- a/neutron/plugins/vmware/vshield/edge_firewall_driver.py +++ b/neutron/plugins/vmware/vshield/edge_firewall_driver.py @@ -187,10 +187,10 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2): def _get_firewall(self, context, edge_id): try: return self.vcns.get_firewall(edge_id)[1] - except vcns_exc.VcnsApiException as e: - LOG.exception(_("Failed to get firewall with edge " - "id: %s"), edge_id) - raise e + except vcns_exc.VcnsApiException: + with excutils.save_and_reraise_exception(): + LOG.exception(_("Failed to get firewall with edge " + "id: %s"), edge_id) def _get_firewall_rule_next(self, context, edge_id, rule_vseid): # Return the firewall rule below 'rule_vseid' @@ -215,12 +215,12 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2): try: response = self.vcns.get_firewall_rule( edge_id, vcns_rule_id)[1] - except vcns_exc.VcnsApiException as e: - LOG.exception(_("Failed to get firewall rule: %(rule_id)s " - "with edge_id: %(edge_id)s"), { - 'rule_id': id, - 'edge_id': edge_id}) - raise e + except vcns_exc.VcnsApiException: + with excutils.save_and_reraise_exception(): + LOG.exception(_("Failed to get firewall rule: %(rule_id)s " + "with edge_id: %(edge_id)s"), { + 'rule_id': id, + 'edge_id': edge_id}) return self._restore_firewall_rule(context, edge_id, response) def get_firewall(self, context, edge_id): @@ -231,10 +231,10 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2): fw_req = self._convert_firewall(context, firewall) try: self.vcns.update_firewall(edge_id, fw_req) - except vcns_exc.VcnsApiException as e: - LOG.exception(_("Failed to update firewall " - "with edge_id: %s"), edge_id) - raise e + except vcns_exc.VcnsApiException: + with excutils.save_and_reraise_exception(): + LOG.exception(_("Failed to update firewall " + "with edge_id: %s"), edge_id) fw_res = self._get_firewall(context, edge_id) vcns_db.cleanup_vcns_edge_firewallrule_binding( context.session, edge_id) @@ -243,10 +243,10 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2): def delete_firewall(self, context, edge_id): try: self.vcns.delete_firewall(edge_id) - except vcns_exc.VcnsApiException as e: - LOG.exception(_("Failed to delete firewall " - "with edge_id:%s"), edge_id) - raise e + except vcns_exc.VcnsApiException: + with excutils.save_and_reraise_exception(): + LOG.exception(_("Failed to delete firewall " + "with edge_id:%s"), edge_id) vcns_db.cleanup_vcns_edge_firewallrule_binding( context.session, edge_id) -- 2.45.2