]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use save_and_reraise_exception when reraise exception
authorAkihiro Motoki <motoki@da.jp.nec.com>
Wed, 12 Feb 2014 14:25:14 +0000 (23:25 +0900)
committerAkihiro Motoki <motoki@da.jp.nec.com>
Fri, 21 Mar 2014 12:31:55 +0000 (21:31 +0900)
This fixes reraise in pluign codes.

Closes-Bug: #1279813
Change-Id: Iee174d94c0ce69eb01eb86eea1a903eceb7569d5

15 files changed:
neutron/plugins/brocade/nos/nosdriver.py
neutron/plugins/midonet/plugin.py
neutron/plugins/ml2/drivers/brocade/nos/nosdriver.py
neutron/plugins/ml2/plugin.py
neutron/plugins/nec/common/ofc_client.py
neutron/plugins/nec/nec_plugin.py
neutron/plugins/nec/nec_router.py
neutron/plugins/ryu/ryu_neutron_plugin.py
neutron/plugins/vmware/dbexts/db.py
neutron/plugins/vmware/dhcp_meta/lsnmanager.py
neutron/plugins/vmware/dhcp_meta/nsx.py
neutron/plugins/vmware/nsxlib/secgroup.py
neutron/plugins/vmware/plugins/base.py
neutron/plugins/vmware/plugins/service.py
neutron/plugins/vmware/vshield/edge_ipsecvpn_driver.py

index 58cab2c38c232ce710ad610381e4fae59e90b671..ce4c86110b7bf3b360f6d1317f5d273ff390387a 100644 (file)
@@ -67,8 +67,8 @@ class NOSdriver():
                                        username=username, password=password,
                                        unknown_host_cb=nos_unknown_host_cb)
         except Exception as e:
-            LOG.error(_("Connect failed to switch: %s"), e)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.error(_("Connect failed to switch: %s"), e)
 
         LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
                   dict(host=host, ssh_port=SSH_PORT))
index 2db62870406fd90c3e692598c421494dafd4ed97..5188ba0363bcf5981139678bbe700d9c622e31bf 100644 (file)
@@ -518,9 +518,9 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             super(MidonetPluginV2, self).delete_network(context, id)
         except Exception:
-            LOG.error(_('Failed to delete neutron db, while Midonet bridge=%r'
-                      'had been deleted'), id)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.error(_('Failed to delete neutron db, while Midonet '
+                            'bridge=%r had been deleted'), id)
 
     def create_port(self, context, port):
         """Create a L2 port in Neutron/MidoNet."""
index 26b37f63f3691323bb522f457bc40ce26030026c..56a74ba79444cde7d8892d02cc34716258ad15e4 100644 (file)
@@ -70,8 +70,8 @@ class NOSdriver():
                                        username=username, password=password,
                                        unknown_host_cb=nos_unknown_host_cb)
         except Exception:
-            LOG.exception(_("Connect failed to switch"))
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("Connect failed to switch"))
 
         LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
                   dict(host=host, ssh_port=SSH_PORT))
index a51dd350766d800bc5f80f44b9ff324ff5a98f02..8abeb43aa67a5234f309300617b50d05e8a4736d 100644 (file)
@@ -485,28 +485,28 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                         LOG.debug(_("Committing transaction"))
                         break
             except os_db.exception.DBError as e:
-                if isinstance(e.inner_exception, sql_exc.IntegrityError):
-                    msg = _("A concurrent port creation has occurred")
-                    LOG.warning(msg)
-                    continue
-                else:
-                    raise
+                with excutils.save_and_reraise_exception() as ctxt:
+                    if isinstance(e.inner_exception, sql_exc.IntegrityError):
+                        ctxt.reraise = False
+                        msg = _("A concurrent port creation has occurred")
+                        LOG.warning(msg)
+                        continue
 
             for port in ports:
                 try:
                     self.delete_port(context, port.id)
                 except Exception:
-                    LOG.exception(_("Exception auto-deleting port %s"),
-                                  port.id)
-                    raise
+                    with excutils.save_and_reraise_exception():
+                        LOG.exception(_("Exception auto-deleting port %s"),
+                                      port.id)
 
             for subnet in subnets:
                 try:
                     self.delete_subnet(context, subnet.id)
                 except Exception:
