The nova.virt.vmwareapi.vm_util Module

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

class ExtraSpecs(cpu_limits=None, hw_version=None, storage_policy=None, cores_per_socket=None, memory_limits=None, disk_io_limits=None, vif_limits=None)

Bases: object

class Limits(limit=None, reservation=None, shares_level=None, shares_share=None)

Bases: object

has_limits()
validate()
class VmdkInfo

Bases: tuple

VmdkInfo(path, adapter_type, disk_type, capacity_in_bytes, device)

adapter_type

Alias for field number 1

capacity_in_bytes

Alias for field number 3

device

Alias for field number 4

disk_type

Alias for field number 2

path

Alias for field number 0

allocate_controller_key_and_unit_number(client_factory, devices, adapter_type)

This function inspects the current set of hardware devices and returns controller_key and unit_number that can be used for attaching a new virtual disk to adapter with the given adapter_type.

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

Builds the VM clone spec.

convert_vif_model(name)

Converts standard VIF_MODEL types to the internal VMware ones.

copy_virtual_disk(session, dc_ref, source, dest)

Copy a sparse virtual disk to a thin virtual disk.

This is also done to generate the meta-data file whose specifics depend on the size of the disk, thin/thick provisioning and the storage adapter type.

Parameters:
  • session
    • session for connection
  • dc_ref
    • data center reference object
  • source
    • source datastore path
  • dest
    • destination datastore path
Returns:

None

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

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_folder(session, parent_folder_ref, name)

Creates a folder in vCenter

A folder of ‘name’ will be created under the parent folder. The moref of the folder is returned.

create_serial_port_spec(client_factory)

Creates config spec for serial port.

create_virtual_cdrom_spec(client_factory, datastore, controller_key, file_path, cdrom_unit_number)

Builds spec for the creation of a new Virtual CDROM to the VM.

create_virtual_disk(session, dc_ref, adapter_type, disk_type, virtual_disk_path, size_in_kb)
create_vm(session, instance, vm_folder, config_spec, res_pool_ref)

Create VM on ESX host.

destroy_vm(session, instance, vm_ref=None)

Destroy a VM instance. Assumes VM is powered off.

detach_devices_from_vm(session, vm_ref, devices)

Detach specified devices from VM.

detach_virtual_disk_spec(client_factory, device, destroy_disk=False)

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

find_rescue_device(hardware_devices, instance)

Returns the rescue device.

The method will raise an exception if the rescue device does not exist. The resuce device has suffix ‘-rescue.vmdk’. :param hardware_devices: the hardware devices for the instance :param instance: nova.objects.instance.Instance object :return: the rescue disk device object

folder_ref_cache_get(path)
folder_ref_cache_update(path, folder_ref)
get_add_vswitch_port_group_spec(client_factory, vswitch_name, port_group_name, vlan_id)

Builds the virtual switch port group add spec.

get_all_cluster_mors(session)

Get all the clusters in the vCenter.

get_attach_port_index(session, vm_ref)

Get the first free port index.

get_cdrom_attach_config_spec(client_factory, datastore, file_path, controller_key, cdrom_unit_number)

Builds and returns the cdrom attach config spec.

get_cluster_ref_by_name(session, cluster_name)

Get reference to the vCenter cluster with the specified name.

get_ephemeral_name(id)
get_ephemerals(session, vm_ref)
get_host_name_for_vm(session, instance)

Get the hostname of the ESXi host currently running an instance.

get_host_ref(session, cluster=None)

Get reference to a host within the cluster specified.

get_host_ref_for_vm(session, instance)

Get a MoRef to the ESXi host currently running an instance.

get_machine_id_change_spec(client_factory, machine_id_str)

Builds the machine id change config spec.

get_network_attach_config_spec(client_factory, vif_info, index)

Builds the vif attach config spec.

get_network_detach_config_spec(client_factory, device, port_index)

Builds the vif detach config spec.

get_rdm_disk(hardware_devices, uuid)

Gets the RDM disk key.

get_res_pool_ref(session, cluster)

Get the resource pool.

get_scsi_adapter_type(hardware_devices)

Selects a proper iscsi adapter type from the existing hardware devices

get_stats_from_cluster(session, cluster)

Get the aggregate resource stats of a cluster.

get_storage_profile_spec(session, storage_policy)

Gets the vm profile spec configured for storage policy.

get_swap(session, vm_ref)
get_vm_boot_spec(client_factory, device)

Returns updated boot settings for the instance.

The boot order for the instance will be changed to have the input device as the boot disk.

get_vm_create_spec(client_factory, instance, data_store_name, vif_infos, extra_specs, os_type='otherGuest', profile_spec=None, metadata=None)

Builds the VM Create spec.

get_vm_detach_port_index(session, vm_ref, iface_id)
get_vm_extra_config_spec(client_factory, extra_opts)

Builds extra spec fields from a dictionary.

get_vm_ref(session, instance)

Get reference to the VM through uuid or vm name.

get_vm_ref_from_name(session, name)
get_vm_resize_spec(client_factory, vcpus, memory_mb, extra_specs, metadata=None)

Provides updates for a VM spec.

get_vm_state(session, instance)
get_vmdk_adapter_type(adapter_type)

Return the adapter type to be used in vmdk descriptor.

Adapter type in vmdk descriptor is same for LSI-SAS, LSILogic & ParaVirtual because Virtual Disk Manager API does not recognize the newer controller types.

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

Builds the vmdk attach config spec.

get_vmdk_backed_disk_device(hardware_devices, uuid)
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, destroy_disk=False)

Builds the vmdk detach config spec.

get_vmdk_info(session, vm_ref, uuid=None)

Returns information for the primary VMDK attached to the given VM.

get_vmdk_volume_disk(hardware_devices, path=None)
get_vnc_config_spec(client_factory, port)

Builds the vnc config spec.

get_vnc_port(session)

Return VNC port for an VM or None if there is no available port.

power_off_instance(session, instance, vm_ref=None)

Power off the specified instance.

power_on_instance(session, instance, vm_ref=None)

Power on the specified instance.

propset_dict(propset)

Turn a propset list into a dictionary

PropSet is an optional attribute on ObjectContent objects that are returned by the VMware API.

You can read more about these at: | http://pubs.vmware.com/vsphere-51/index.jsp | #com.vmware.wssdk.apiref.doc/ | vmodl.query.PropertyCollector.ObjectContent.html

Parameters:propset – a property “set” from ObjectContent
Returns:dictionary representing property set
reconfigure_vm(session, vm_ref, config_spec)

Reconfigure a VM according to the config spec.

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

Builds the VM relocation spec.

rename_vm(session, vm_ref, instance)
search_vm_ref_by_identifier(session, identifier)

Searches VM reference using the identifier.

This method is primarily meant to separate out part of the logic for vm_ref search that could be use directly in the special case of migrating the instance. For querying VM linked to an instance always use get_vm_ref instead.

vm_ref_cache_delete(id)
vm_ref_cache_from_instance(func)
vm_ref_cache_from_name(func)
vm_ref_cache_get(id)
vm_ref_cache_update(id, vm_ref)
vm_refs_cache_reset()

Previous topic

The nova.virt.vmwareapi.vim_util Module

Next topic

The nova.virt.vmwareapi.vmops Module

Project Source

This Page