This is interesting. My understanding is resize to different host. The host here means ESXi Host. I am not certain if current openstack support resize across Clusters.
Taking look at the code. "host_ref = self._get_host_ref_from_name(dest) ", And I think cluster does not fit into this category.
def migrate_disk_and_power_off(self, context, instance, dest, flavor):
"""
Transfers the disk of a running instance in multiple phases, turning
off the instance before the end.
"""
# 0. Zero out the progress to begin self._update_instance_progress(context, instance, step=0, total_steps=RESIZE_TOTAL_STEPS)
vm_ref = vm_util.get_vm_ref(self._session, instance)
# Read the host_ref for the destination. If this is None then the
# VC will decide on placement
host_ref = self._get_host_ref_from_name(dest)
# 1. Power off the instance self.power_off(instance) self._update_instance_progress(context, instance, step=1, total_steps=RESIZE_TOTAL_STEPS)
# 2. Rename the original VM with suffix '-orig'
name_label = self._get_orig_vm_name_label(instance) LOG.debug(_("Renaming the VM to %s") % name_label, instance=instance)
rename_task = self._session._call_method( self._session._get_vim(), "Rename_Task", vm_ref, newName=name_label) self._session._wait_for_task(instance['uuid'], rename_task) LOG.debug(_("Renamed the VM to %s") % name_label, instance=instance) self._update_instance_progress(context, instance, step=2, total_steps=RESIZE_TOTAL_STEPS)
# Get the clone vm spec
ds_ref = vm_util.get_datastore_ref_and_name( self._session, self._cluster, host_ref, datastore_regex=self._datastore_regex)[0] client_factory = self._session._get_vim().client.factory
rel_spec = vm_util.relocate_vm_spec(client_factory, ds_ref, host_ref)
clone_spec = vm_util.clone_vm_spec(client_factory, rel_spec) vm_folder_ref = self._get_vmfolder_ref()
# 3. Clone VM on ESX host LOG.debug(_("Cloning VM to host %s") % dest, instance=instance) vm_clone_task = self._session._call_method( self._session._get_vim(), "CloneVM_Task", vm_ref, folder=vm_folder_ref, name=instance['uuid'], spec=clone_spec) self._session._wait_for_task(instance['uuid'], vm_clone_task) LOG.debug(_("Cloned VM to host %s") % dest, instance=instance) self._update_instance_progress(context, instance, step=3, total_steps=RESIZE_TOTAL_STEPS)
This is interesting. My understanding is resize to different host. The host here means ESXi Host. I am not certain if current openstack support resize across Clusters.
Taking look at the code. "host_ref = self._get_ host_ref_ from_name( dest) ", And I think cluster does not fit into this category.
def migrate_ disk_and_ power_off( self, context, instance, dest,
flavor) :
self._ update_ instance_ progress( context, instance,
step= 0,
total_ steps=RESIZE_ TOTAL_STEPS)
"""
Transfers the disk of a running instance in multiple phases, turning
off the instance before the end.
"""
# 0. Zero out the progress to begin
vm_ref = vm_util. get_vm_ ref(self. _session, instance) host_ref_ from_name( dest)
# Read the host_ref for the destination. If this is None then the
# VC will decide on placement
host_ref = self._get_
# 1. Power off the instance
self.power_ off(instance)
self._ update_ instance_ progress( context, instance,
step= 1,
total_ steps=RESIZE_ TOTAL_STEPS)
# 2. Rename the original VM with suffix '-orig' orig_vm_ name_label( instance)
LOG.debug( _("Renaming the VM to %s") % name_label,
instance= instance) _call_method(
self._session. _get_vim( ),
"Rename_ Task", vm_ref, newName=name_label)
self._ session. _wait_for_ task(instance[ 'uuid'] , rename_task)
LOG.debug( _("Renamed the VM to %s") % name_label,
instance= instance)
self._ update_ instance_ progress( context, instance,
step= 2,
total_ steps=RESIZE_ TOTAL_STEPS)
name_label = self._get_
rename_task = self._session.
# Get the clone vm spec get_datastore_ ref_and_ name(
self._session, self._cluster, host_ref,
datastore_ regex=self. _datastore_ regex)[ 0]
client_ factory = self._session. _get_vim( ).client. factory relocate_ vm_spec( client_ factory, ds_ref, host_ref) clone_vm_ spec(client_ factory, rel_spec)
vm_folder_ ref = self._get_ vmfolder_ ref()
ds_ref = vm_util.
rel_spec = vm_util.
clone_spec = vm_util.
# 3. Clone VM on ESX host
LOG.debug( _("Cloning VM to host %s") % dest, instance=instance)
vm_clone_ task = self._session. _call_method(
self. _session. _get_vim( ),
"CloneVM_ Task", vm_ref,
folder= vm_folder_ ref,
name= instance[ 'uuid'] ,
spec= clone_spec)
self._ session. _wait_for_ task(instance[ 'uuid'] , vm_clone_task)
LOG.debug( _("Cloned VM to host %s") % dest, instance=instance)
self._ update_ instance_ progress( context, instance,
step= 3,
total_ steps=RESIZE_ TOTAL_STEPS)