summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/virt/xenapi/vmops.py22
-rw-r--r--nova/virt/xenapi_conn.py10
3 files changed, 23 insertions, 14 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index b8c3c24cd..6b784f1e3 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -463,7 +463,7 @@ class ComputeManager(manager.Manager):
vcpus=instance_type['vcpus'],
local_gb=instance_type['local_gb']))
- self.driver._start(instance_ref)
+ self.driver.revert_resize(instance_ref)
self.db.migration_update(context, migration_id,
{'status': 'reverted'})
@@ -514,8 +514,6 @@ class ComputeManager(manager.Manager):
self.db.migration_update(context, migration_id,
{'status': 'post-migrating', })
-
-
service = self.db.service_get_by_host_and_topic(context,
migration_ref['dest_compute'], FLAGS.compute_topic)
topic = self.db.queue_get_for(context, FLAGS.compute_topic,
@@ -536,7 +534,6 @@ class ComputeManager(manager.Manager):
migration_ref = self.db.migration_get(context, migration_id)
instance_ref = self.db.instance_get(context,
migration_ref['instance_id'])
-
#TODO(mdietz): apply the rest of the instance_type attributes going
#after they're supported
instance_type = self.db.instance_type_get_by_flavor_id(context,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index b5003f0f8..ee99a9918 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -62,6 +62,17 @@ class VMOps(object):
vm_refs.append(vm_rec["name_label"])
return vm_refs
+ def revert_resize(self, instance):
+ vm_ref = VMHelper.lookup(self._session, instance.name)
+ self._start(instance, vm_ref)
+
+ def finish_resize(self, instance, disk_info):
+ vdi_uuid = self._vmops.link_disks(instance, disk_info['base_copy'],
+ disk_info['cow'])
+ vm_ref = self._create_vm(instance, vdi_uuid)
+ self.resize_instance(instance, vdi_uuid)
+ self._spawn(instance, vm_ref)
+
def _start(self, instance, vm_ref=None):
"""Power on a VM instance"""
if not vm_ref:
@@ -307,7 +318,8 @@ class VMOps(object):
template_vdi_uuids = template_vm_ref = None
try:
# transfer the base copy
- template_vm_ref, template_vdi_uuids = selimage._get_snapshot(instance)
+ template_vm_ref, template_vdi_uuids = \
+ self.image._get_snapshot(instance)
base_copy_uuid = template_vdi_uuids['image']
vdi_ref, vm_vdi_rec = \
VMHelper.get_vdi_for_vm_safely(self._session, vm_ref)
@@ -370,8 +382,8 @@ class VMOps(object):
#The new disk size must be in bytes
new_disk_size = str(instance.local_gb * 1024 * 1024 * 1024)
- LOG.debug(_("Resizing VDI %s for instance %s. Expanding to %sGB") % (vdi_uuid,
- instance.name, instance.local_gb))
+ LOG.debug(_("Resizpng VDI %s for instance %s. Expanding to %sGB") %
+ (vdi_uuid, instance.name, instance.local_gb))
vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', vdi_uuid)
self._session.call_xenapi('VDI.resize_online', vdi_ref, new_disk_size)
LOG.debug(_("Resize instance %s complete") % (instance.name))
@@ -451,8 +463,8 @@ class VMOps(object):
state = self.get_info(instance['name'])['state']
if state == power_state.SHUTDOWN:
instance_name = instance.name
- LOG.warn(_("VM %(instance_name)s already halted, skipping shutdown...") %
- locals())
+ LOG.warn(_("VM %(instance_name)s already halted,"
+ "skipping shutdown...") % locals())
return
instance_id = instance.id
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 2b0f82a4a..da2fb51f1 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -164,13 +164,13 @@ class XenAPIConnection(object):
"""Create VM instance"""
self._vmops.spawn(instance)
+ def revert_resize(self, instance):
+ """Reverts a resize, powering back on the instance"""
+ self._vmops.revert_resize(instance)
+
def finish_resize(self, instance, disk_info):
"""Completes a resize, turning on the migrated instance"""
- vdi_uuid = self._vmops.link_disks(instance, disk_info['base_copy'],
- disk_info['cow'])
- vm_ref = self._vmops._create_vm(instance, vdi_uuid)
- self._vmops.resize_instance(instance, vdi_uuid)
- self._vmops._spawn(instance, vm_ref)
+ self._vmops.finish_resize(instance, disk_info)
def snapshot(self, instance, image_id):
""" Create snapshot from a running VM instance """