CONF = cfg.CONF
CONF.register_opts(host_manager_opts)
+CONF.import_opt('scheduler_driver', 'cinder.scheduler.manager')
LOG = logging.getLogger(__name__)
'weights')
self.weight_classes = self.weight_handler.get_all_classes()
+ default_filters = ['AvailabilityZoneFilter',
+ 'CapacityFilter',
+ 'CapabilitiesFilter']
+ chance = 'cinder.scheduler.chance.ChanceScheduler'
+ simple = 'cinder.scheduler.simple.SimpleScheduler'
+ if CONF.scheduler_driver == simple:
+ CONF.set_override('scheduler_default_filters', default_filters)
+ CONF.set_override('scheduler_default_weighers',
+ ['AllocatedCapacityWeigher'])
+ elif CONF.scheduler_driver == chance:
+ CONF.set_override('scheduler_default_filters', default_filters)
+ CONF.set_override('scheduler_default_weighers',
+ ['ChanceWeigher'])
+ else:
+ # Do nothing when some other scheduler is configured
+ pass
+
def _choose_host_filters(self, filter_cls_names):
"""Since the caller may specify which filters to use we need
to have an authoritative list of what is permissible. This
*args, **kwargs):
if not scheduler_driver:
scheduler_driver = CONF.scheduler_driver
+ if scheduler_driver in ['cinder.scheduler.chance.ChanceScheduler',
+ 'cinder.scheduler.simple.SimpleScheduler']:
+ scheduler_driver = ('cinder.scheduler.filter_scheduler.'
+ 'FilterScheduler')
+ LOG.deprecated(_('ChanceScheduler and SimpleScheduler have been '
+ 'deprecated due to lack of support for advanced '
+ 'features like: volume types, volume encryption,'
+ ' QoS etc. These two schedulers can be fully '
+ 'replaced by FilterScheduler with certain '
+ 'combination of filters and weighers.'))
self.driver = importutils.import_object(scheduler_driver)
super(SchedulerManager, self).__init__(*args, **kwargs)
CONF.import_opt('xiv_ds8k_proxy', 'cinder.volume.drivers.xiv_ds8k')
CONF.import_opt('backup_driver', 'cinder.backup.manager')
CONF.import_opt('fixed_key', 'cinder.keymgr.conf_key_mgr', group='keymgr')
+CONF.import_opt('scheduler_driver', 'cinder.scheduler.manager')
def_vol_type = 'fake_vol_type'
'cinder.tests.test_xiv_ds8k.XIVDS8KFakeProxyDriver')
conf.set_default('backup_driver', 'cinder.tests.backup.fake_service')
conf.set_default('fixed_key', default='0' * 64, group='keymgr')
+ conf.set_default('scheduler_driver',
+ 'cinder.scheduler.filter_scheduler.FilterScheduler')
"""
import mock
+from oslo.config import cfg
from cinder import context
from cinder import exception
from cinder.scheduler import driver
+from cinder.scheduler import filter_scheduler
from cinder.scheduler import manager
from cinder import test
+CONF = cfg.CONF
+
+
class SchedulerManagerTestCase(test.TestCase):
"""Test case for scheduler manager."""
_mock_host_passes.assert_called_once_with(self.context, 'host',
request_spec, {})
+ def test_chance_simple_scheduler_mocked(self):
+ # Test FilterScheduler is loaded and predefined combination
+ # of filters and weighers overrides the default value of config option
+ # scheduler_default_filters and scheduler_default_weighers when
+ # ChanceScheduler or SimpleScheduler is configured as scheduler_driver.
+ chance = 'cinder.scheduler.chance.ChanceScheduler'
+ simple = 'cinder.scheduler.simple.SimpleScheduler'
+ default_filters = ['AvailabilityZoneFilter',
+ 'CapacityFilter',
+ 'CapabilitiesFilter']
+ self.flags(scheduler_driver=chance,
+ scheduler_default_filters=['CapacityFilter'],
+ scheduler_default_weighers=['CapacityWeigher'])
+ self.manager = self.manager_cls()
+ self.assertTrue(isinstance(self.manager.driver,
+ filter_scheduler.FilterScheduler))
+ self.assertEqual(CONF.scheduler_default_filters,
+ default_filters)
+ self.assertEqual(CONF.scheduler_default_weighers,
+ ['ChanceWeigher'])
+
+ self.flags(scheduler_driver=simple,
+ scheduler_default_filters=['CapacityFilter'],
+ scheduler_default_weighers=['CapacityWeigher'])
+ self.manager = self.manager_cls()
+ self.assertTrue(isinstance(self.manager.driver,
+ filter_scheduler.FilterScheduler))
+ self.assertEqual(CONF.scheduler_default_filters,
+ default_filters)
+ self.assertEqual(CONF.scheduler_default_weighers,
+ ['AllocatedCapacityWeigher'])
+
class SchedulerTestCase(test.TestCase):
"""Test case for base scheduler driver class."""