Merge "Remove multi scheduler."

This commit is contained in:
Jenkins
2013-04-11 19:59:07 +00:00
committed by Gerrit Code Review
2 changed files with 0 additions and 155 deletions

View File

@@ -1,78 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2010 OpenStack Foundation
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Scheduler that allows routing some calls to one driver and others to another.
This scheduler was originally used to deal with both compute and volume. But
is now used for openstack extensions that want to use the nova-scheduler to
schedule requests to compute nodes but provide their own manager and topic.
https://bugs.launchpad.net/nova/+bug/1009681
"""
from oslo.config import cfg
from nova.openstack.common import importutils
from nova.scheduler import driver
multi_scheduler_opts = [
cfg.StrOpt('compute_scheduler_driver',
default='nova.scheduler.'
'filter_scheduler.FilterScheduler',
help='Driver to use for scheduling compute calls'),
cfg.StrOpt('default_scheduler_driver',
default='nova.scheduler.chance.ChanceScheduler',
help='Default driver to use for scheduling calls'),
]
CONF = cfg.CONF
CONF.register_opts(multi_scheduler_opts)
class MultiScheduler(driver.Scheduler):
"""A scheduler that holds multiple sub-schedulers.
This exists to allow flag-driven composibility of schedulers, allowing
third parties to integrate custom schedulers more easily.
"""
def __init__(self):
super(MultiScheduler, self).__init__()
compute_driver = importutils.import_object(
CONF.compute_scheduler_driver)
default_driver = importutils.import_object(
CONF.default_scheduler_driver)
self.drivers = {'compute': compute_driver,
'default': default_driver}
def schedule_run_instance(self, *args, **kwargs):
return self.drivers['compute'].schedule_run_instance(*args, **kwargs)
def schedule_prep_resize(self, *args, **kwargs):
return self.drivers['compute'].schedule_prep_resize(*args, **kwargs)
def update_service_capabilities(self, service_name, host, capabilities):
# Multi scheduler is only a holder of sub-schedulers, so
# pass the capabilities to the schedulers that matter
for d in self.drivers.values():
d.update_service_capabilities(service_name, host, capabilities)

View File

@@ -1,77 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Tests For Multi Scheduler
"""
from nova.scheduler import driver
from nova.scheduler import multi
from nova.tests.scheduler import test_scheduler
class FakeComputeScheduler(driver.Scheduler):
is_fake_compute = True
def __init__(self):
super(FakeComputeScheduler, self).__init__()
self.is_update_caps_called = False
def schedule_theoretical(self, *args, **kwargs):
pass
class FakeDefaultScheduler(driver.Scheduler):
is_fake_default = True
def __init__(self):
super(FakeDefaultScheduler, self).__init__()
self.is_update_caps_called = False
class MultiDriverTestCase(test_scheduler.SchedulerTestCase):
"""Test case for multi driver."""
driver_cls = multi.MultiScheduler
def setUp(self):
super(MultiDriverTestCase, self).setUp()
base_name = 'nova.tests.scheduler.test_multi_scheduler.%s'
compute_cls_name = base_name % 'FakeComputeScheduler'
default_cls_name = base_name % 'FakeDefaultScheduler'
self.flags(compute_scheduler_driver=compute_cls_name,
default_scheduler_driver=default_cls_name)
self._manager = multi.MultiScheduler()
def test_drivers_inited(self):
mgr = self._manager
self.assertEqual(len(mgr.drivers), 2)
self.assertTrue(mgr.drivers['compute'].is_fake_compute)
self.assertTrue(mgr.drivers['default'].is_fake_default)
def test_update_service_capabilities(self):
def fake_update_service_capabilities(self, service, host, caps):
self.is_update_caps_called = True
mgr = self._manager
self.stubs.Set(driver.Scheduler,
'update_service_capabilities',
fake_update_service_capabilities)
self.assertFalse(mgr.drivers['compute'].is_update_caps_called)
mgr.update_service_capabilities('foo_svc', 'foo_host', 'foo_caps')
self.assertTrue(mgr.drivers['compute'].is_update_caps_called)