summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem@us.ibm.com>2013-05-29 21:12:04 -0700
committerMatt Riedemann <mriedem@us.ibm.com>2013-05-30 07:52:33 -0700
commit1690a1ae8f2fdddebfb8ae50a8492aedf466b8e3 (patch)
tree968f7fe649af0c936595a581c9d346a989f80ced /nova/virt
parent783b0e836d9ba0630d4745a6457144fac6dfa9f0 (diff)
Add power_on flag to virt driver finish/revert migration methods
This patch adds a boolean power_on flag to the virt driver finish_migration and finish_revert_migration methods to indicate whether or not to power on the instance as part of the resize/migrate operation. The default is to power on the instance. Related to bug 1177811 Change-Id: I76c7d6912eda2c333554855a8956bd0fbb1e8b6d
Diffstat (limited to 'nova/virt')
-rwxr-xr-xnova/virt/driver.py26
-rwxr-xr-xnova/virt/fake.py4
-rwxr-xr-xnova/virt/hyperv/driver.py8
-rw-r--r--nova/virt/hyperv/migrationops.py10
-rwxr-xr-xnova/virt/libvirt/driver.py33
-rwxr-xr-xnova/virt/powervm/driver.py13
-rw-r--r--nova/virt/powervm/operator.py11
-rwxr-xr-xnova/virt/vmwareapi/driver.py9
-rw-r--r--nova/virt/vmwareapi/vmops.py13
-rwxr-xr-xnova/virt/xenapi/driver.py11
-rw-r--r--nova/virt/xenapi/vmops.py17
11 files changed, 98 insertions, 57 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index 93bff1ff4..6f79de048 100755
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -343,14 +343,23 @@ class ComputeDriver(object):
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info=None):
- """Completes a resize, turning on the migrated instance
+ block_device_info=None, power_on=True):
+ """Completes a resize.
+ :param context: the context for the migration/resize
+ :param migration: the migrate/resize information
+ :param instance: the instance being migrated/resized
+ :param disk_info: the newly transferred disk information
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param image_meta: image object returned by nova.image.glance that
defines the image from which this instance
was created
+ :param resize_instance: True if the instance is being resized,
+ False otherwise
+ :param block_device_info: instance volume block device info
+ :param power_on: True if the instance should be powered on, False
+ otherwise
"""
raise NotImplementedError()
@@ -360,8 +369,17 @@ class ComputeDriver(object):
raise NotImplementedError()
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
- """Finish reverting a resize, powering back on the instance."""
+ block_device_info=None, power_on=True):
+ """
+ Finish reverting a resize.
+
+ :param instance: the instance being migrated/resized
+ :param network_info:
+ :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
+ :param block_device_info: instance volume block device info
+ :param power_on: True if the instance should be powered on, False
+ otherwise
+ """
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index c38dc9ed6..1b65571a5 100755
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -170,7 +170,7 @@ class FakeDriver(driver.ComputeDriver):
pass
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
pass
def post_live_migration_at_destination(self, context, instance,
@@ -368,7 +368,7 @@ class FakeDriver(driver.ComputeDriver):
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info=None):
+ block_device_info=None, power_on=True):
return
def confirm_migration(self, migration, instance, network_info):
diff --git a/nova/virt/hyperv/driver.py b/nova/virt/hyperv/driver.py
index 477f8fa2a..675f36f54 100755
--- a/nova/virt/hyperv/driver.py
+++ b/nova/virt/hyperv/driver.py
@@ -172,17 +172,17 @@ class HyperVDriver(driver.ComputeDriver):
self._migrationops.confirm_migration(migration, instance, network_info)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
self._migrationops.finish_revert_migration(instance, network_info,
- block_device_info)
+ block_device_info, power_on)
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance=False,
- block_device_info=None):
+ block_device_info=None, power_on=True):
self._migrationops.finish_migration(context, migration, instance,
disk_info, network_info,
image_meta, resize_instance,
- block_device_info)
+ block_device_info, power_on)
def get_host_ip_addr(self):
return self._hostops.get_host_ip_addr()
diff --git a/nova/virt/hyperv/migrationops.py b/nova/virt/hyperv/migrationops.py
index ff8651efe..5ce092bf3 100644
--- a/nova/virt/hyperv/migrationops.py
+++ b/nova/virt/hyperv/migrationops.py
@@ -144,7 +144,7 @@ class MigrationOps(object):
self._pathutils.rename(revert_path, instance_path)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
LOG.debug(_("finish_revert_migration called"), instance=instance)
instance_name = instance['name']
@@ -157,7 +157,8 @@ class MigrationOps(object):
self._vmops.create_instance(instance, network_info, block_device_info,
root_vhd_path)
- self._vmops.power_on(instance)
+ if power_on:
+ self._vmops.power_on(instance)
def _merge_base_vhd(self, diff_vhd_path, base_vhd_path):
base_vhd_copy_path = os.path.join(os.path.dirname(diff_vhd_path),
@@ -209,7 +210,7 @@ class MigrationOps(object):
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance=False,
- block_device_info=None):
+ block_device_info=None, power_on=True):
LOG.debug(_("finish_migration called"), instance=instance)
instance_name = instance['name']
@@ -239,4 +240,5 @@ class MigrationOps(object):
self._vmops.create_instance(instance, network_info, block_device_info,
root_vhd_path)
- self._vmops.power_on(instance)
+ if power_on:
+ self._vmops.power_on(instance)
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 7af7e4e2a..becc132de 100755
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2386,7 +2386,7 @@ class LibvirtDriver(driver.ComputeDriver):
'id': virt_dom.ID()}
def _create_domain(self, xml=None, domain=None,
- instance=None, launch_flags=0):
+ instance=None, launch_flags=0, power_on=True):
"""Create a domain.
Either domain or xml must be passed in. If both are passed, then
@@ -2409,7 +2409,8 @@ class LibvirtDriver(driver.ComputeDriver):
if xml:
domain = self._conn.defineXML(xml)
- domain.createWithFlags(launch_flags)
+ if power_on:
+ domain.createWithFlags(launch_flags)
self._enable_hairpin(domain.XMLDesc(0))
# NOTE(uni): Now the container is running with its own private mount
@@ -2426,7 +2427,7 @@ class LibvirtDriver(driver.ComputeDriver):
return domain
def _create_domain_and_network(self, xml, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
"""Do required network setup and create domain."""
block_device_mapping = driver.block_device_info_get_mapping(
@@ -2448,7 +2449,7 @@ class LibvirtDriver(driver.ComputeDriver):
self.plug_vifs(instance, network_info)
self.firewall_driver.setup_basic_filtering(instance, network_info)
self.firewall_driver.prepare_instance_filter(instance, network_info)
- domain = self._create_domain(xml, instance=instance)
+ domain = self._create_domain(xml, instance=instance, power_on=power_on)
self.firewall_driver.apply_instance_filter(instance, network_info)
return domain
@@ -3626,7 +3627,7 @@ class LibvirtDriver(driver.ComputeDriver):
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info=None):
+ block_device_info=None, power_on=True):
LOG.debug(_("Starting finish_migration"), instance=instance)
# resize disks. only "disk" and "disk.local" are necessary.
@@ -3677,10 +3678,12 @@ class LibvirtDriver(driver.ComputeDriver):
block_device_info=block_device_info,
write_to_disk=True)
self._create_domain_and_network(xml, instance, network_info,
- block_device_info)
- timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_running,
- instance)
- timer.start(interval=0.5).wait()
+ block_device_info, power_on)
+ if power_on:
+ timer = loopingcall.FixedIntervalLoopingCall(
+ self._wait_for_running,
+ instance)
+ timer.start(interval=0.5).wait()
def _cleanup_failed_migration(self, inst_base):
"""Make sure that a failed migrate doesn't prevent us from rolling
@@ -3688,7 +3691,7 @@ class LibvirtDriver(driver.ComputeDriver):
shutil.rmtree(inst_base)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
LOG.debug(_("Starting finish_revert_migration"),
instance=instance)
@@ -3710,11 +3713,13 @@ class LibvirtDriver(driver.ComputeDriver):
xml = self.to_xml(instance, network_info, disk_info,
block_device_info=block_device_info)
self._create_domain_and_network(xml, instance, network_info,
- block_device_info)
+ block_device_info, power_on)
- timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_running,
- instance)
- timer.start(interval=0.5).wait()
+ if power_on:
+ timer = loopingcall.FixedIntervalLoopingCall(
+ self._wait_for_running,
+ instance)
+ timer.start(interval=0.5).wait()
def confirm_migration(self, migration, instance, network_info):
"""Confirms a resize, destroying the source VM."""
diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py
index 199b10704..5117bdf72 100755
--- a/nova/virt/powervm/driver.py
+++ b/nova/virt/powervm/driver.py
@@ -279,7 +279,7 @@ class PowerVMDriver(driver.ComputeDriver):
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info=None):
+ block_device_info=None, power_on=True):
"""Completes a resize, turning on the migrated instance
:param network_info:
@@ -297,7 +297,8 @@ class PowerVMDriver(driver.ComputeDriver):
disk_size = max(int(new_lv_size), int(old_lv_size))
disk_size_bytes = disk_size * 1024 * 1024 * 1024
self._powervm.deploy_from_migrated_file(
- lpar_obj, disk_info['root_disk_file'], disk_size_bytes)
+ lpar_obj, disk_info['root_disk_file'], disk_size_bytes,
+ power_on)
else:
# this shouldn't get hit unless someone forgot to handle
# a certain migration type
@@ -312,8 +313,8 @@ class PowerVMDriver(driver.ComputeDriver):
self._powervm.destroy(new_name)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
- """Finish reverting a resize, powering back on the instance."""
+ block_device_info=None, power_on=True):
+ """Finish reverting a resize."""
new_name = self._get_resize_name(instance['name'])
@@ -332,4 +333,6 @@ class PowerVMDriver(driver.ComputeDriver):
self._powervm.destroy(instance['name'])
# undo instance rename and start
self._powervm._operator.rename_lpar(new_name, instance['name'])
- self._powervm.power_on(instance['name'])
+
+ if power_on:
+ self._powervm.power_on(instance['name'])
diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py
index f78aeb475..18cba0ba2 100644
--- a/nova/virt/powervm/operator.py
+++ b/nova/virt/powervm/operator.py
@@ -414,7 +414,8 @@ class PowerVMOperator(object):
disk_info['root_disk_file'] = dest_file_path
return disk_info
- def deploy_from_migrated_file(self, lpar, file_path, size):
+ def deploy_from_migrated_file(self, lpar, file_path, size,
+ power_on=True):
"""Deploy the logical volume and attach to new lpar.
:param lpar: lar instance
@@ -426,13 +427,14 @@ class PowerVMOperator(object):
try:
# deploy lpar from file
self._deploy_from_vios_file(lpar, file_path, size,
- decompress=need_decompress)
+ decompress=need_decompress,
+ power_on=power_on)
finally:
# cleanup migrated file
self._operator._remove_file(file_path)
def _deploy_from_vios_file(self, lpar, file_path, size,
- decompress=True):
+ decompress=True, power_on=True):
self._operator.create_lpar(lpar)
lpar = self._operator.get_lpar(lpar['name'])
instance_id = lpar['lpar_id']
@@ -447,7 +449,8 @@ class PowerVMOperator(object):
self._disk_adapter._copy_file_to_device(file_path, diskName,
decompress)
- self._operator.start_lpar(lpar['name'])
+ if power_on:
+ self._operator.start_lpar(lpar['name'])
class BaseOperator(object):
diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py
index 4fa1614e0..916913187 100755
--- a/nova/virt/vmwareapi/driver.py
+++ b/nova/virt/vmwareapi/driver.py
@@ -383,16 +383,17 @@ class VMwareVCDriver(VMwareESXDriver):
self._vmops.confirm_migration(migration, instance, network_info)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
+ block_device_info=None, power_on=True):
"""Finish reverting a resize, powering back on the instance."""
- self._vmops.finish_revert_migration(instance)
+ self._vmops.finish_revert_migration(instance, power_on)
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance=False,
- block_device_info=None):
+ block_device_info=None, power_on=True):
"""Completes a resize, turning on the migrated instance."""
self._vmops.finish_migration(context, migration, instance, disk_info,
- network_info, image_meta, resize_instance)
+ network_info, image_meta, resize_instance,
+ power_on)
def live_migration(self, context, instance_ref, dest,
post_method, recover_method, block_migration=False,
diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py
index cda2ce8e3..538b498b6 100644
--- a/nova/virt/vmwareapi/vmops.py
+++ b/nova/virt/vmwareapi/vmops.py
@@ -978,8 +978,8 @@ class VMwareVMOps(object):
if network_info:
self.unplug_vifs(instance, network_info)
- def finish_revert_migration(self, instance):
- """Finish reverting a resize, powering back on the instance."""
+ def finish_revert_migration(self, instance, power_on=True):
+ """Finish reverting a resize."""
# The original vm was suffixed with '-orig'; find it using
# the old suffix, remove the suffix, then power it back on.
name_label = self._get_orig_vm_name_label(instance)
@@ -995,13 +995,16 @@ class VMwareVMOps(object):
self._session._wait_for_task(instance['uuid'], rename_task)
LOG.debug(_("Renamed the VM from %s") % name_label,
instance=instance)
- self.power_on(instance)
+ if power_on:
+ self.power_on(instance)
def finish_migration(self, context, migration, instance, disk_info,
- network_info, image_meta, resize_instance=False):
+ network_info, image_meta, resize_instance=False,
+ power_on=True):
"""Completes a resize, turning on the migrated instance."""
# 4. Start VM
- self.power_on(instance)
+ if power_on:
+ self.power_on(instance)
self._update_instance_progress(context, instance,
step=4,
total_steps=RESIZE_TOTAL_STEPS)
diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py
index 5bc1a3049..cd892bceb 100755
--- a/nova/virt/xenapi/driver.py
+++ b/nova/virt/xenapi/driver.py
@@ -182,18 +182,19 @@ class XenAPIDriver(driver.ComputeDriver):
self._vmops.confirm_migration(migration, instance, network_info)
def finish_revert_migration(self, instance, network_info,
- block_device_info=None):
- """Finish reverting a resize, powering back on the instance."""
+ block_device_info=None, power_on=True):
+ """Finish reverting a resize."""
# NOTE(vish): Xen currently does not use network info.
- self._vmops.finish_revert_migration(instance, block_device_info)
+ self._vmops.finish_revert_migration(instance, block_device_info,
+ power_on)
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance=False,
- block_device_info=None):
+ block_device_info=None, power_on=True):
"""Completes a resize, turning on the migrated instance."""
self._vmops.finish_migration(context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info)
+ block_device_info, power_on)
def snapshot(self, context, instance, image_id, update_task_state):
"""Create snapshot from a running VM instance."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 29e075655..332f3b88c 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -231,10 +231,13 @@ class VMOps(object):
mount_device,
hotplug=False)
- def finish_revert_migration(self, instance, block_device_info=None):
- self._restore_orig_vm_and_cleanup_orphan(instance, block_device_info)
+ def finish_revert_migration(self, instance, block_device_info=None,
+ power_on=True):
+ self._restore_orig_vm_and_cleanup_orphan(instance, block_device_info,
+ power_on)
- def _restore_orig_vm_and_cleanup_orphan(self, instance, block_device_info):
+ def _restore_orig_vm_and_cleanup_orphan(self, instance,
+ block_device_info, power_on=True):
# NOTE(sirp): the original vm was suffixed with '-orig'; find it using
# the old suffix, remove the suffix, then power it back on.
name_label = self._get_orig_vm_name_label(instance)
@@ -257,11 +260,12 @@ class VMOps(object):
# We crashed before the -orig backup was made
vm_ref = new_ref
- self._start(instance, vm_ref)
+ if power_on:
+ self._start(instance, vm_ref)
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
- block_device_info=None):
+ block_device_info=None, power_on=True):
root_vdi = vm_utils.move_disks(self._session, instance, disk_info)
if resize_instance:
@@ -292,7 +296,8 @@ class VMOps(object):
self._attach_mapped_block_devices(instance, block_device_info)
# 5. Start VM
- self._start(instance, vm_ref=vm_ref)
+ if power_on:
+ self._start(instance, vm_ref=vm_ref)
self._update_instance_progress(context, instance,
step=5,
total_steps=RESIZE_TOTAL_STEPS)