-                    LOG.exception(_("Exception auto-deleting subnet %s"),
-                                  subnet.id)
-                    raise
+                    with excutils.save_and_reraise_exception():
+                        LOG.exception(_("Exception auto-deleting subnet %s"),
+                                      subnet.id)
 
         try:
             self.mechanism_manager.delete_network_postcommit(mech_context)
@@ -595,9 +595,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                 try:
                     self.delete_port(context, a.port_id)
                 except Exception:
-                    LOG.exception(_("Exception auto-deleting port %s"),
-                                  a.port_id)
-                    raise
+                    with excutils.save_and_reraise_exception():
+                        LOG.exception(_("Exception auto-deleting port %s"),
+                                      a.port_id)
 
         try:
             self.mechanism_manager.delete_subnet_postcommit(mech_context)
index 6456cece85fa1c47eaf395ede14ac45022eb7df4..55b128562ba384a9466119952f59fadff89281a5 100644 (file)
@@ -20,6 +20,7 @@ import json
 import socket
 import time
 
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.nec.common import config
 from neutron.plugins.nec.common import exceptions as nexc
@@ -129,16 +130,17 @@ class OFCClient(object):
             try:
                 return self.do_single_request(method, action, body)
             except nexc.OFCServiceUnavailable as e:
-                try:
-                    wait_time = int(e.retry_after)
-                except (ValueError, TypeError):
-                    wait_time = None
-                if i > 1 and wait_time:
-                    LOG.info(_("Waiting for %s seconds due to "
-                               "OFC Service_Unavailable."), wait_time)
-                    time.sleep(wait_time)
-                    continue
-                raise
+                with excutils.save_and_reraise_exception() as ctxt:
+                    try:
+                        wait_time = int(e.retry_after)
+                    except (ValueError, TypeError):
+                        wait_time = None
+                    if i > 1 and wait_time:
+                        LOG.info(_("Waiting for %s seconds due to "
+                                   "OFC Service_Unavailable."), wait_time)
+                        time.sleep(wait_time)
+                        ctxt.reraise = False
+                        continue
 
     def get(self, action):
         return self.do_request("GET", action)
index f19781fbbe4d8ec4cfd1983a211cb11d35a9779f..26e74806ffd9145a16ff1f834a493f099fc35788 100644 (file)
@@ -37,6 +37,7 @@ from neutron.db import quota_db  # noqa
 from neutron.db import securitygroups_rpc_base as sg_db_rpc
 from neutron.extensions import allowedaddresspairs as addr_pair
 from neutron.extensions import portbindings
+from neutron.openstack.common import excutils
 from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import rpc
@@ -384,11 +385,11 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self.ofc.delete_ofc_network(context, id, net_db)
         except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
-            reason = _("delete_network() failed due to %s") % exc
-            LOG.error(reason)
-            self._update_resource_status(context, "network", net_db['id'],
-                                         const.NET_STATUS_ERROR)
-            raise
+            with excutils.save_and_reraise_exception():
+                reason = _("delete_network() failed due to %s") % exc
+                LOG.error(reason)
+                self._update_resource_status(context, "network", net_db['id'],
+                                             const.NET_STATUS_ERROR)
 
         super(NECPluginV2, self).delete_network(context, id)
 
index 487e9a23ef6c474b93162dabd7bd89c04abac2a3..e1a6ef6c9e6e706e24088ff4bc2fd22647c91161 100644 (file)
@@ -26,6 +26,7 @@ from neutron.db import l3_db
 from neutron.db import l3_gwmode_db
 from neutron.db import models_v2
 from neutron.extensions import l3
+from neutron.openstack.common import excutils
 from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.nec.common import config
@@ -77,8 +78,9 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
         try:
             return driver.create_router(context, tenant_id, new_router)
         except nexc.RouterOverLimit:
