summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/test_xenapi.py10
-rw-r--r--nova/virt/xenapi/vmops.py7
2 files changed, 13 insertions, 4 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 94daf0b5c..404c183a0 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -1488,6 +1488,11 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
instance = db.instance_update(self.context, instance['uuid'],
{'instance_type_id': 5})
+ # NOTE(danms): because we're stubbing out the instance_types from
+ # the database, our instance['instance_type'] doesn't get properly
+ # filled out here, so put what we need into it
+ instance['instance_type']['swap'] = 1024
+
def fake_generate_swap(*args, **kwargs):
self.called = True
self.stubs.Set(vm_utils, 'generate_swap', fake_generate_swap)
@@ -1500,6 +1505,11 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
instance = db.instance_update(self.context, instance['uuid'],
{'instance_type_id': 4})
+ # NOTE(danms): because we're stubbing out the instance_types from
+ # the database, our instance['instance_type'] doesn't get properly
+ # filled out here, so put what we need into it
+ instance['instance_type']['ephemeral_gb'] = 160
+
def fake_generate_ephemeral(*args):
self.called = True
self.stubs.Set(vm_utils, 'generate_ephemeral', fake_generate_ephemeral)
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 7ccb23283..3f742ebcd 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -466,7 +466,7 @@ class VMOps(object):
def _attach_disks(self, instance, vm_ref, name_label, vdis,
disk_image_type):
ctx = nova_context.get_admin_context()
- instance_type = db.instance_type_get(ctx, instance['instance_type_id'])
+ instance_type = instance['instance_type']
# DISK_ISO needs two VBDs: the ISO disk and a blank RW disk
if disk_image_type == vm_utils.ImageType.DISK_ISO:
@@ -475,7 +475,7 @@ class VMOps(object):
cd_vdi = vdis.pop('root')
root_vdi = vm_utils.fetch_blank_disk(self._session,
- instance['instance_type_id'])
+ instance_type['id'])
vdis['root'] = root_vdi
vm_utils.create_vbd(self._session, vm_ref, root_vdi['ref'],
@@ -570,8 +570,7 @@ class VMOps(object):
agent.resetnetwork()
# Set VCPU weight
- inst_type = db.instance_type_get(ctx, instance['instance_type_id'])
- vcpu_weight = inst_type['vcpu_weight']
+ vcpu_weight = instance['instance_type']['vcpu_weight']
if vcpu_weight is not None:
LOG.debug(_("Setting VCPU weight"), instance=instance)
self._session.call_xenapi('VM.add_to_VCPUs_params', vm_ref,