Use instance_properties in resize.

This just makes resize behave a bit more like create, which is useful
for custom filtering.

Change-Id: I10ba726712d8f601f5ee97e0bb033bd7339a7a88
This commit is contained in:
Mark Washenberger
2012-01-05 18:15:29 -05:00
parent 4f63540735
commit a819c028ef
3 changed files with 12 additions and 8 deletions

View File

@@ -394,10 +394,12 @@ class DistributedScheduler(driver.Scheduler):
selected_filters = self._choose_host_filters()
# Filter out original host
if ('original_host' in request_spec and
request_spec.get('avoid_original_host', True)):
hosts = [(h, hi) for h, hi in hosts
if h != request_spec['original_host']]
try:
if request_spec['avoid_original_host']:
original_host = request_spec['instance_properties']['host']
hosts = [(h, hi) for h, hi in hosts if h != original_host]
except (KeyError, TypeError):
pass
# TODO(sandy): We're only using InstanceType-based specs
# currently. Later we'll need to snoop for more detailed

View File

@@ -313,7 +313,7 @@ class DistributedSchedulerTestCase(test.TestCase):
_fake_choose_host_filters)
hosts = [('host1', '1info'), ('host2', '2info'), ('host3', '3info')]
request_spec = dict(original_host='host2',
request_spec = dict(instance_properties=dict(host='host2'),
avoid_original_host=True)
filtered = sched._filter_hosts('compute', request_spec, hosts, {})
@@ -333,7 +333,7 @@ class DistributedSchedulerTestCase(test.TestCase):
_fake_choose_host_filters)
hosts = [('host1', '1info'), ('host2', '2info'), ('host3', '3info')]
request_spec = dict(original_host='host2',
request_spec = dict(instance_properties=dict(host='host2'),
avoid_original_host=False)
filtered = sched._filter_hosts('compute', request_spec, hosts, {})

View File

@@ -2060,7 +2060,8 @@ class ComputeAPITestCase(BaseTestCase):
def test_resize_request_spec(self):
def _fake_cast(context, args):
request_spec = args['args']['request_spec']
self.assertEqual(request_spec['original_host'], 'host2')
instance_properties = request_spec['instance_properties']
self.assertEqual(instance_properties['host'], 'host2')
self.assertEqual(request_spec['avoid_original_host'], True)
self.stubs.Set(self.compute_api, '_cast_scheduler_message',
@@ -2078,7 +2079,8 @@ class ComputeAPITestCase(BaseTestCase):
def test_resize_request_spec_noavoid(self):
def _fake_cast(context, args):
request_spec = args['args']['request_spec']
self.assertEqual(request_spec['original_host'], 'host2')
instance_properties = request_spec['instance_properties']
self.assertEqual(instance_properties['host'], 'host2')
self.assertEqual(request_spec['avoid_original_host'], False)
self.stubs.Set(self.compute_api, '_cast_scheduler_message',