-            super(RouterMixin, self).delete_router(context, new_router['id'])
-            raise
+            with excutils.save_and_reraise_exception():
+                super(RouterMixin, self).delete_router(context,
+                                                       new_router['id'])
 
     def update_router(self, context, router_id, router):
         LOG.debug(_("RouterMixin.update_router() called, "
index 5eaf2770a028def03e8fb3a1612a68bb155f8a2a..3e8b8300b24dc43e05298692338eeb6d7359d8d2 100644 (file)
@@ -36,6 +36,7 @@ from neutron.db import models_v2
 from neutron.db import portbindings_base
 from neutron.db import securitygroups_rpc_base as sg_db_rpc
 from neutron.extensions import portbindings
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import rpc
 from neutron.openstack.common.rpc import proxy
@@ -180,8 +181,8 @@ class RyuNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             try:
                 self._client_create_network(net['id'], tunnel_key)
             except Exception:
-                self._client_delete_network(net['id'])
-                raise
+                with excutils.save_and_reraise_exception():
+                    self._client_delete_network(net['id'])
 
         return net
 
index 831d41b2fccafe7edbcfeadfc6d63ed87f2043d2..0db4f09a3f9b815983ab2dfb36ac13f3a0eb9c62 100644 (file)
@@ -18,6 +18,7 @@ from sqlalchemy.orm import exc
 
 import neutron.db.api as db
 from neutron.openstack.common.db import exception as db_exc
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.vmware.dbexts import models
 from neutron.plugins.vmware.dbexts import networkgw_db
@@ -64,20 +65,21 @@ def add_neutron_nsx_port_mapping(session, neutron_id,
         session.add(mapping)
         session.commit()
     except db_exc.DBDuplicateEntry:
-        session.rollback()
-        # do not complain if the same exact mapping is being added, otherwise
-        # re-raise because even though it is possible for the same neutron
-        # port to map to different back-end ports over time, this should not
-        # occur whilst a mapping already exists
-        current = get_nsx_switch_and_port_id(session, neutron_id)
-        if current[1] == nsx_port_id:
-            LOG.debug(_("Port mapping for %s already available"), neutron_id)
-        else:
-            raise
+        with excutils.save_and_reraise_exception() as ctxt:
+            session.rollback()
+            # do not complain if the same exact mapping is being added,
+            # otherwise re-raise because even though it is possible for the
+            # same neutron port to map to different back-end ports over time,
+            # this should not occur whilst a mapping already exists
+            current = get_nsx_switch_and_port_id(session, neutron_id)
+            if current[1] == nsx_port_id:
+                LOG.debug(_("Port mapping for %s already available"),
+                          neutron_id)
+                ctxt.reraise = False
     except db_exc.DBError:
-        # rollback for any other db error
-        session.rollback()
-        raise
+        with excutils.save_and_reraise_exception():
+            # rollback for any other db error
+            session.rollback()
     return mapping
 
 
index a9214d7959a8fcdfc87376718ca09abf19012b58..03a2af61ec31b3442531aff827e61d9e78f899e0 100644 (file)
@@ -19,6 +19,7 @@ from oslo.config import cfg
 
 from neutron.common import exceptions as n_exc
 from neutron.openstack.common.db import exception as db_exc
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.vmware.api_client import exception as api_exc
 from neutron.plugins.vmware.common import exceptions as p_exc
@@ -354,13 +355,15 @@ class PersistentLsnManager(LsnManager):
                 context, network_id, raise_on_err=raise_on_err)
             return obj.lsn_id if obj else None
         except p_exc.LsnNotFound:
-            if self.sync_on_missing:
-                lsn_id = super(PersistentLsnManager, self).lsn_get(
-                    context, network_id, raise_on_err=raise_on_err)
-                self.lsn_save(context, network_id, lsn_id)
-                return lsn_id
-            if raise_on_err:
-                raise
+            with excutils.save_and_reraise_exception() as ctxt:
+                ctxt.reraise = False
+                if self.sync_on_missing:
+                    lsn_id = super(PersistentLsnManager, self).lsn_get(
+                        context, network_id, raise_on_err=raise_on_err)
+                    self.lsn_save(context, network_id, lsn_id)
+                    return lsn_id
+                if raise_on_err:
+                    ctxt.reraise = True
 
     def lsn_save(self, context, network_id, lsn_id):
         """Save LSN-Network mapping to the DB."""
@@ -377,8 +380,8 @@ class PersistentLsnManager(LsnManager):
         try:
             self.lsn_save(context, network_id, lsn_id)
         except p_exc.NsxPluginException:
-            super(PersistentLsnManager, self).lsn_delete(context, lsn_id)
-            raise
+            with excutils.save_and_reraise_exception():
+                super(PersistentLsnManager, self).lsn_delete(context, lsn_id)
         return lsn_id
 
     def lsn_delete(self, context, lsn_id):
@@ -391,18 +394,20 @@ class PersistentLsnManager(LsnManager):
                 context, subnet_id, raise_on_err=raise_on_err)
             return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
         except p_exc.LsnPortNotFound:
-            if self.sync_on_missing:
-                lsn_id, lsn_port_id = (
-                    super(PersistentLsnManager, self).lsn_port_get(
-                        context, network_id, subnet_id,
-                        raise_on_err=raise_on_err))
-                mac_addr = lsn_api.lsn_port_info_get(
-                    self.cluster, lsn_id, lsn_port_id)['mac_address']
-                self.lsn_port_save(
-                    context, lsn_port_id, subnet_id, mac_addr, lsn_id)
-                return (lsn_id, lsn_port_id)
-            if raise_on_err:
-                raise
+            with excutils.save_and_reraise_exception() as ctxt:
+                ctxt.reraise = False
+                if self.sync_on_missing:
+                    lsn_id, lsn_port_id = (
+                        super(PersistentLsnManager, self).lsn_port_get(
+                            context, network_id, subnet_id,
+                            raise_on_err=raise_on_err))
+                    mac_addr = lsn_api.lsn_port_info_get(
+                        self.cluster, lsn_id, lsn_port_id)['mac_address']
+                    self.lsn_port_save(
+                        context, lsn_port_id, subnet_id, mac_addr, lsn_id)
+                    return (lsn_id, lsn_port_id)
+                if raise_on_err:
+                    ctxt.reraise = True
 
     def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
         try:
@@ -410,18 +415,20 @@ class PersistentLsnManager(LsnManager):
                 context, mac, raise_on_err=raise_on_err)
             return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
         except p_exc.LsnPortNotFound:
