Merge "Use save_and_reraise_exception when reraise exception"

This commit is contained in:
Jenkins 2014-03-22 02:03:49 +00:00 committed by Gerrit Code Review
commit 7d900bec0e
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:
LOG.error(_("Connect failed to switch: %s"), e) with excutils.save_and_reraise_exception():
raise LOG.error(_("Connect failed to switch: %s"), e)
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:
LOG.exception(_("Connect failed to switch")) with excutils.save_and_reraise_exception():
raise LOG.exception(_("Connect failed to switch"))
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:
if isinstance(e.inner_exception, sql_exc.IntegrityError): with excutils.save_and_reraise_exception() as ctxt:
msg = _("A concurrent port creation has occurred") if isinstance(e.inner_exception, sql_exc.IntegrityError):
LOG.warning(msg) ctxt.reraise = False
continue msg = _("A concurrent port creation has occurred")
else: LOG.warning(msg)
raise continue
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:
LOG.exception(_("Exception auto-deleting port %s"), with excutils.save_and_reraise_exception():
port.id) LOG.exception(_("Exception auto-deleting port %s"),
raise port.id)
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:
LOG.exception(_("Exception auto-deleting subnet %s"), with excutils.save_and_reraise_exception():
subnet.id) LOG.exception(_("Exception auto-deleting subnet %s"),
raise subnet.id)
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:
LOG.exception(_("Exception auto-deleting port %s"), with excutils.save_and_reraise_exception():
a.port_id) LOG.exception(_("Exception auto-deleting port %s"),
raise a.port_id)
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,16 +130,17 @@ 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:
try: with excutils.save_and_reraise_exception() as ctxt:
wait_time = int(e.retry_after) try:
except (ValueError, TypeError): wait_time = int(e.retry_after)
wait_time = None except (ValueError, TypeError):
if i > 1 and wait_time: wait_time = None
LOG.info(_("Waiting for %s seconds due to " if i > 1 and wait_time:
"OFC Service_Unavailable."), wait_time) LOG.info(_("Waiting for %s seconds due to "
time.sleep(wait_time) "OFC Service_Unavailable."), wait_time)
continue time.sleep(wait_time)
raise ctxt.reraise = False
continue
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:
reason = _("delete_network() failed due to %s") % exc with excutils.save_and_reraise_exception():
LOG.error(reason) reason = _("delete_network() failed due to %s") % exc
self._update_resource_status(context, "network", net_db['id'], LOG.error(reason)
const.NET_STATUS_ERROR) self._update_resource_status(context, "network", net_db['id'],
raise const.NET_STATUS_ERROR)
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:
self._client_delete_network(net['id']) with excutils.save_and_reraise_exception():
raise self._client_delete_network(net['id'])
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:
session.rollback() with excutils.save_and_reraise_exception() as ctxt:
# do not complain if the same exact mapping is being added, otherwise session.rollback()
# re-raise because even though it is possible for the same neutron # do not complain if the same exact mapping is being added,
# port to map to different back-end ports over time, this should not # otherwise re-raise because even though it is possible for the
# occur whilst a mapping already exists # same neutron port to map to different back-end ports over time,
current = get_nsx_switch_and_port_id(session, neutron_id) # this should not occur whilst a mapping already exists
if current[1] == nsx_port_id: current = get_nsx_switch_and_port_id(session, neutron_id)
LOG.debug(_("Port mapping for %s already available"), neutron_id) if current[1] == nsx_port_id:
else: LOG.debug(_("Port mapping for %s already available"),
raise neutron_id)
ctxt.reraise = False
except db_exc.DBError: except db_exc.DBError:
# rollback for any other db error with excutils.save_and_reraise_exception():
session.rollback() # rollback for any other db error
raise session.rollback()
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:
if self.sync_on_missing: with excutils.save_and_reraise_exception() as ctxt:
lsn_id = super(PersistentLsnManager, self).lsn_get( ctxt.reraise = False
context, network_id, raise_on_err=raise_on_err) if self.sync_on_missing:
self.lsn_save(context, network_id, lsn_id) lsn_id = super(PersistentLsnManager, self).lsn_get(
return lsn_id context, network_id, raise_on_err=raise_on_err)
if raise_on_err: self.lsn_save(context, network_id, lsn_id)
raise return lsn_id
if raise_on_err:
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:
super(PersistentLsnManager, self).lsn_delete(context, lsn_id) with excutils.save_and_reraise_exception():
raise super(PersistentLsnManager, self).lsn_delete(context, lsn_id)
return lsn_id return lsn_id
def lsn_delete(self, context, 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) 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:
if self.sync_on_missing: with excutils.save_and_reraise_exception() as ctxt:
lsn_id, lsn_port_id = ( ctxt.reraise = False
super(PersistentLsnManager, self).lsn_port_get( if self.sync_on_missing:
context, network_id, subnet_id, lsn_id, lsn_port_id = (
raise_on_err=raise_on_err)) super(PersistentLsnManager, self).lsn_port_get(
mac_addr = lsn_api.lsn_port_info_get( context, network_id, subnet_id,
self.cluster, lsn_id, lsn_port_id)['mac_address'] raise_on_err=raise_on_err))
self.lsn_port_save( mac_addr = lsn_api.lsn_port_info_get(
context, lsn_port_id, subnet_id, mac_addr, lsn_id) self.cluster, lsn_id, lsn_port_id)['mac_address']
return (lsn_id, lsn_port_id) self.lsn_port_save(
if raise_on_err: context, lsn_port_id, subnet_id, mac_addr, lsn_id)
raise 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): def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
try: try:
@ -410,18 +415,20 @@ 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:
if self.sync_on_missing: with excutils.save_and_reraise_exception() as ctxt:
lsn_id, lsn_port_id = ( ctxt.reraise = False
super(PersistentLsnManager, self).lsn_port_get_by_mac( if self.sync_on_missing:
context, network_id, mac, lsn_id, lsn_port_id = (
raise_on_err=raise_on_err)) super(PersistentLsnManager, self).lsn_port_get_by_mac(
subnet_id = lsn_api.lsn_port_info_get( context, network_id, mac,
self.cluster, lsn_id, lsn_port_id).get('subnet_id') raise_on_err=raise_on_err))
self.lsn_port_save( subnet_id = lsn_api.lsn_port_info_get(
context, lsn_port_id, subnet_id, mac, lsn_id) self.cluster, lsn_id, lsn_port_id).get('subnet_id')
return (lsn_id, lsn_port_id) self.lsn_port_save(
if raise_on_err: context, lsn_port_id, subnet_id, mac, lsn_id)
raise 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): 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:
super(PersistentLsnManager, self).lsn_port_delete( with excutils.save_and_reraise_exception():
context, lsn_id, lsn_port_id) super(PersistentLsnManager, self).lsn_port_delete(
raise context, lsn_id, lsn_port_id)
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:
if action == 'create_port': with excutils.save_and_reraise_exception():
db_base_plugin_v2.NeutronDbPluginV2.delete_port( if action == 'create_port':
plugin, context, port['id']) db_base_plugin_v2.NeutronDbPluginV2.delete_port(
raise plugin, context, port['id'])
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:
if not is_delete: with excutils.save_and_reraise_exception():
db_base_plugin_v2.NeutronDbPluginV2.delete_port( if not is_delete:
plugin, context, port['id']) db_base_plugin_v2.NeutronDbPluginV2.delete_port(
raise plugin, context, port['id'])
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:
if is_enabled: with excutils.save_and_reraise_exception():
l3_db.L3_NAT_db_mixin.remove_router_interface( if is_enabled:
plugin, context, router_id, interface) l3_db.L3_NAT_db_mixin.remove_router_interface(
raise plugin, context, router_id, interface)
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:
# This is not necessarily an error condition with excutils.save_and_reraise_exception():
LOG.warn(_("Unable to find security profile %s on NSX backend"), # This is not necessarily an error condition
spid) LOG.warn(_("Unable to find security profile %s on NSX backend"),
raise spid)

