Use save_and_reraise_exception when reraise exception

This fixes reraise in pluign codes.

Closes-Bug: #1279813
Change-Id: Iee174d94c0ce69eb01eb86eea1a903eceb7569d5
This commit is contained in:
Akihiro Motoki 2014-02-12 23:25:14 +09:00
parent a742ca0011
commit 3c0025abf4
15 changed files with 152 additions and 134 deletions

View File

@ -67,8 +67,8 @@ class NOSdriver():
username=username, password=password, username=username, password=password,
unknown_host_cb=nos_unknown_host_cb) unknown_host_cb=nos_unknown_host_cb)
except Exception as e: except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error(_("Connect failed to switch: %s"), e) LOG.error(_("Connect failed to switch: %s"), e)
raise
LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"), LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
dict(host=host, ssh_port=SSH_PORT)) dict(host=host, ssh_port=SSH_PORT))

View File

@ -518,9 +518,9 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
super(MidonetPluginV2, self).delete_network(context, id) super(MidonetPluginV2, self).delete_network(context, id)
except Exception: except Exception:
LOG.error(_('Failed to delete neutron db, while Midonet bridge=%r' with excutils.save_and_reraise_exception():
'had been deleted'), id) LOG.error(_('Failed to delete neutron db, while Midonet '
raise 'bridge=%r had been deleted'), id)
def create_port(self, context, port): def create_port(self, context, port):
"""Create a L2 port in Neutron/MidoNet.""" """Create a L2 port in Neutron/MidoNet."""

View File

@ -70,8 +70,8 @@ class NOSdriver():
username=username, password=password, username=username, password=password,
unknown_host_cb=nos_unknown_host_cb) unknown_host_cb=nos_unknown_host_cb)
except Exception: except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("Connect failed to switch")) LOG.exception(_("Connect failed to switch"))
raise
LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"), LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
dict(host=host, ssh_port=SSH_PORT)) dict(host=host, ssh_port=SSH_PORT))

View File

@ -485,28 +485,28 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("Committing transaction")) LOG.debug(_("Committing transaction"))
break break
except os_db.exception.DBError as e: except os_db.exception.DBError as e:
with excutils.save_and_reraise_exception() as ctxt:
if isinstance(e.inner_exception, sql_exc.IntegrityError): if isinstance(e.inner_exception, sql_exc.IntegrityError):
ctxt.reraise = False
msg = _("A concurrent port creation has occurred") msg = _("A concurrent port creation has occurred")
LOG.warning(msg) LOG.warning(msg)
continue continue
else:
raise
for port in ports: for port in ports:
try: try:
self.delete_port(context, port.id) self.delete_port(context, port.id)
except Exception: except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("Exception auto-deleting port %s"), LOG.exception(_("Exception auto-deleting port %s"),
port.id) port.id)
raise
for subnet in subnets: for subnet in subnets:
try: try:
self.delete_subnet(context, subnet.id) self.delete_subnet(context, subnet.id)
except Exception: except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("Exception auto-deleting subnet %s"), LOG.exception(_("Exception auto-deleting subnet %s"),
subnet.id) subnet.id)
raise
try: try:
self.mechanism_manager.delete_network_postcommit(mech_context) self.mechanism_manager.delete_network_postcommit(mech_context)
@ -595,9 +595,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
self.delete_port(context, a.port_id) self.delete_port(context, a.port_id)
except Exception: except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("Exception auto-deleting port %s"), LOG.exception(_("Exception auto-deleting port %s"),
a.port_id) a.port_id)
raise
try: try:
self.mechanism_manager.delete_subnet_postcommit(mech_context) self.mechanism_manager.delete_subnet_postcommit(mech_context)

View File

@ -20,6 +20,7 @@ import json
import socket import socket
import time import time
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.nec.common import config from neutron.plugins.nec.common import config
from neutron.plugins.nec.common import exceptions as nexc from neutron.plugins.nec.common import exceptions as nexc
@ -129,6 +130,7 @@ class OFCClient(object):
try: try:
return self.do_single_request(method, action, body) return self.do_single_request(method, action, body)
except nexc.OFCServiceUnavailable as e: except nexc.OFCServiceUnavailable as e:
with excutils.save_and_reraise_exception() as ctxt:
try: try:
wait_time = int(e.retry_after) wait_time = int(e.retry_after)
except (ValueError, TypeError): except (ValueError, TypeError):
@ -137,8 +139,8 @@ class OFCClient(object):
LOG.info(_("Waiting for %s seconds due to " LOG.info(_("Waiting for %s seconds due to "
"OFC Service_Unavailable."), wait_time) "OFC Service_Unavailable."), wait_time)
time.sleep(wait_time) time.sleep(wait_time)
ctxt.reraise = False
continue continue
raise
def get(self, action): def get(self, action):
return self.do_request("GET", action) return self.do_request("GET", action)

