From a6d9580f2b95bf2c7c607d4e2671ffbbceae28d5 Mon Sep 17 00:00:00 2001 From: Assaf Muller Date: Mon, 12 Oct 2015 14:42:43 -0400 Subject: [PATCH] Fix DVR downgrade exception / error code 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 | 4 ---- neutron/db/l3_dvr_db.py | 6 ++++-- neutron/tests/unit/db/test_l3_dvr_db.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/neutron/common/exceptions.py b/neutron/common/exceptions.py index 66aae8721..94e52466f 100644 --- a/neutron/common/exceptions.py +++ b/neutron/common/exceptions.py @@ -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") diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index ce6263e2e..a65b82df4 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -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 diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index 3e27f9b20..444110369 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -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}) -- 2.45.2