-            if self.sync_on_missing:
-                lsn_id, lsn_port_id = (
-                    super(PersistentLsnManager, self).lsn_port_get_by_mac(
-                        context, network_id, mac,
-                        raise_on_err=raise_on_err))
-                subnet_id = lsn_api.lsn_port_info_get(
-                    self.cluster, lsn_id, lsn_port_id).get('subnet_id')
-                self.lsn_port_save(
-                    context, lsn_port_id, subnet_id, mac, lsn_id)
-                return (lsn_id, lsn_port_id)
-            if raise_on_err:
-                raise
+            with excutils.save_and_reraise_exception() as ctxt:
+                ctxt.reraise = False
+                if self.sync_on_missing:
+                    lsn_id, lsn_port_id = (
+                        super(PersistentLsnManager, self).lsn_port_get_by_mac(
+                            context, network_id, mac,
+                            raise_on_err=raise_on_err))
+                    subnet_id = lsn_api.lsn_port_info_get(
+                        self.cluster, lsn_id, lsn_port_id).get('subnet_id')
+                    self.lsn_port_save(
+                        context, lsn_port_id, subnet_id, mac, lsn_id)
+                    return (lsn_id, lsn_port_id)
+                if raise_on_err:
+                    ctxt.reraise = True
 
     def lsn_port_save(self, context, lsn_port_id, subnet_id, mac_addr, lsn_id):
         """Save LSN Port information to the DB."""
@@ -440,9 +447,9 @@ class PersistentLsnManager(LsnManager):
             self.lsn_port_save(context, lsn_port_id, subnet_info['subnet_id'],
                                subnet_info['mac_address'], lsn_id)
         except p_exc.NsxPluginException:
