saltext.vmware.utils.vm#

saltext.vmware.utils.vm.power_cycle_vm(virtual_machine, action='on')[source]#

Powers on/off a virtual machine specified by its name.

virtual_machine

vim.VirtualMachine object to power on/off virtual machine

action

Operation option to power on/off the machine

saltext.vmware.utils.vm.create_vm(vm_name, vm_config_spec, folder_object, resourcepool_object, host_object=None)[source]#

Creates virtual machine from config spec

vm_name

Virtual machine name to be created

vm_config_spec

Virtual Machine Config Spec object

folder_object

vm Folder managed object reference

resourcepool_object

Resource pool object where the machine will be created

host_object

Host object where the machine will be placed (optional)

return

Virtual Machine managed object reference

saltext.vmware.utils.vm.clone_vm(vm_name, folder_object, template, clone_config_spec)[source]#

Creates virtual machine from config spec

Returns Virtual Machine managed object reference

vm_name

Virtual machine name to be created

folder_object

Virtual Machine Folder managed object reference

template

Vitual Machine template to clone from

clone_config_spec

Clone Config Spec object

saltext.vmware.utils.vm.register_vm(datacenter, name, vmx_path, resourcepool_object, host_object=None)[source]#

Registers a virtual machine to the inventory with the given vmx file, on success it returns the vim.VirtualMachine managed object reference

datacenter

Datacenter object of the virtual machine, vim.Datacenter object

name

Name of the virtual machine

vmx_path:

Full path to the vmx file, datastore name should be included

resourcepool

Placement resource pool of the virtual machine, vim.ResourcePool object

host

Placement host of the virtual machine, vim.HostSystem object

saltext.vmware.utils.vm.update_vm(vm_ref, vm_config_spec)[source]#

Updates the virtual machine configuration with the given object

vm_ref

Virtual machine managed object reference

vm_config_spec

Virtual machine config spec object to update

saltext.vmware.utils.vm.delete_vm(vm_ref)[source]#

Destroys the virtual machine

vm_ref

Managed object reference of a virtual machine object

saltext.vmware.utils.vm.unregister_vm(vm_ref)[source]#

Destroys the virtual machine

vm_ref

Managed object reference of a virtual machine object

saltext.vmware.utils.vm.list_vms(service_instance)[source]#

Returns a list of VMs associated with a given service instance.

service_instance

The Service Instance Object from which to obtain VMs.

saltext.vmware.utils.vm.list_vm_templates(service_instance)[source]#

Returns a list of template VMs associated with a given service instance.

service_instance

The Service Instance Object from which to obtain VMs.

saltext.vmware.utils.vm.get_vm_by_property(service_instance, name, datacenter=None, vm_properties=None, traversal_spec=None, parent_ref=None)[source]#

Get virtual machine properties based on the traversal specs and properties list, returns Virtual Machine object with properties.

service_instance

Service instance object to access vCenter

name

Name of the virtual machine.

datacenter

Datacenter name

vm_properties

List of vm properties.

traversal_spec

Traversal Spec object(s) for searching.

parent_ref

Container Reference object for searching under a given object.

saltext.vmware.utils.vm.get_placement(service_instance, datacenter, placement=None)[source]#

To create a virtual machine a resource pool needs to be supplied, we would like to use the strictest as possible.

datacenter

Name of the datacenter

placement

Dictionary with the placement info, cluster, host resource pool name

return

Resource pool, cluster and host object if any applies

saltext.vmware.utils.vm.get_folder(service_instance, datacenter, placement, base_vm_name=None)[source]#

Returns a Folder Object

service_instance

Service instance object

datacenter

Name of the datacenter

placement

Placement dictionary

base_vm_name

Existing virtual machine name (for cloning)

saltext.vmware.utils.vm.read_ovf_file(ovf_path)[source]#

Read in OVF file.

ovf_path

Path to ovf file

saltext.vmware.utils.vm.read_ovf_from_ova(ova_path)[source]#

Read in OVF file from OVA.

ova_path

Path to ova file

saltext.vmware.utils.vm.get_network(vm)[source]#

Returns network from a virtual machine object.

vm

Virtual Machine Object from which to obtain mac address.

saltext.vmware.utils.vm.get_mac_address(vm)[source]#

Returns mac addresses from a virtual machine object.

vm

Virtual Machine Object from which to obtain mac address.

saltext.vmware.utils.vm.options_order_list(vm, order)[source]#

Converts a text order into internal representation for setting the boot order.

vm

Reference to virtual machine to check options on.

order

(List of strings) Boot order of devices. Acceptable strings: cdrom, disk, ethernet, floppy

saltext.vmware.utils.vm.compare_boot_order_list(new, current)[source]#

Compares current boot order list and input boot order list.

new

List of vim bootable device objects.

current

List of vim bootable device objects.

saltext.vmware.utils.vm.compare_boot_options(input_opts, current)[source]#

Compares current boot options and input options.

input_opts

(dict) Dictionary of virtual machine boot options.

current

Pyvmomi virtual machine boot options object.

saltext.vmware.utils.vm.boot_options_dif(input_opts, current)[source]#

Returns the difference between two dictionaries of virtual machine boot options.

input_opts

(dict) Dictionary of virtual machine boot options.

current

Pyvmomi virtual machine boot options object.

saltext.vmware.utils.vm.change_boot_options(vm, input_opts)[source]#

Changes boot options on given vm.

vm

reference to virtual machine to change options on.

input_opts

(dict) Dictionary of virtual machine boot options.

saltext.vmware.utils.vm.create_snapshot(vm_ref, snapshot_name, description, memory, quiesce)[source]#

Create virtual machine snapshot.

vm_ref

Reference to virtual machine.

snapshot_name

The name for the snapshot being created. Not unique

description

Description for the snapshot.

memory

(boolean) If TRUE, a dump of the internal state of the virtual machine (basically a memory dump) is included in the snapshot.

quiesce

(boolean) If TRUE and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine.

saltext.vmware.utils.vm.snapshot_recursive(snapshot_tree_root, snaps)[source]#

Recursively appends all snapshots in a snapshot tree.

snapshot_tree_root

Root node of snapshot tree.

snaps

List of snapshot info.

Recursively appends all snapshots in a snapshot tree.

snapshot_tree_root

Root node of snapshot tree.

snapshot_name

Name of snapshot to find.

snapshot_id

id of snapshot to find.

saltext.vmware.utils.vm.get_snapshots(vm_ref)[source]#

Returns list of snapshot info for a given vm.

vm_ref

Reference to a virtual machine.

saltext.vmware.utils.vm.destroy_snapshot(snapshot, remove_children)[source]#

Destroy a given snapshot.

snapshot

Reference to a vim.vm.Snapshot object.

remove_children

Remove subtree of snapshots.

saltext.vmware.utils.vm.relocate(vm, host, datastore, pool)[source]#

Relocates a virtual machine to the location specified.

vm

Reference to virtual machine.

host

Reference to new host.

datastore

Reference to datastore

Pool

Reference to resource pool.