From fe3d6dba3d1db8f97dab4baffcc11dda56368096 Mon Sep 17 00:00:00 2001 From: EdLeafe Date: Fri, 8 Jul 2016 18:07:44 +0000 Subject: [PATCH] Remove support for deprecated driver import Support for specifying the scheduler driver via a full classpath was deprecated in Mitaka, and with this patch is removed in Ocata. Change-Id: I72e392aafa886ba19c874f1e0a0c95f6d1757ab9 --- nova/scheduler/manager.py | 28 +++---------------- .../notification_sample_base.py | 2 +- nova/tests/unit/scheduler/test_scheduler.py | 17 ----------- ...ove_classpath_import-5d0f48eb388e6948.yaml | 6 ++++ 4 files changed, 11 insertions(+), 42 deletions(-) create mode 100644 releasenotes/notes/sched_remove_classpath_import-5d0f48eb388e6948.yaml diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 3c34034976db..f6602396925b 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -23,12 +23,10 @@ from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils from oslo_service import periodic_task -from oslo_utils import importutils from stevedore import driver import nova.conf from nova import exception -from nova.i18n import _, _LW from nova import manager from nova import objects from nova import quota @@ -51,28 +49,10 @@ class SchedulerManager(manager.Manager): def __init__(self, scheduler_driver=None, *args, **kwargs): if not scheduler_driver: scheduler_driver = CONF.scheduler_driver - try: - self.driver = driver.DriverManager( - "nova.scheduler.driver", - scheduler_driver, - invoke_on_load=True).driver - # TODO(Yingxin): Change to catch stevedore.exceptions.NoMatches after - # stevedore v1.9.0 - except RuntimeError: - # NOTE(Yingxin): Loading full class path is deprecated and should - # be removed in the N release. - try: - self.driver = importutils.import_object(scheduler_driver) - LOG.warning(_LW("DEPRECATED: scheduler_driver uses " - "classloader to load %(path)s. This legacy " - "loading style will be removed in the " - "N release."), - {'path': scheduler_driver}) - except (ImportError, ValueError): - raise RuntimeError( - _("Cannot load scheduler driver from configuration " - "%(conf)s."), - {'conf': scheduler_driver}) + self.driver = driver.DriverManager( + "nova.scheduler.driver", + scheduler_driver, + invoke_on_load=True).driver super(SchedulerManager, self).__init__(service_name='scheduler', *args, **kwargs) diff --git a/nova/tests/functional/notification_sample_tests/notification_sample_base.py b/nova/tests/functional/notification_sample_tests/notification_sample_base.py index 8415f4c5c5b4..b13886a4cae0 100644 --- a/nova/tests/functional/notification_sample_tests/notification_sample_base.py +++ b/nova/tests/functional/notification_sample_tests/notification_sample_base.py @@ -69,7 +69,7 @@ class NotificationSampleTestBase(test.TestCase, self.useFixture(utils_fixture.TimeFixture(test_services.fake_utcnow())) - self.flags(scheduler_driver='nova.scheduler.chance.ChanceScheduler') + self.flags(scheduler_driver='chance_scheduler') # the image fake backend needed for image discovery nova.tests.unit.image.fake.stub_out_image_service(self) self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset) diff --git a/nova/tests/unit/scheduler/test_scheduler.py b/nova/tests/unit/scheduler/test_scheduler.py index ecf51e47f753..d462dcda1a5d 100644 --- a/nova/tests/unit/scheduler/test_scheduler.py +++ b/nova/tests/unit/scheduler/test_scheduler.py @@ -71,23 +71,6 @@ class SchedulerManagerInitTestCase(test.NoDBTestCase): self.flags(scheduler_driver='nonexist_scheduler') self.assertRaises(RuntimeError, self.manager_cls) - # NOTE(Yingxin): Loading full class path is deprecated and should be - # removed in the N release. - @mock.patch.object(manager.LOG, 'warning') - @mock.patch.object(host_manager.HostManager, '_init_instance_info') - @mock.patch.object(host_manager.HostManager, '_init_aggregates') - def test_init_using_classpath_to_schedulerdriver(self, - mock_init_agg, - mock_init_inst, - mock_warning): - self.flags( - scheduler_driver= - 'nova.scheduler.chance.ChanceScheduler') - driver = self.manager_cls().driver - self.assertIsInstance(driver, chance.ChanceScheduler) - warn_args, kwargs = mock_warning.call_args - self.assertIn("DEPRECATED", warn_args[0]) - class SchedulerManagerTestCase(test.NoDBTestCase): """Test case for scheduler manager.""" diff --git a/releasenotes/notes/sched_remove_classpath_import-5d0f48eb388e6948.yaml b/releasenotes/notes/sched_remove_classpath_import-5d0f48eb388e6948.yaml new file mode 100644 index 000000000000..ae019952381c --- /dev/null +++ b/releasenotes/notes/sched_remove_classpath_import-5d0f48eb388e6948.yaml @@ -0,0 +1,6 @@ +--- +upgrades: + - The ability to specify the scheduler driver via a full class path was + deprecated in Mitaka, and has now been removed. Drivers must now be listed + as one of the entrypoints under the namespace 'nova.scheduler.driver' of + the 'setup.cfg' file.