Class for VM tasks like spawn, snapshot, suspend, resume etc.
-
class VMWareVMOps(session)
Bases: object
Management class for VM-related tasks.
-
destroy(instance, network_info)
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.
-
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.
-
list_instances()
Lists the VM instances that are registered with the ESX host.
-
pause(instance)
-
plug_vifs(instance, network_info)
Plug VIFs into networks.
-
reboot(instance, network_info)
Reboot a VM instance.
-
resume(instance)
Resume the specified instance.
-
snapshot(context, instance, snapshot_name)
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)
Creates a VM instance.
Steps followed are:
- Create a VM with no disk and the specifics in the instance object
like RAM size.
- 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.
- Delete the -flat.vmdk file created in the above step and retain
the metadata .vmdk file.
- Upload the disk 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.