Add option to force hosts to scheduler

Change-Id: I7364115e247ebeb441fa838ac66db5ef5f608b55
This commit is contained in:
Vishvananda Ishaya
2012-01-20 15:28:39 -08:00
parent 55c84792e7
commit 00f257ccd3
4 changed files with 23 additions and 4 deletions

View File

@@ -467,3 +467,5 @@ DEFINE_boolean('allow_ec2_admin_api', False, 'Enable/Disable EC2 Admin API')
DEFINE_integer('service_down_time', 60,
'maximum time since last check-in for up service')
DEFINE_string('default_schedule_zone', None,
'zone to use when user doesnt specify one')

View File

@@ -117,6 +117,9 @@ class HostState(object):
if self.host in filter_properties.get('ignore_hosts', []):
return False
force_hosts = filter_properties.get('force_hosts', [])
if force_hosts:
return self.host in force_hosts
for filter_fn in filter_fns:
if not filter_fn(self, filter_properties):
return False

View File

@@ -35,8 +35,6 @@ flags.DEFINE_integer("max_gigabytes", 10000,
"maximum number of volume gigabytes to allow per host")
flags.DEFINE_integer("max_networks", 1000,
"maximum number of networks to allow per host")
flags.DEFINE_string('default_schedule_zone', None,
'zone to use when user doesnt specify one')
flags.DEFINE_list('isolated_images', [], 'Images to run on isolated host')
flags.DEFINE_list('isolated_hosts', [], 'Host reserved for specific images')
flags.DEFINE_boolean('skip_isolated_core_check', True,

View File

@@ -18,8 +18,6 @@ Tests For HostManager
import datetime
import mox
from nova import db
from nova import exception
from nova import log as logging
@@ -364,3 +362,21 @@ class HostStateTestCase(test.TestCase):
result = fake_host.passes_filters(filter_fns, filter_properties)
self.mox.VerifyAll()
self.assertFalse(result)
def test_host_state_passes_filters_skipped_from_force(self):
fake_host = host_manager.HostState('host1', 'compute')
filter_properties = {'force_hosts': ['host1']}
cls1 = ComputeFilterClass1()
cls2 = ComputeFilterClass2()
self.mox.StubOutWithMock(cls1, 'host_passes')
self.mox.StubOutWithMock(cls2, 'host_passes')
filter_fns = [cls1.host_passes, cls2.host_passes]
# cls[12].host_passes() not called because of short circuit
# with matching host to force
self.mox.ReplayAll()
result = fake_host.passes_filters(filter_fns, filter_properties)
self.mox.VerifyAll()
self.assertTrue(result)