Merge lp:~cbehrens/nova/lp821720 into lp:~hudson-openstack/nova/trunk

Proposed by Chris Behrens
Status: Merged
Approved by: Josh Kearney
Approved revision: 1389
Merged at revision: 1391
Proposed branch: lp:~cbehrens/nova/lp821720
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 112 lines (+30/-8)
3 files modified
nova/compute/api.py (+4/-0)
nova/scheduler/zone_aware_scheduler.py (+2/-1)
nova/tests/scheduler/test_zone_aware_scheduler.py (+24/-7)
To merge this branch: bzr merge lp:~cbehrens/nova/lp821720
Reviewer Review Type Date Requested Status
Josh Kearney (community) Approve
Rick Harris (community) Approve
Review via email: mp+70640@code.launchpad.net

Description of the change

ZoneAwareScheduler classes couldn't build local instances due to an additional argument ('image') being added to compute_api.create_db_entry_for_new_instance() at some point.

With this fix, 'image' is now being passed down to the scheduler and into the above call. Updated an existing test so that it didn't stub around the above failing call.

To post a comment you must log in.
Revision history for this message
Rick Harris (rconradharris) wrote :

LGTM, nice.

review: Approve
Revision history for this message
Josh Kearney (jk0) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/compute/api.py'
2--- nova/compute/api.py 2011-08-04 16:26:14 +0000
3+++ nova/compute/api.py 2011-08-05 23:51:06 +0000
4@@ -360,6 +360,7 @@
5 instance_type, zone_blob,
6 availability_zone, injected_files,
7 admin_password,
8+ image,
9 instance_id=None, num_instances=1):
10 """Send the run_instance request to the schedulers for processing."""
11 pid = context.project_id
12@@ -373,6 +374,7 @@
13
14 filter_class = 'nova.scheduler.host_filter.InstanceTypeFilter'
15 request_spec = {
16+ 'image': image,
17 'instance_properties': base_options,
18 'instance_type': instance_type,
19 'filter': filter_class,
20@@ -415,6 +417,7 @@
21 instance_type, zone_blob,
22 availability_zone, injected_files,
23 admin_password,
24+ image,
25 num_instances=num_instances)
26
27 return base_options['reservation_id']
28@@ -463,6 +466,7 @@
29 instance_type, zone_blob,
30 availability_zone, injected_files,
31 admin_password,
32+ image,
33 instance_id=instance_id)
34
35 return [dict(x.iteritems()) for x in instances]
36
37=== modified file 'nova/scheduler/zone_aware_scheduler.py'
38--- nova/scheduler/zone_aware_scheduler.py 2011-07-28 00:55:10 +0000
39+++ nova/scheduler/zone_aware_scheduler.py 2011-08-05 23:51:06 +0000
40@@ -58,12 +58,13 @@
41 """Create the requested resource in this Zone."""
42 host = build_plan_item['hostname']
43 base_options = request_spec['instance_properties']
44+ image = request_spec['image']
45
46 # TODO(sandy): I guess someone needs to add block_device_mapping
47 # support at some point? Also, OS API has no concept of security
48 # groups.
49 instance = compute_api.API().create_db_entry_for_new_instance(context,
50- base_options, None, [])
51+ image, base_options, None, [])
52
53 instance_id = instance['id']
54 kwargs['instance_id'] = instance_id
55
56=== modified file 'nova/tests/scheduler/test_zone_aware_scheduler.py'
57--- nova/tests/scheduler/test_zone_aware_scheduler.py 2011-07-29 18:58:49 +0000
58+++ nova/tests/scheduler/test_zone_aware_scheduler.py 2011-08-05 23:51:06 +0000
59@@ -21,7 +21,9 @@
60 import nova.db
61
62 from nova import exception
63+from nova import rpc
64 from nova import test
65+from nova.compute import api as compute_api
66 from nova.scheduler import driver
67 from nova.scheduler import zone_aware_scheduler
68 from nova.scheduler import zone_manager
69@@ -114,7 +116,7 @@
70
71
72 def fake_decrypt_blob_returns_local_info(blob):
73- return {'foo': True} # values aren't important.
74+ return {'hostname': 'foooooo'} # values aren't important.
75
76
77 def fake_decrypt_blob_returns_child_info(blob):
78@@ -283,14 +285,29 @@
79 global was_called
80 sched = FakeZoneAwareScheduler()
81 was_called = False
82+
83+ def fake_create_db_entry_for_new_instance(self, context,
84+ image, base_options, security_group,
85+ block_device_mapping, num=1):
86+ global was_called
87+ was_called = True
88+ # return fake instances
89+ return {'id': 1, 'uuid': 'f874093c-7b17-49c0-89c3-22a5348497f9'}
90+
91+ def fake_rpc_cast(*args, **kwargs):
92+ pass
93+
94 self.stubs.Set(sched, '_decrypt_blob',
95 fake_decrypt_blob_returns_local_info)
96- self.stubs.Set(sched, '_provision_resource_locally',
97- fake_provision_resource_locally)
98-
99- request_spec = {'blob': "Non-None blob data"}
100-
101- sched._provision_resource_from_blob(None, request_spec, 1,
102+ self.stubs.Set(compute_api.API,
103+ 'create_db_entry_for_new_instance',
104+ fake_create_db_entry_for_new_instance)
105+ self.stubs.Set(rpc, 'cast', fake_rpc_cast)
106+
107+ build_plan_item = {'blob': "Non-None blob data"}
108+ request_spec = {'image': {}, 'instance_properties': {}}
109+
110+ sched._provision_resource_from_blob(None, build_plan_item, 1,
111 request_spec, {})
112 self.assertTrue(was_called)
113