View 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.db import securitygroups_rpc_base as sg_db_rpc
from neutron.extensions import allowedaddresspairs as addr_pair from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common import excutils
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.openstack.common import rpc from neutron.openstack.common import rpc
@ -384,11 +385,11 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
self.ofc.delete_ofc_network(context, id, net_db) self.ofc.delete_ofc_network(context, id, net_db)
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc: except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
with excutils.save_and_reraise_exception():
reason = _("delete_network() failed due to %s") % exc reason = _("delete_network() failed due to %s") % exc
LOG.error(reason) LOG.error(reason)
self._update_resource_status(context, "network", net_db['id'], self._update_resource_status(context, "network", net_db['id'],
const.NET_STATUS_ERROR) const.NET_STATUS_ERROR)
raise
super(NECPluginV2, self).delete_network(context, id) super(NECPluginV2, self).delete_network(context, id)

View File

@ -26,6 +26,7 @@ from neutron.db import l3_db
from neutron.db import l3_gwmode_db from neutron.db import l3_gwmode_db
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.openstack.common import excutils
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.nec.common import config from neutron.plugins.nec.common import config
@ -77,8 +78,9 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
try: try:
return driver.create_router(context, tenant_id, new_router) return driver.create_router(context, tenant_id, new_router)
except nexc.RouterOverLimit: except nexc.RouterOverLimit:
super(RouterMixin, self).delete_router(context, new_router['id']) with excutils.save_and_reraise_exception():
raise super(RouterMixin, self).delete_router(context,
new_router['id'])
def update_router(self, context, router_id, router): def update_router(self, context, router_id, router):
LOG.debug(_("RouterMixin.update_router() called, " LOG.debug(_("RouterMixin.update_router() called, "

View File

@ -36,6 +36,7 @@ from neutron.db import models_v2
from neutron.db import portbindings_base from neutron.db import portbindings_base
from neutron.db import securitygroups_rpc_base as sg_db_rpc from neutron.db import securitygroups_rpc_base as sg_db_rpc
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.openstack.common import rpc from neutron.openstack.common import rpc
from neutron.openstack.common.rpc import proxy from neutron.openstack.common.rpc import proxy
@ -180,8 +181,8 @@ class RyuNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
self._client_create_network(net['id'], tunnel_key) self._client_create_network(net['id'], tunnel_key)
except Exception: except Exception:
with excutils.save_and_reraise_exception():
self._client_delete_network(net['id']) self._client_delete_network(net['id'])
raise
return net return net

View File

@ -18,6 +18,7 @@ from sqlalchemy.orm import exc
import neutron.db.api as db import neutron.db.api as db
from neutron.openstack.common.db import exception as db_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.openstack.common import log as logging
from neutron.plugins.vmware.dbexts import models from neutron.plugins.vmware.dbexts import models
from neutron.plugins.vmware.dbexts import networkgw_db 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.add(mapping)
session.commit() session.commit()
except db_exc.DBDuplicateEntry: except db_exc.DBDuplicateEntry:
with excutils.save_and_reraise_exception() as ctxt:
session.rollback() session.rollback()
# do not complain if the same exact mapping is being added, otherwise # do not complain if the same exact mapping is being added,
# re-raise because even though it is possible for the same neutron # otherwise re-raise because even though it is possible for the
# port to map to different back-end ports over time, this should not # same neutron port to map to different back-end ports over time,
# occur whilst a mapping already exists # this should not occur whilst a mapping already exists
current = get_nsx_switch_and_port_id(session, neutron_id) current = get_nsx_switch_and_port_id(session, neutron_id)
if current[1] == nsx_port_id: if current[1] == nsx_port_id:
LOG.debug(_("Port mapping for %s already available"), neutron_id) LOG.debug(_("Port mapping for %s already available"),
else: neutron_id)
raise ctxt.reraise = False
except db_exc.DBError: except db_exc.DBError:
with excutils.save_and_reraise_exception():
# rollback for any other db error # rollback for any other db error
session.rollback() session.rollback()
raise
return mapping return mapping

View File

@ -19,6 +19,7 @@ from oslo.config import cfg
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.openstack.common.db import exception as db_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.openstack.common import log as logging
from neutron.plugins.vmware.api_client import exception as api_exc from neutron.plugins.vmware.api_client import exception as api_exc
from neutron.plugins.vmware.common import exceptions as p_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) context, network_id, raise_on_err=raise_on_err)
return obj.lsn_id if obj else None return obj.lsn_id if obj else None
except p_exc.LsnNotFound: except p_exc.LsnNotFound:
with excutils.save_and_reraise_exception() as ctxt:
ctxt.reraise = False
if self.sync_on_missing: if self.sync_on_missing:
lsn_id = super(PersistentLsnManager, self).lsn_get( lsn_id = super(PersistentLsnManager, self).lsn_get(
context, network_id, raise_on_err=raise_on_err) context, network_id, raise_on_err=raise_on_err)
self.lsn_save(context, network_id, lsn_id) self.lsn_save(context, network_id, lsn_id)
return lsn_id return lsn_id
if raise_on_err: if raise_on_err:
raise ctxt.reraise = True
def lsn_save(self, context, network_id, lsn_id): def lsn_save(self, context, network_id, lsn_id):
"""Save LSN-Network mapping to the DB.""" """Save LSN-Network mapping to the DB."""
@ -377,8 +380,8 @@ class PersistentLsnManager(LsnManager):
try: try:
self.lsn_save(context, network_id, lsn_id) self.lsn_save(context, network_id, lsn_id)
except p_exc.NsxPluginException: except p_exc.NsxPluginException:
with excutils.save_and_reraise_exception():
super(PersistentLsnManager, self).lsn_delete(context, lsn_id) super(PersistentLsnManager, self).lsn_delete(context, lsn_id)
raise
return lsn_id return lsn_id
def lsn_delete(self, context, lsn_id): def lsn_delete(self, context, lsn_id):
@ -391,6 +394,8 @@ class PersistentLsnManager(LsnManager):
context, subnet_id, raise_on_err=raise_on_err) context, subnet_id, raise_on_err=raise_on_err)
return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None) return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
except p_exc.LsnPortNotFound: except p_exc.LsnPortNotFound:
with excutils.save_and_reraise_exception() as ctxt:
ctxt.reraise = False
if self.sync_on_missing: if self.sync_on_missing:
lsn_id, lsn_port_id = ( lsn_id, lsn_port_id = (
super(PersistentLsnManager, self).lsn_port_get( super(PersistentLsnManager, self).lsn_port_get(
@ -402,7 +407,7 @@ class PersistentLsnManager(LsnManager):
context, lsn_port_id, subnet_id, mac_addr, lsn_id) context, lsn_port_id, subnet_id, mac_addr, lsn_id)
return (lsn_id, lsn_port_id) return (lsn_id, lsn_port_id)
if raise_on_err: if raise_on_err:
raise ctxt.reraise = True
def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True): def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
try: try:
@ -410,6 +415,8 @@ class PersistentLsnManager(LsnManager):
context, mac, raise_on_err=raise_on_err) context, mac, raise_on_err=raise_on_err)
return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None) return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
except p_exc.LsnPortNotFound: except p_exc.LsnPortNotFound:
with excutils.save_and_reraise_exception() as ctxt:
ctxt.reraise = False
if self.sync_on_missing: if self.sync_on_missing:
lsn_id, lsn_port_id = ( lsn_id, lsn_port_id = (
super(PersistentLsnManager, self).lsn_port_get_by_mac( super(PersistentLsnManager, self).lsn_port_get_by_mac(
@ -421,7 +428,7 @@ class PersistentLsnManager(LsnManager):
context, lsn_port_id, subnet_id, mac, lsn_id) context, lsn_port_id, subnet_id, mac, lsn_id)
return (lsn_id, lsn_port_id) return (lsn_id, lsn_port_id)
if raise_on_err: if raise_on_err:
raise ctxt.reraise = True
def lsn_port_save(self, context, lsn_port_id, subnet_id, mac_addr, lsn_id): def lsn_port_save(self, context, lsn_port_id, subnet_id, mac_addr, lsn_id):
"""Save LSN Port information to the DB.""" """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'], self.lsn_port_save(context, lsn_port_id, subnet_info['subnet_id'],
subnet_info['mac_address'], lsn_id) subnet_info['mac_address'], lsn_id)
except p_exc.NsxPluginException: except p_exc.NsxPluginException:
with excutils.save_and_reraise_exception():
super(PersistentLsnManager, self).lsn_port_delete( super(PersistentLsnManager, self).lsn_port_delete(
context, lsn_id, lsn_port_id) context, lsn_id, lsn_port_id)
raise
return lsn_port_id return lsn_port_id
def lsn_port_delete(self, context, lsn_id, lsn_port_id): def lsn_port_delete(self, context, lsn_id, lsn_port_id):

View 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 db_base_plugin_v2
from neutron.db import l3_db from neutron.db import l3_db
from neutron.extensions import external_net from neutron.extensions import external_net
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.vmware.common import exceptions as p_exc from neutron.plugins.vmware.common import exceptions as p_exc
from neutron.plugins.vmware.dhcp_meta import constants as d_const 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: try:
handler(context, network_id, subnet_id, host_data) handler(context, network_id, subnet_id, host_data)
except p_exc.PortConfigurationError: except p_exc.PortConfigurationError:
with excutils.save_and_reraise_exception():
if action == 'create_port': if action == 'create_port':
db_base_plugin_v2.NeutronDbPluginV2.delete_port( db_base_plugin_v2.NeutronDbPluginV2.delete_port(
plugin, context, port['id']) plugin, context, port['id'])
raise
LOG.info(_("DHCP for port %s configured successfully"), 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: try:
handler(context, network_id, subnet_id, host_data) handler(context, network_id, subnet_id, host_data)
except p_exc.PortConfigurationError: except p_exc.PortConfigurationError:
with excutils.save_and_reraise_exception():
if not is_delete: if not is_delete:
db_base_plugin_v2.NeutronDbPluginV2.delete_port( db_base_plugin_v2.NeutronDbPluginV2.delete_port(
plugin, context, port['id']) plugin, context, port['id'])
raise
LOG.info(_("Metadata for port %s configured successfully"), 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( plugin.lsn_manager.lsn_metadata_configure(
context, subnet_id, is_enabled) context, subnet_id, is_enabled)
except p_exc.NsxPluginException: except p_exc.NsxPluginException:
with excutils.save_and_reraise_exception():
if is_enabled: if is_enabled:
l3_db.L3_NAT_db_mixin.remove_router_interface( l3_db.L3_NAT_db_mixin.remove_router_interface(
plugin, context, router_id, interface) plugin, context, router_id, interface)
raise
LOG.info(_("Metadata for router %s handled successfully"), router_id) LOG.info(_("Metadata for router %s handled successfully"), router_id)

View File

@ -17,6 +17,7 @@ import json
from neutron.common import constants from neutron.common import constants
from neutron.common import exceptions from neutron.common import exceptions
from neutron.openstack.common import excutils
from neutron.openstack.common import log from neutron.openstack.common import log
from neutron.plugins.vmware.common import utils from neutron.plugins.vmware.common import utils
from neutron.plugins.vmware.nsxlib import _build_uri_path from neutron.plugins.vmware.nsxlib import _build_uri_path
@ -139,7 +140,7 @@ def delete_security_profile(cluster, spid):
try: try:
do_request(HTTP_DELETE, path, cluster=cluster) do_request(HTTP_DELETE, path, cluster=cluster)
except exceptions.NotFound: except exceptions.NotFound:
with excutils.save_and_reraise_exception():
# This is not necessarily an error condition # This is not necessarily an error condition
LOG.warn(_("Unable to find security profile %s on NSX backend"), LOG.warn(_("Unable to find security profile %s on NSX backend"),
spid) spid)
raise

View File

@ -204,9 +204,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Ensure this method is executed only once # Ensure this method is executed only once
self._is_default_net_gw_in_sync = True self._is_default_net_gw_in_sync = True
except Exception: except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_("Unable to process default l2 gw service:%s"), LOG.exception(_("Unable to process default l2 gw service:%s"),
def_l2_gw_uuid) def_l2_gw_uuid)
raise
def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None): def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
"""Build ip_addresses data structure for logical router port. """Build ip_addresses data structure for logical router port.
@ -1803,10 +1803,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
destination_ip_addresses=internal_ip) destination_ip_addresses=internal_ip)
except api_exc.NsxApiException: except api_exc.NsxApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_("An error occurred while removing NAT rules " LOG.exception(_("An error occurred while removing NAT rules "
"on the NSX platform for floating ip:%s"), "on the NSX platform for floating ip:%s"),
floating_ip_address) floating_ip_address)
raise
except nsx_exc.NatRuleMismatch: except nsx_exc.NatRuleMismatch:
# Do not surface to the user # Do not surface to the user
LOG.warning(_("An incorrect number of matching NAT rules " LOG.warning(_("An incorrect number of matching NAT rules "
@ -2285,13 +2285,13 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"resource was not found"), "resource was not found"),
{'neutron_id': device_id, 'nsx_id': nsx_device_id}) {'neutron_id': device_id, 'nsx_id': nsx_device_id})
except api_exc.NsxApiException: except api_exc.NsxApiException:
with excutils.save_and_reraise_exception():
# In this case a 500 should be returned
LOG.exception(_("Removal of gateway device: %(neutron_id)s " LOG.exception(_("Removal of gateway device: %(neutron_id)s "
"failed on NSX backend (NSX id:%(nsx_id)s). " "failed on NSX backend (NSX id:%(nsx_id)s). "
"Neutron and NSX states have diverged."), "Neutron and NSX states have diverged."),
{'neutron_id': device_id, {'neutron_id': device_id,
'nsx_id': nsx_device_id}) 'nsx_id': nsx_device_id})
# In this case a 500 should be returned
raise
def create_security_group(self, context, security_group, default_sg=False): def create_security_group(self, context, security_group, default_sg=False):
"""Create security group. """Create security group.

View File

@ -1563,15 +1563,15 @@ class NsxAdvancedPlugin(sr_db.ServiceRouter_mixin,
self.vcns_driver.update_ipsec_config( self.vcns_driver.update_ipsec_config(
edge_id, sites, enabled=vpn_service.admin_state_up) edge_id, sites, enabled=vpn_service.admin_state_up)
except exceptions.VcnsBadRequest: except exceptions.VcnsBadRequest:
with excutils.save_and_reraise_exception():
LOG.exception(_("Bad or unsupported Input request!")) LOG.exception(_("Bad or unsupported Input request!"))
raise
except exceptions.VcnsApiException: except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
msg = (_("Failed to update ipsec VPN configuration " msg = (_("Failed to update ipsec VPN configuration "
"with vpnservice: %(vpnservice_id)s on vShield Edge: " "with vpnservice: %(vpnservice_id)s on vShield Edge: "
"%(edge_id)s") % {'vpnservice_id': vpnservice_id, "%(edge_id)s") % {'vpnservice_id': vpnservice_id,
'edge_id': edge_id}) 'edge_id': edge_id})
LOG.exception(msg) LOG.exception(msg)
raise
def create_vpnservice(self, context, vpnservice): def create_vpnservice(self, context, vpnservice):
LOG.debug(_("create_vpnservice() called")) LOG.debug(_("create_vpnservice() called"))

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.vmware.vshield.common import ( from neutron.plugins.vmware.vshield.common import (
exceptions as vcns_exc) exceptions as vcns_exc)
@ -131,9 +132,9 @@ class EdgeIPsecVpnDriver():
try: try:
self.vcns.update_ipsec_config(edge_id, ipsec_config) self.vcns.update_ipsec_config(edge_id, ipsec_config)
except vcns_exc.VcnsApiException: except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_("Failed to update ipsec vpn configuration " LOG.exception(_("Failed to update ipsec vpn configuration "
"with edge_id: %s"), edge_id) "with edge_id: %s"), edge_id)
raise
def delete_ipsec_config(self, edge_id): def delete_ipsec_config(self, edge_id):
try: try:
@ -141,9 +142,9 @@ class EdgeIPsecVpnDriver():
except vcns_exc.ResourceNotFound: except vcns_exc.ResourceNotFound:
LOG.warning(_("IPsec config not found on edge: %s"), edge_id) LOG.warning(_("IPsec config not found on edge: %s"), edge_id)
except vcns_exc.VcnsApiException: except vcns_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_("Failed to delete ipsec vpn configuration " LOG.exception(_("Failed to delete ipsec vpn configuration "
"with edge_id: %s"), edge_id) "with edge_id: %s"), edge_id)
raise
def get_ipsec_config(self, edge_id): def get_ipsec_config(self, edge_id):
return self.vcns.get_ipsec_config(edge_id) return self.vcns.get_ipsec_config(edge_id)