Merge lp:~ewanmellor/nova/lp653651 into lp:~hudson-openstack/nova/trunk

Proposed by Ewan Mellor
Status: Merged
Approved by: Jay Pipes
Approved revision: 317
Merged at revision: 324
Proposed branch: lp:~ewanmellor/nova/lp653651
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 71 lines (+15/-20)
1 file modified
nova/virt/xenapi.py (+15/-20)
To merge this branch: bzr merge lp:~ewanmellor/nova/lp653651
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Eric Day (community) Approve
Review via email: mp+37352@code.launchpad.net

Commit message

Matches changes in the database / model layer with corresponding fixes to nova.virt.xenapi.

To post a comment you must log in.
Revision history for this message
Eric Day (eday) wrote :

lgtm

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

yep, looks good. /me definitely going to work with Ewan and MontyT at the next summit to get a full testing infrastructure up on Hudson to specifically test the Xen stuff so we can avoid embarrassing breakages like this in the future...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/xenapi.py'
2--- nova/virt/xenapi.py 2010-09-30 09:21:44 +0000
3+++ nova/virt/xenapi.py 2010-10-02 16:05:58 +0000
4@@ -42,10 +42,12 @@
5 from twisted.internet import reactor
6 from twisted.internet import task
7
8+from nova import db
9 from nova import flags
10 from nova import process
11 from nova import utils
12 from nova.auth.manager import AuthManager
13+from nova.compute import instance_types
14 from nova.compute import power_state
15 from nova.virt import images
16
17@@ -113,32 +115,24 @@
18 raise Exception('Attempted to create non-unique name %s' %
19 instance.name)
20
21- if 'bridge_name' in instance.datamodel:
22- network_ref = \
23- yield self._find_network_with_bridge(
24- instance.datamodel['bridge_name'])
25- else:
26- network_ref = None
27-
28- if 'mac_address' in instance.datamodel:
29- mac_address = instance.datamodel['mac_address']
30- else:
31- mac_address = ''
32-
33- user = AuthManager().get_user(instance.datamodel['user_id'])
34- project = AuthManager().get_project(instance.datamodel['project_id'])
35+ network = db.project_get_network(None, instance.project_id)
36+ network_ref = \
37+ yield self._find_network_with_bridge(network.bridge)
38+
39+ user = AuthManager().get_user(instance.user_id)
40+ project = AuthManager().get_project(instance.project_id)
41 vdi_uuid = yield self._fetch_image(
42- instance.datamodel['image_id'], user, project, True)
43+ instance.image_id, user, project, True)
44 kernel = yield self._fetch_image(
45- instance.datamodel['kernel_id'], user, project, False)
46+ instance.kernel_id, user, project, False)
47 ramdisk = yield self._fetch_image(
48- instance.datamodel['ramdisk_id'], user, project, False)
49+ instance.ramdisk_id, user, project, False)
50 vdi_ref = yield self._call_xenapi('VDI.get_by_uuid', vdi_uuid)
51
52 vm_ref = yield self._create_vm(instance, kernel, ramdisk)
53 yield self._create_vbd(vm_ref, vdi_ref, 0, True)
54 if network_ref:
55- yield self._create_vif(vm_ref, network_ref, mac_address)
56+ yield self._create_vif(vm_ref, network_ref, instance.mac_address)
57 logging.debug('Starting VM %s...', vm_ref)
58 yield self._call_xenapi('VM.start', vm_ref, False, False)
59 logging.info('Spawning VM %s created %s.', instance.name, vm_ref)
60@@ -148,8 +142,9 @@
61 """Create a VM record. Returns a Deferred that gives the new
62 VM reference."""
63
64- mem = str(long(instance.datamodel['memory_kb']) * 1024)
65- vcpus = str(instance.datamodel['vcpus'])
66+ instance_type = instance_types.INSTANCE_TYPES[instance.instance_type]
67+ mem = str(long(instance_type['memory_mb']) * 1024 * 1024)
68+ vcpus = str(instance_type['vcpus'])
69 rec = {
70 'name_label': instance.name,
71 'name_description': '',