]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix DVR downgrade exception / error code
authorAssaf Muller <amuller@redhat.com>
Mon, 12 Oct 2015 18:42:43 +0000 (14:42 -0400)
committerGal Sagie <gal.sagie@huawei.com>
Sat, 17 Oct 2015 18:30:16 +0000 (18:30 +0000)
Updating a distributed router back to a legacy router
should return error 400 (BadRequest), not error 500.

Closes-Bug: #1505346
Change-Id: Ia57e80107bd11ff7b38b89d30279603017913724

neutron/common/exceptions.py
neutron/db/l3_dvr_db.py
neutron/tests/unit/db/test_l3_dvr_db.py

index 66aae8721d5fe86ebac111966456344cdd829da4..94e52466fd036cde69296aeb92eda425e2a877b6 100644 (file)
@@ -72,10 +72,6 @@ class ServiceUnavailable(NeutronException):
     message = _("The service is unavailable")
 
 
-class NotSupported(NeutronException):
-    message = _('Not supported: %(msg)s')
-
-
 class AdminRequired(NotAuthorized):
     message = _("User does not have admin privileges: %(reason)s")
 
index ce6263e2e4bfafe134d75dd917417ff3cb3c71b3..a65b82df4cbe061fad0f30d3402ecb2595a6754f 100644 (file)
@@ -80,8 +80,10 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
             router_res.get('distributed') is False):
             LOG.info(_LI("Centralizing distributed router %s "
                          "is not supported"), router_db['id'])
-            raise n_exc.NotSupported(msg=_("Migration from distributed router "
-                                           "to centralized"))
+            raise n_exc.BadRequest(
+                resource='router',
+                msg=_("Migration from distributed router to centralized is "
+                      "not supported"))
         elif (not router_db.extra_attributes.distributed and
               router_res.get('distributed')):
             # router should be disabled in order for upgrade
index 3e27f9b205fca6996d1c4bb679539dcb6eb68006..444110369626501a956f7b89e95dd574b946e293 100644 (file)
@@ -96,7 +96,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
             'distributed': True
         }
         router_db = self._create_router(router)
-        self.assertRaises(exceptions.NotSupported,
+        self.assertRaises(exceptions.BadRequest,
                           self.mixin._validate_router_migration,
                           self.ctx, router_db, {'distributed': False})