diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index 6fa97ea8cd..aa3f3d1f46 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -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 " diff --git a/neutron/db/dhcp_rpc_base.py b/neutron/db/dhcp_rpc_base.py index 953512d838..106ad5ed7a 100644 --- a/neutron/db/dhcp_rpc_base.py +++ b/neutron/db/dhcp_rpc_base.py @@ -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. diff --git a/neutron/db/loadbalancer/loadbalancer_db.py b/neutron/db/loadbalancer/loadbalancer_db.py index cbff0ed0db..4ed96de685 100644 --- a/neutron/db/loadbalancer/loadbalancer_db.py +++ b/neutron/db/loadbalancer/loadbalancer_db.py @@ -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): diff --git a/neutron/db/vpn/vpn_db.py b/neutron/db/vpn/vpn_db.py index c750d8c4b7..056d956f39 100644 --- a/neutron/db/vpn/vpn_db.py +++ b/neutron/db/vpn/vpn_db.py @@ -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):