View File

@ -205,9 +205,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:
LOG.exception(_("Unable to process default l2 gw service:%s"), with excutils.save_and_reraise_exception():
def_l2_gw_uuid) LOG.exception(_("Unable to process default l2 gw service:%s"),
raise def_l2_gw_uuid)
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.
@ -1804,10 +1804,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:
LOG.exception(_("An error occurred while removing NAT rules " with excutils.save_and_reraise_exception():
"on the NSX platform for floating ip:%s"), LOG.exception(_("An error occurred while removing NAT rules "
floating_ip_address) "on the NSX platform for floating ip:%s"),
raise floating_ip_address)
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 "
@ -2286,13 +2286,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:
LOG.exception(_("Removal of gateway device: %(neutron_id)s " with excutils.save_and_reraise_exception():
"failed on NSX backend (NSX id:%(nsx_id)s). " # In this case a 500 should be returned
"Neutron and NSX states have diverged."), LOG.exception(_("Removal of gateway device: %(neutron_id)s "
{'neutron_id': device_id, "failed on NSX backend (NSX id:%(nsx_id)s). "
'nsx_id': nsx_device_id}) "Neutron and NSX states have diverged."),
# In this case a 500 should be returned {'neutron_id': device_id,
raise 'nsx_id': nsx_device_id})
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:
LOG.exception(_("Bad or unsupported Input request!")) with excutils.save_and_reraise_exception():
raise LOG.exception(_("Bad or unsupported Input request!"))
except exceptions.VcnsApiException: except exceptions.VcnsApiException:
msg = (_("Failed to update ipsec VPN configuration " with excutils.save_and_reraise_exception():
"with vpnservice: %(vpnservice_id)s on vShield Edge: " msg = (_("Failed to update ipsec VPN configuration "
"%(edge_id)s") % {'vpnservice_id': vpnservice_id, "with vpnservice: %(vpnservice_id)s on vShield Edge: "
'edge_id': edge_id}) "%(edge_id)s") % {'vpnservice_id': vpnservice_id,
LOG.exception(msg) 'edge_id': edge_id})
raise LOG.exception(msg)
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:
LOG.exception(_("Failed to update ipsec vpn configuration " with excutils.save_and_reraise_exception():
"with edge_id: %s"), edge_id) LOG.exception(_("Failed to update ipsec vpn configuration "
raise "with edge_id: %s"), edge_id)
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:
LOG.exception(_("Failed to delete ipsec vpn configuration " with excutils.save_and_reraise_exception():
"with edge_id: %s"), edge_id) LOG.exception(_("Failed to delete ipsec vpn configuration "
raise "with edge_id: %s"), edge_id)
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)