-            super(PersistentLsnManager, self).lsn_port_delete(
-                context, lsn_id, lsn_port_id)
-            raise
+            with excutils.save_and_reraise_exception():
+                super(PersistentLsnManager, self).lsn_port_delete(
+                    context, lsn_id, lsn_port_id)
         return lsn_port_id
 
     def lsn_port_delete(self, context, lsn_id, lsn_port_id):
index 8e5c0e5008f7d38dad71f62ca36b699370166672..6fbb350627a40aead16582faba7ddc73044051fa 100644 (file)
@@ -23,6 +23,7 @@ from neutron.common import exceptions as n_exc
 from neutron.db import db_base_plugin_v2
 from neutron.db import l3_db
 from neutron.extensions import external_net
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.vmware.common import exceptions as p_exc
 from neutron.plugins.vmware.dhcp_meta import constants as d_const
@@ -261,10 +262,10 @@ def handle_port_dhcp_access(plugin, context, port, action):
             try:
                 handler(context, network_id, subnet_id, host_data)
             except p_exc.PortConfigurationError:
-                if action == 'create_port':
-                    db_base_plugin_v2.NeutronDbPluginV2.delete_port(
-                        plugin, context, port['id'])
-                raise
+                with excutils.save_and_reraise_exception():
+                    if action == 'create_port':
+                        db_base_plugin_v2.NeutronDbPluginV2.delete_port(
+                            plugin, context, port['id'])
     LOG.info(_("DHCP for port %s configured successfully"), port['id'])
 
 
@@ -289,10 +290,10 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
         try:
             handler(context, network_id, subnet_id, host_data)
         except p_exc.PortConfigurationError:
-            if not is_delete:
-                db_base_plugin_v2.NeutronDbPluginV2.delete_port(
-                    plugin, context, port['id'])
-            raise
+            with excutils.save_and_reraise_exception():
+                if not is_delete:
+                    db_base_plugin_v2.NeutronDbPluginV2.delete_port(
+                        plugin, context, port['id'])
         LOG.info(_("Metadata for port %s configured successfully"), port['id'])
 
 
@@ -310,8 +311,8 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
             plugin.lsn_manager.lsn_metadata_configure(
                 context, subnet_id, is_enabled)
         except p_exc.NsxPluginException:
-            if is_enabled:
-                l3_db.L3_NAT_db_mixin.remove_router_interface(
-                    plugin, context, router_id, interface)
-            raise
+            with excutils.save_and_reraise_exception():
+                if is_enabled:
+                    l3_db.L3_NAT_db_mixin.remove_router_interface(
+                        plugin, context, router_id, interface)
     LOG.info(_("Metadata for router %s handled successfully"), router_id)
index 29d0951e9375a6782489a9d2e702d6be7230db5e..ad8ac2dc6937993709c98f232f1b4c751e2da7cb 100644 (file)
@@ -17,6 +17,7 @@ import json
 
 from neutron.common import constants
 from neutron.common import exceptions
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log
 from neutron.plugins.vmware.common import utils
 from neutron.plugins.vmware.nsxlib import _build_uri_path
@@ -139,7 +140,7 @@ def delete_security_profile(cluster, spid):
     try:
         do_request(HTTP_DELETE, path, cluster=cluster)
     except exceptions.NotFound:
-        # This is not necessarily an error condition
-        LOG.warn(_("Unable to find security profile %s on NSX backend"),
-                 spid)
-        raise
+        with excutils.save_and_reraise_exception():
+            # This is not necessarily an error condition
+            LOG.warn(_("Unable to find security profile %s on NSX backend"),
+                     spid)
index 0ad0fc3086fe6672e4fd7ecab97b3976f697bb7d..e307d6ab1bfe04e68d847f1237f7fe6d67a01436 100644 (file)
@@ -204,9 +204,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
             # Ensure this method is executed only once
             self._is_default_net_gw_in_sync = True
         except Exception:
