'Transfers the disk of a running instance in multiple phases, turning
off the instance before the end.'

def migrate_disk_and_power_off(self, context, instance, dest, flavor):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    vmdk = vm_util.get_vmdk_info(self._session, vm_ref, uuid=instance.uuid)
    if ((flavor.root_gb < instance.flavor.root_gb) or ((flavor.root_gb != 0) and (flavor.root_gb < (vmdk.capacity_in_bytes / units.Gi)))):
        reason = _('Unable    to    shrink    disk.')
        raise exception.InstanceFaultRollback(exception.ResizeError(reason=reason))
    self._update_instance_progress(context, instance, step=0, total_steps=RESIZE_TOTAL_STEPS)
    vm_util.power_off_instance(self._session, instance, vm_ref)
    self._update_instance_progress(context, instance, step=1, total_steps=RESIZE_TOTAL_STEPS)
    self._resize_vm(context, instance, vm_ref, flavor, instance.image_meta)
    self._update_instance_progress(context, instance, step=2, total_steps=RESIZE_TOTAL_STEPS)
    self._resize_disk(instance, vm_ref, vmdk, flavor)
    self._update_instance_progress(context, instance, step=3, total_steps=RESIZE_TOTAL_STEPS)
    self._remove_ephemerals_and_swap(vm_ref)
    self._update_instance_progress(context, instance, step=4, total_steps=RESIZE_TOTAL_STEPS)
