]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Handle nvp default l3 gw service misconfiguration appropriately
authorSalvatore Orlando <salv.orlando@gmail.com>
Fri, 9 Aug 2013 00:04:05 +0000 (17:04 -0700)
committerSalvatore Orlando <salv.orlando@gmail.com>
Fri, 9 Aug 2013 00:04:05 +0000 (17:04 -0700)
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

index c8f84e031c7a3375428ffe44e68e19a19e5d6a7c..5c833e5e400a3fb916637191283e4d779a8179c9 100644 (file)
@@ -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'],