-            LOG.exception(_("Unable to process default l2 gw service:%s"),
-                          def_l2_gw_uuid)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("Unable to process default l2 gw service:%s"),
+                              def_l2_gw_uuid)
 
     def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
         """Build ip_addresses data structure for logical router port.
@@ -1803,10 +1803,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
                 destination_ip_addresses=internal_ip)
 
         except api_exc.NsxApiException:
-            LOG.exception(_("An error occurred while removing NAT rules "
-                            "on the NSX platform for floating ip:%s"),
-                          floating_ip_address)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("An error occurred while removing NAT rules "
+                                "on the NSX platform for floating ip:%s"),
+                              floating_ip_address)
         except nsx_exc.NatRuleMismatch:
             # Do not surface to the user
             LOG.warning(_("An incorrect number of matching NAT rules "
@@ -2285,13 +2285,13 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
                        "resource was not found"),
                      {'neutron_id': device_id, 'nsx_id': nsx_device_id})
         except api_exc.NsxApiException:
-            LOG.exception(_("Removal of gateway device: %(neutron_id)s "
-                            "failed on NSX backend (NSX id:%(nsx_id)s). "
-                            "Neutron and NSX states have diverged."),
-                          {'neutron_id': device_id,
-                           'nsx_id': nsx_device_id})
-            # In this case a 500 should be returned
-            raise
+            with excutils.save_and_reraise_exception():
+                # In this case a 500 should be returned
+                LOG.exception(_("Removal of gateway device: %(neutron_id)s "
+                                "failed on NSX backend (NSX id:%(nsx_id)s). "
+                                "Neutron and NSX states have diverged."),
+                              {'neutron_id': device_id,
+                               'nsx_id': nsx_device_id})
 
     def create_security_group(self, context, security_group, default_sg=False):
         """Create security group.
index 8414600ad2c1013da9d8c9612d31dc32fbac1405..b181baf5992e4170e95c14812c6b492c9d8945c2 100644 (file)
@@ -1563,15 +1563,15 @@ class NsxAdvancedPlugin(sr_db.ServiceRouter_mixin,
             self.vcns_driver.update_ipsec_config(
                 edge_id, sites, enabled=vpn_service.admin_state_up)
         except exceptions.VcnsBadRequest:
-            LOG.exception(_("Bad or unsupported Input request!"))
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("Bad or unsupported Input request!"))
         except exceptions.VcnsApiException:
-            msg = (_("Failed to update ipsec VPN configuration "
-                     "with vpnservice: %(vpnservice_id)s on vShield Edge: "
-                     "%(edge_id)s") % {'vpnservice_id': vpnservice_id,
-                                       'edge_id': edge_id})
-            LOG.exception(msg)
-            raise
+            with excutils.save_and_reraise_exception():
+                msg = (_("Failed to update ipsec VPN configuration "
+                         "with vpnservice: %(vpnservice_id)s on vShield Edge: "
+                         "%(edge_id)s") % {'vpnservice_id': vpnservice_id,
+                                           'edge_id': edge_id})
+                LOG.exception(msg)
 
     def create_vpnservice(self, context, vpnservice):
         LOG.debug(_("create_vpnservice() called"))
index ae39187ea4daac63178aa5b926238a3b897750c7..7e74fe1f8703e119bdc53a1eb815a6c7ab91f89d 100644 (file)
@@ -12,6 +12,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.vmware.vshield.common import (
     exceptions as vcns_exc)
@@ -131,9 +132,9 @@ class EdgeIPsecVpnDriver():
         try:
             self.vcns.update_ipsec_config(edge_id, ipsec_config)
         except vcns_exc.VcnsApiException:
-            LOG.exception(_("Failed to update ipsec vpn configuration "
-                            "with edge_id: %s"), edge_id)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("Failed to update ipsec vpn configuration "
+                                "with edge_id: %s"), edge_id)
 
     def delete_ipsec_config(self, edge_id):
         try:
@@ -141,9 +142,9 @@ class EdgeIPsecVpnDriver():
         except vcns_exc.ResourceNotFound:
             LOG.warning(_("IPsec config not found on edge: %s"), edge_id)
         except vcns_exc.VcnsApiException:
-            LOG.exception(_("Failed to delete ipsec vpn configuration "
-                            "with edge_id: %s"), edge_id)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_("Failed to delete ipsec vpn configuration "
+                                "with edge_id: %s"), edge_id)
 
     def get_ipsec_config(self, edge_id):
         return self.vcns.get_ipsec_config(edge_id)