Fix usage of save_and_reraise_exception
Set reraise=False for the cases where the purpose of exception handler is to reraise proper type of exception Change-Id: Id6595ba1e160b9033d519ded16e0fbd2f91ccb5d Closes-Bug: #1288188
This commit is contained in:
parent
1532e5a609
commit
a9ccd21215
@ -331,8 +331,9 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
|||||||
self.context)
|
self.context)
|
||||||
return self.target_ex_net_id
|
return self.target_ex_net_id
|
||||||
except rpc_common.RemoteError as e:
|
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':
|
if e.exc_type == 'TooManyExternalNetworks':
|
||||||
|
ctx.reraise = False
|
||||||
msg = _(
|
msg = _(
|
||||||
"The 'gateway_external_network_id' option must be "
|
"The 'gateway_external_network_id' option must be "
|
||||||
"configured for this agent as Neutron has more than "
|
"configured for this agent as Neutron has more than "
|
||||||
|
@ -59,8 +59,7 @@ class DhcpRpcCallbackMixin(object):
|
|||||||
raise n_exc.Invalid(message=msg)
|
raise n_exc.Invalid(message=msg)
|
||||||
except (db_exc.DBError, n_exc.NetworkNotFound,
|
except (db_exc.DBError, n_exc.NetworkNotFound,
|
||||||
n_exc.SubnetNotFound, n_exc.IpAddressGenerationFailure) as e:
|
n_exc.SubnetNotFound, n_exc.IpAddressGenerationFailure) as e:
|
||||||
with excutils.save_and_reraise_exception() as ctxt:
|
with excutils.save_and_reraise_exception(reraise=False) as ctxt:
|
||||||
ctxt.reraise = False
|
|
||||||
if isinstance(e, n_exc.IpAddressGenerationFailure):
|
if isinstance(e, n_exc.IpAddressGenerationFailure):
|
||||||
# Check if the subnet still exists and if it does not,
|
# Check if the subnet still exists and if it does not,
|
||||||
# this is the reason why the ip address generation failed.
|
# this is the reason why the ip address generation failed.
|
||||||
|
@ -205,7 +205,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
|
|||||||
try:
|
try:
|
||||||
r = self._get_by_id(context, model, id)
|
r = self._get_by_id(context, model, id)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception(reraise=False) as ctx:
|
||||||
if issubclass(model, Vip):
|
if issubclass(model, Vip):
|
||||||
raise loadbalancer.VipNotFound(vip_id=id)
|
raise loadbalancer.VipNotFound(vip_id=id)
|
||||||
elif issubclass(model, Pool):
|
elif issubclass(model, Pool):
|
||||||
@ -214,6 +214,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
|
|||||||
raise loadbalancer.MemberNotFound(member_id=id)
|
raise loadbalancer.MemberNotFound(member_id=id)
|
||||||
elif issubclass(model, HealthMonitor):
|
elif issubclass(model, HealthMonitor):
|
||||||
raise loadbalancer.HealthMonitorNotFound(monitor_id=id)
|
raise loadbalancer.HealthMonitorNotFound(monitor_id=id)
|
||||||
|
ctx.reraise = True
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def assert_modification_allowed(self, obj):
|
def assert_modification_allowed(self, obj):
|
||||||
|
@ -179,7 +179,7 @@ class VPNPluginDb(VPNPluginBase, base_db.CommonDbMixin):
|
|||||||
try:
|
try:
|
||||||
r = self._get_by_id(context, model, v_id)
|
r = self._get_by_id(context, model, v_id)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception(reraise=False) as ctx:
|
||||||
if issubclass(model, IPsecSiteConnection):
|
if issubclass(model, IPsecSiteConnection):
|
||||||
raise vpnaas.IPsecSiteConnectionNotFound(
|
raise vpnaas.IPsecSiteConnectionNotFound(
|
||||||
ipsec_site_conn_id=v_id
|
ipsec_site_conn_id=v_id
|
||||||
@ -190,6 +190,7 @@ class VPNPluginDb(VPNPluginBase, base_db.CommonDbMixin):
|
|||||||
raise vpnaas.IPsecPolicyNotFound(ipsecpolicy_id=v_id)
|
raise vpnaas.IPsecPolicyNotFound(ipsecpolicy_id=v_id)
|
||||||
elif issubclass(model, VPNService):
|
elif issubclass(model, VPNService):
|
||||||
raise vpnaas.VPNServiceNotFound(vpnservice_id=v_id)
|
raise vpnaas.VPNServiceNotFound(vpnservice_id=v_id)
|
||||||
|
ctx.reraise = True
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def assert_update_allowed(self, obj):
|
def assert_update_allowed(self, obj):
|
||||||
|
Loading…
Reference in New Issue
Block a user