Merge "Fix usage of save_and_reraise_exception"

This commit is contained in:
Jenkins 2014-03-21 08:21:14 +00:00 committed by Gerrit Code Review
commit 219020248f
4 changed files with 7 additions and 5 deletions

View File

@ -331,8 +331,9 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
self.context)
return self.target_ex_net_id
except rpc_common.RemoteError as e:
with excutils.save_and_reraise_exception():
with excutils.save_and_reraise_exception() as ctx:
if e.exc_type == 'TooManyExternalNetworks':
ctx.reraise = False
msg = _(
"The 'gateway_external_network_id' option must be "
"configured for this agent as Neutron has more than "

View File

@ -59,8 +59,7 @@ class DhcpRpcCallbackMixin(object):
raise n_exc.Invalid(message=msg)
except (db_exc.DBError, n_exc.NetworkNotFound,
n_exc.SubnetNotFound, n_exc.IpAddressGenerationFailure) as e:
with excutils.save_and_reraise_exception() as ctxt:
ctxt.reraise = False
with excutils.save_and_reraise_exception(reraise=False) as ctxt:
if isinstance(e, n_exc.IpAddressGenerationFailure):
# Check if the subnet still exists and if it does not,
# this is the reason why the ip address generation failed.

View File

@ -205,7 +205,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
try:
r = self._get_by_id(context, model, id)
except exc.NoResultFound:
with excutils.save_and_reraise_exception():
with excutils.save_and_reraise_exception(reraise=False) as ctx:
if issubclass(model, Vip):
raise loadbalancer.VipNotFound(vip_id=id)
elif issubclass(model, Pool):
@ -214,6 +214,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
raise loadbalancer.MemberNotFound(member_id=id)
elif issubclass(model, HealthMonitor):
raise loadbalancer.HealthMonitorNotFound(monitor_id=id)
ctx.reraise = True
return r
def assert_modification_allowed(self, obj):

View File

@ -179,7 +179,7 @@ class VPNPluginDb(VPNPluginBase, base_db.CommonDbMixin):
try:
r = self._get_by_id(context, model, v_id)
except exc.NoResultFound:
with excutils.save_and_reraise_exception():
with excutils.save_and_reraise_exception(reraise=False) as ctx:
if issubclass(model, IPsecSiteConnection):
raise vpnaas.IPsecSiteConnectionNotFound(
ipsec_site_conn_id=v_id
@ -190,6 +190,7 @@ class VPNPluginDb(VPNPluginBase, base_db.CommonDbMixin):
raise vpnaas.IPsecPolicyNotFound(ipsecpolicy_id=v_id)
elif issubclass(model, VPNService):
raise vpnaas.VPNServiceNotFound(vpnservice_id=v_id)
ctx.reraise = True
return r
def assert_update_allowed(self, obj):