summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2011-05-23 14:38:37 -0500
committerChris Behrens <cbehrens@codestud.com>2011-05-23 14:38:37 -0500
commitffac2aa8162ba5111a01b495d9dd7e43bfda4af4 (patch)
tree0026787a684d89a70573e4a7f9143cd71aa82c6d /nova
parente1795bd73c71a20290bc988c410e0cc30afe6bd8 (diff)
initial fudging in of swap disk
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/xenapi/stubs.py2
-rw-r--r--nova/virt/xenapi/vm_utils.py18
-rw-r--r--nova/virt/xenapi/vmops.py21
3 files changed, 26 insertions, 15 deletions
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 4833ccb07..d9306900d 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -37,7 +37,7 @@ def stubout_instance_snapshot(stubs):
sr_ref=sr_ref, sharable=False)
vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
vdi_uuid = vdi_rec['uuid']
- return vdi_uuid
+ return dict(primary_vdi_uuid=vdi_uuid, swap_vdi_uuid=None)
stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 9f6cd608c..c24fc7ba6 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -408,18 +408,24 @@ class VMHelper(HelperBase):
kwargs = {'params': pickle.dumps(params)}
task = session.async_call_plugin('glance', 'download_vhd', kwargs)
- vdi_uuid = session.wait_for_task(task, instance_id)
+ vdi_uuids = session.wait_for_task(task, instance_id)
+ primary_vdi_uuid = vdi_uuids.get('primary_vdi_uuid')
+ swap_vdi_uuid = vdi_uuids.get('swap_vdi_uuid')
cls.scan_sr(session, instance_id, sr_ref)
# Set the name-label to ease debugging
- vdi_ref = session.get_xenapi().VDI.get_by_uuid(vdi_uuid)
- name_label = get_name_label_for_image(image)
- session.get_xenapi().VDI.set_name_label(vdi_ref, name_label)
+ primary_vdi_ref = session.get_xenapi().VDI.get_by_uuid(primary_vdi_uuid)
+ primary_name_label = get_name_label_for_image(image)
+ session.get_xenapi().VDI.set_name_label(primary_vdi_ref, primary_name_label)
- LOG.debug(_("xapi 'download_vhd' returned VDI UUID %(vdi_uuid)s")
+ LOG.debug(_("xapi 'download_vhd' returned VDI UUID %(primary_vdi_uuid)s")
% locals())
- return vdi_uuid
+
+ LOG.debug("=" * 100)
+ LOG.debug(rimary_vdi_uuid)
+ LOG.debug(swap_vdi_uuid)
+ return (primary_vdi_uuid, swap_vdi_uuid)
@classmethod
def _fetch_image_glance_disk(cls, session, instance_id, image, access,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 0074444f8..4a01cac29 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -109,20 +109,20 @@ class VMOps(object):
user = AuthManager().get_user(instance.user_id)
project = AuthManager().get_project(instance.project_id)
disk_image_type = VMHelper.determine_disk_image_type(instance)
- vdi_uuid = VMHelper.fetch_image(self._session, instance.id,
- instance.image_id, user, project, disk_image_type)
- return vdi_uuid
+ (primary_vdi_uuid, swap_vdi_uuid) = VMHelper.fetch_image(self._session,
+ instance.id, instance.image_id, user, project, disk_image_type)
+ return (primary_vdi_uuid, swap_vdi_uuid)
def spawn(self, instance, network_info=None):
- vdi_uuid = self._create_disk(instance)
- vm_ref = self._create_vm(instance, vdi_uuid, network_info)
+ vdi_uuid, swap_uuid = self._create_disk(instance)
+ vm_ref = self._create_vm(instance, vdi_uuid, swap_uuid, network_info)
self._spawn(instance, vm_ref)
def spawn_rescue(self, instance):
"""Spawn a rescue instance."""
self.spawn(instance)
- def _create_vm(self, instance, vdi_uuid, network_info=None):
+ def _create_vm(self, instance, vdi_uuid, swap_vdi_uuid=None, network_info=None):
"""Create VM instance."""
instance_name = instance.name
vm_ref = VMHelper.lookup(self._session, instance_name)
@@ -143,18 +143,20 @@ class VMOps(object):
# Are we building from a pre-existing disk?
vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', vdi_uuid)
+ if swap_vdi_uuid:
+ swap_vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', swap_vdi_uuid)
disk_image_type = VMHelper.determine_disk_image_type(instance)
kernel = None
if instance.kernel_id:
kernel = VMHelper.fetch_image(self._session, instance.id,
- instance.kernel_id, user, project, ImageType.KERNEL_RAMDISK)
+ instance.kernel_id, user, project, ImageType.KERNEL_RAMDISK)[0]
ramdisk = None
if instance.ramdisk_id:
ramdisk = VMHelper.fetch_image(self._session, instance.id,
- instance.ramdisk_id, user, project, ImageType.KERNEL_RAMDISK)
+ instance.ramdisk_id, user, project, ImageType.KERNEL_RAMDISK)[0]
use_pv_kernel = VMHelper.determine_is_pv(self._session, instance.id,
vdi_ref, disk_image_type, instance.os_type)
@@ -163,6 +165,9 @@ class VMOps(object):
VMHelper.create_vbd(session=self._session, vm_ref=vm_ref,
vdi_ref=vdi_ref, userdevice=0, bootable=True)
+ if swap_vdi_uuid:
+ VMHelper.create_vbd(session=self._session, vm_ref=vm_ref,
+ vdi_ref=swap_vdi_ref, userdevice=0, bootable=False)
# TODO(tr3buchet) - check to make sure we have network info, otherwise
# create it now. This goes away once nova-multi-nic hits.