From adf3b8d3b1796337aac7cd5ff7683782eb715f96 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Thu, 8 Aug 2013 17:04:05 -0700 Subject: [PATCH] Handle nvp default l3 gw service misconfiguration appropriately Bug 1185885 Avoid returning an unrelated, backend-specific, error message to the user, and ensure the logical router is removed from the NVP backend. Change-Id: I5f7b88480dab80a2138486e612e144b971691cf5 --- neutron/plugins/nicira/NeutronPlugin.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/nicira/NeutronPlugin.py b/neutron/plugins/nicira/NeutronPlugin.py index c8f84e031..5c833e5e4 100644 --- a/neutron/plugins/nicira/NeutronPlugin.py +++ b/neutron/plugins/nicira/NeutronPlugin.py @@ -1539,9 +1539,23 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2, raise nvp_exc.NvpPluginException( err_msg=_("Unable to create logical router on NVP Platform")) # Create the port here - and update it later if we have gw_info - self._create_and_attach_router_port( - self.cluster, context, lrouter['uuid'], {'fake_ext_gw': True}, - "L3GatewayAttachment", self.cluster.default_l3_gw_service_uuid) + try: + self._create_and_attach_router_port( + self.cluster, context, lrouter['uuid'], {'fake_ext_gw': True}, + "L3GatewayAttachment", + self.cluster.default_l3_gw_service_uuid) + except nvp_exc.NvpPluginException: + LOG.exception(_("Unable to create L3GW port on logical router " + "%(router_uuid)s. Verify Default Layer-3 Gateway " + "service %(def_l3_gw_svc)s id is correct") % + {'router_uuid': lrouter['uuid'], + 'def_l3_gw_svc': + self.cluster.default_l3_gw_service_uuid}) + # Try and remove logical router from NVP + nvplib.delete_lrouter(self.cluster, lrouter['uuid']) + # Return user a 500 with an apter message + raise nvp_exc.NvpPluginException( + err_msg=_("Unable to create router %s") % r['name']) with context.session.begin(subtransactions=True): router_db = l3_db.Router(id=lrouter['uuid'], -- 2.45.2