The nova.virt.vmwareapi.vm_util Module

The VMware API VM utility module to build SOAP object specs.

build_datastore_path(datastore_name, path)

Build the datastore compliant path.

clone_vm_spec(client_factory, location, power_on=False, snapshot=None, template=False)

Builds the VM clone spec.

create_controller_spec(client_factory, key, adapter_type='lsiLogic')

Builds a Config Spec for the LSI or Bus Logic Controller’s addition which acts as the controller for the virtual hard disk to be attached to the VM.

create_network_spec(client_factory, vif_info)

Builds a config spec for the addition of a new network adapter to the VM.

create_virtual_disk_spec(client_factory, controller_key, disk_type='preallocated', file_path=None, disk_size=None, linked_clone=False, unit_number=None, device_name=None)

Builds spec for the creation of a new/ attaching of an already existing Virtual Disk to the VM.

delete_virtual_disk_spec(client_factory, device)

Builds spec for the deletion of an already existing Virtual Disk from VM.

get_add_vswitch_port_group_spec(client_factory, vswitch_name, port_group_name, vlan_id)

Builds the virtual switch port group add spec.

get_cluster_ref_from_name(session, cluster_name)

Get reference to the cluster with the name specified.

get_copy_virtual_disk_spec(client_factory, adapter_type='lsilogic', disk_type='preallocated')

Builds the Virtual Disk copy spec.

get_datastore_ref_and_name(session, cluster=None, host=None)

Get the datastore list and choose the first local storage.

get_dummy_vm_create_spec(client_factory, name, data_store_name)

Builds the dummy VM create spec.

get_host_id_from_vm_ref(session, vm_ref)

This method allows you to find the managed object ID of the host running a VM. Since vMotion can change the value, you should not presume that this is a value that you can cache for very long and should be prepared to allow for it to change.

Parameters:
  • session – a vSphere API connection
  • vm_ref – a reference object to the running VM
Returns:

the host_id running the virtual machine

get_host_name_for_vm(session, instance)

Get the ESXi host running a VM by its name.

get_host_name_from_host_ref(host_ref)
get_host_ref(session, cluster=None)

Get reference to a host within the cluster specified.

get_host_ref_for_vm(session, instance, props)

Get the ESXi host running a VM by its name.

get_host_ref_from_id(session, host_id, property_list=None)

Get a host reference object for a host_id string.

get_machine_id_change_spec(client_factory, machine_id_str)

Builds the machine id change config spec.

get_rdm_create_spec(client_factory, device, adapter_type='lsiLogic', disk_type='rdmp')

Builds the RDM virtual disk create spec.

get_rdm_disk(hardware_devices, uuid)

Gets the RDM disk key.

get_vm_create_spec(client_factory, instance, data_store_name, vif_infos, os_type='otherGuest')

Builds the VM Create spec.

get_vm_ref(session, instance)

Get reference to the VM through uuid or vm name.

get_vm_ref_from_name(session, vm_name)

Get reference to the VM with the name specified.

get_vm_ref_from_uuid(session, instance_uuid)

Get reference to the VM with the uuid specified.

get_vmdk_attach_config_spec(client_factory, adapter_type='lsiLogic', disk_type='preallocated', file_path=None, disk_size=None, linked_clone=False, controller_key=None, unit_number=None, device_name=None)

Builds the vmdk attach config spec.

get_vmdk_create_spec(client_factory, size_in_kb, adapter_type='lsiLogic', disk_type='preallocated')

Builds the virtual disk create spec.

get_vmdk_detach_config_spec(client_factory, device)

Builds the vmdk detach config spec.

get_vmdk_path_and_adapter_type(hardware_devices)

Gets the vmdk file path and the storage adapter type.

get_vnc_config_spec(client_factory, port, password)

Builds the vnc config spec.

property_from_property_set(property_name, property_set)

Use this method to filter property collector results.

Because network traffic is expensive, multiple VMwareAPI calls will sometimes pile-up properties to be collected. That means results may contain many different values for multiple purposes.

This helper will filter a list for a single result and filter the properties of that result to find the single value of whatever type resides in that result. This could be a ManagedObjectReference ID or a complex value.

Parameters:
  • property_name – name of property you want
  • property_set – all results from query
Returns:

the value of the property.

relocate_vm_spec(client_factory, datastore=None, host=None, disk_move_type='moveAllDiskBackingsAndAllowSharing')

Builds the VM relocation spec.

search_datastore_spec(client_factory, file_name)

Builds the datastore search spec.

split_datastore_path(datastore_path)

Split the VMware style datastore path to get the Datastore name and the entity path.

Previous topic

The nova.virt.vmwareapi.vim_util Module

Next topic

The nova.virt.vmwareapi.vmops Module

This Page