Class for VM tasks like spawn, snapshot, suspend, resume etc.
-
class VMwareVMOps(session, virtapi, volumeops, cluster_name=None)
Bases: object
Management class for VM-related tasks.
-
confirm_migration(migration, instance, network_info)
Confirms a resize, destroying the source VM.
-
destroy(instance, network_info, destroy_disks=True)
Destroy a VM instance. Steps followed are:
1. Power off the VM, if it is in poweredOn state.
2. Un-register a VM.
3. Delete the contents of the folder holding the VM related data.
-
finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance=False, block_device_info=None, power_on=True)
Completes a resize, turning on the migrated instance.
-
finish_revert_migration(instance, network_info, block_device_info, power_on=True)
Finish reverting a resize.
-
get_console_output(instance)
Return snapshot of console.
-
get_diagnostics(instance)
Return data about VM diagnostics.
-
get_info(instance)
Return data about the VM instance.
-
get_vnc_console(instance)
Return connection info for a vnc console.
-
get_vnc_console_vcenter(instance)
Return connection info for a vnc console using vCenter logic.
-
inject_network_info(instance, network_info)
inject network info for specified instance.
-
list_instances()
Lists the VM instances that are registered with the ESX host.
-
live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False)
Spawning live_migration operation for distributing high-load.
-
migrate_disk_and_power_off(context, instance, dest, instance_type)
Transfers the disk of a running instance in multiple phases, turning
off the instance before the end.
-
pause(instance)
-
plug_vifs(instance, network_info)
Plug VIFs into networks.
-
poll_rebooting_instances(timeout, instances)
Poll for rebooting instances.
-
power_off(instance)
Power off the specified instance.
-
power_on(context, instance, network_info, block_device_info)
-
reboot(instance, network_info)
Reboot a VM instance.
-
rescue(context, instance, network_info, image_meta)
Rescue the specified instance.
- shutdown the instance VM.
- spawn a rescue VM (the vm name-label will be instance-N-rescue).
-
resume(instance)
Resume the specified instance.
-
snapshot(context, instance, snapshot_name, update_task_state)
Create snapshot from a running VM instance.
Steps followed are:
- Get the name of the vmdk file which the VM points to right now.
Can be a chain of snapshots, so we need to know the last in the
chain.
- Create the snapshot. A new vmdk is created which the VM points to
now. The earlier vmdk becomes read-only.
- Call CopyVirtualDisk which coalesces the disk chain to form a single
vmdk, rather a .vmdk metadata file and a -flat.vmdk disk data file.
- Now upload the -flat.vmdk file to the image store.
- Delete the coalesced .vmdk and -flat.vmdk created.
-
spawn(context, instance, image_meta, network_info, block_device_info=None)
Creates a VM instance.
Steps followed are:
- Create a VM with no disk and the specifics in the instance object
like RAM size.
- For flat disk
- 2.1. Create a dummy vmdk of the size of the disk file that is to be
- uploaded. This is required just to create the metadata file.
- 2.2. Delete the -flat.vmdk file created in the above step and retain
- the metadata .vmdk file.
2.3. Upload the disk file.
- For sparse disk
3.1. Upload the disk file to a -sparse.vmdk file.
3.2. Copy/Clone the -sparse.vmdk file to a thin vmdk.
3.3. Delete the -sparse.vmdk file.
- Attach the disk to the VM by reconfiguring the same.
- Power on the VM.
-
suspend(instance)
Suspend the specified instance.
-
unpause(instance)
-
unplug_vifs(instance, network_info)
Unplug VIFs from networks.
-
unrescue(instance)
Unrescue the specified instance.