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
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 "
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.
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):
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):
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
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):