saltext.vmware.utils.common#

Common functions used across modules

saltext.vmware.utils.common.get_root_folder(service_instance)[source]#

Returns the root folder of a vCenter.

service_instance

The Service Instance Object for which to obtain the root folder.

saltext.vmware.utils.common.get_service_content(service_instance)[source]#

Returns the service content for a Service Instance.

service_instance

The Service Instance from which to obtain service content.

saltext.vmware.utils.common.get_content(service_instance, obj_type, property_list=None, container_ref=None, traversal_spec=None, local_properties=False)[source]#

Returns the content of the specified type of object for a Service Instance.

For more information, please see: http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.pg.doc_50%2FPG_Ch5_PropertyCollector.7.6.html

service_instance

The Service Instance from which to obtain content.

obj_type

The type of content to obtain.

property_list

An optional list of object properties to used to return even more filtered content results.

container_ref

An optional reference to the managed object to search under. Can either be an object of type Folder, Datacenter, ComputeResource, Resource Pool or HostSystem. If not specified, default behaviour is to search under the inventory rootFolder.

traversal_spec

An optional TraversalSpec to be used instead of the standard Traverse All spec.

local_properties

Flag specifying whether the properties to be retrieved are local to the container. If that is the case, the traversal spec needs to be None.

saltext.vmware.utils.common.get_mors_with_properties(service_instance, object_type, property_list=None, container_ref=None, traversal_spec=None, local_properties=False)[source]#

Returns a list containing properties and managed object references for the managed object.

service_instance

The Service Instance from which to obtain managed object references.

object_type

The type of content for which to obtain managed object references.

property_list

An optional list of object properties used to return even more filtered managed object reference results.

container_ref

An optional reference to the managed object to search under. Can either be an object of type Folder, Datacenter, ComputeResource, Resource Pool or HostSystem. If not specified, default behaviour is to search under the inventory rootFolder.

traversal_spec

An optional TraversalSpec to be used instead of the standard Traverse All spec

local_properties

Flag specifying whether the properties to be retrieved are local to the container. If that is the case, the traversal spec needs to be None.

saltext.vmware.utils.common.get_mor_by_property(service_instance, object_type, property_value, property_name='name', container_ref=None)[source]#

Returns the first managed object reference having the specified property value.

service_instance

The Service Instance from which to obtain managed object references.

object_type

The type of content for which to obtain managed object references.

property_value

The name of the property for which to obtain the managed object reference.

property_name

An object property used to return the specified object reference results. Defaults to name.

container_ref

An optional reference to the managed object to search under. Can either be an object of type Folder, Datacenter, ComputeResource, Resource Pool or HostSystem. If not specified, default behaviour is to search under the inventory rootFolder.

saltext.vmware.utils.common.list_objects(service_instance, vim_object, properties=None)[source]#

Returns a simple list of objects from a given service instance.

service_instance

The Service Instance for which to obtain a list of objects.

object_type

The type of content for which to obtain information.

properties

An optional list of object properties used to return reference results. If not provided, defaults to name.

saltext.vmware.utils.common.get_service_instance_from_managed_object(mo_ref, name='<unnamed>')[source]#

Retrieves the service instance from a managed object.

me_ref

Reference to a managed object (of type vim.ManagedEntity).

name

Name of managed object. This field is optional.

saltext.vmware.utils.common.get_properties_of_managed_object(mo_ref, properties)[source]#

Returns specific properties of a managed object, retrieved in an optimally.

mo_ref

The managed object reference.

properties

List of properties of the managed object to retrieve.

saltext.vmware.utils.common.get_managed_object_name(mo_ref)[source]#

Returns the name of a managed object. If the name wasn’t found, it returns None.

mo_ref

The managed object reference.

saltext.vmware.utils.common.get_resource_pools(service_instance, resource_pool_names, datacenter_name=None, get_all_resource_pools=False)[source]#

Retrieves resource pool objects

service_instance

The service instance object to query the vCenter

resource_pool_names

Resource pool names

datacenter_name

Name of the datacenter where the resource pool is available

