From e004e1ad9da5df6e7ce0daac1c2de7e5a94db1ee Mon Sep 17 00:00:00 2001 From: Sergey Belous Date: Fri, 24 Jul 2015 13:41:35 +0300 Subject: [PATCH] Add error message when migrate from distributed router to centralized When trying to migrate from distributed router to centralized a NotImplementedError occurs with empty message. Need to concretize a message. Closes-Bug: #1477509 Change-Id: I2b57ec5af38a0f87c1ab256cb8af66bc443be824 --- neutron/common/exceptions.py | 4 ++++ neutron/db/l3_dvr_db.py | 3 ++- neutron/tests/unit/db/test_l3_dvr_db.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/neutron/common/exceptions.py b/neutron/common/exceptions.py index c6ec6ccca54..373c69979b6 100644 --- a/neutron/common/exceptions.py +++ b/neutron/common/exceptions.py @@ -69,6 +69,10 @@ 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 f4aa8a13ea6..47fbbc63f2e 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -87,7 +87,8 @@ 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 NotImplementedError() + raise n_exc.NotSupported(msg=_("Migration from distributed router " + "to centralized")) elif (not router_db.extra_attributes.distributed and router_res.get('distributed')): # Notify advanced services of the imminent state transition diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index c5fbb45e8d7..419e168fb7a 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -85,7 +85,7 @@ class L3DvrTestCase(testlib_api.SqlTestCase): 'distributed': True } router_db = self._create_router(router) - self.assertRaises(NotImplementedError, + self.assertRaises(exceptions.NotSupported, self.mixin._validate_router_migration, self.ctx, router_db, {'distributed': False})