get_all_resource_pools

Boolean

return

Resourcepool managed object reference

saltext.vmware.utils.common.wait_for_task(task, instance_name, task_type, sleep_seconds=1, log_level='debug')[source]#

Waits for a task to be completed.

task

The task to wait for.

instance_name

The name of the ESXi host, vCenter Server, or Virtual Machine that the task is being run on.

task_type

The type of task being performed. Useful information for debugging purposes.

sleep_seconds

The number of seconds to wait before querying the task again. Defaults to 1 second.

log_level

The level at which to log task information. Default is debug, but info is also supported.

saltext.vmware.utils.common.get_parent_type(node, parent_type)[source]#

Return a parent of specified type from a node.

node

Object reference to start at.

parent_type

The vim type of the parent you are searching for.

saltext.vmware.utils.common.get_path(node, service_instance, path='')[source]#

Return a path to root from a node.

node

Object reference to start at.

service_instance

The Service Instance from which to obtain managed object references.

path

Path to node, recursively passed.

saltext.vmware.utils.common.get_datacenters(service_instance, datacenter_names=None, get_all_datacenters=False)[source]#

Returns all datacenters in a vCenter.

service_instance

The Service Instance Object from which to obtain cluster.

datacenter_names

List of datacenter names to filter by. Default value is None.

get_all_datacenters

Flag specifying whether to retrieve all datacenters. Default value is None.

saltext.vmware.utils.common.get_datacenter(service_instance, datacenter_name)[source]#

Returns a vim.Datacenter managed object.

service_instance

The Service Instance Object from which to obtain datacenter.

datacenter_name

The datacenter name

saltext.vmware.utils.common.list_datacenters(service_instance)[source]#

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

service_instance

The Service Instance Object from which to obtain datacenters.

saltext.vmware.utils.common.create_datacenter(service_instance, datacenter_name)[source]#

Creates a datacenter.

New in version 2017.7.0.

service_instance

The Service Instance Object

datacenter_name

The datacenter name

saltext.vmware.utils.common.delete_datacenter(service_instance, datacenter_name)[source]#

Deletes a datacenter.

service_instance

The Service Instance Object

datacenter_name

The datacenter name

saltext.vmware.utils.common.get_parent_of_type(mors, type)[source]#

Finds the first parent of a managed object that matches the type specified.

None is returned if no object is found.

saltext.vmware.utils.common.find_filtered_object(service_instance, datacenter_name=None, cluster_name=None, host_name=None)[source]#

Finds zero or one matching objects: plug in almost any combination of datacenter, cluster, and/or host name.

If cluster_name is passed, datacenter_name must also be passed.

At least one of the optional parameters must be set.

The most specific object will be returned (if you pass host_name and datacenter_name, the host will be returned).

service_instance

The Service Instance Object from which to obtain cluster.

datacenter_name

(Optional) Datacenter name to filter by.

cluster_name

(Optional) Exact cluster name to filter by. If used, datacenter_name is required.

host_name

(Optional) Exact host name name to filter by.

saltext.vmware.utils.common.get_license_mgrs(service_instance, license_mgr_names=None, get_all_license_mgrs=False)[source]#

Returns all license managers in a vCenter.

service_instance

The Service Instance Object from which to obtain cluster.

license_mgr_names

List of license manager names to filter by. Default value is None.

get_all_license_mgrs

Flag specifying whether to retrieve all license managers. Default value is None.

saltext.vmware.utils.common.get_license_mgr(service_instance, license_mgr_name)[source]#

Returns a vim.LicenseAssignmentManager managed object.

service_instance

The Service Instance Object from which to obtain license manager.

license_mgr_name

The license manager name

saltext.vmware.utils.common.list_license_mgrs(service_instance)[source]#

Returns a list of license managers associated with a given service instance.

service_instance

The Service Instance Object from which to obtain license managers.

saltext.vmware.utils.common.deployment_resources(host_name, service_instance)[source]#

Returns the dict representation of deployment resources from given host name.

host_name

The name of the esxi host to obtain esxi reference.