The oslo_vmware.vim_util
Module¶
The VMware API utility module.
-
class
oslo_vmware.vim_util.
WithRetrieval
(vim, retrieve_result)¶ Bases:
object
Context to retrieve results.
This context provides an iterator to retrieve results and cancel (when needed) retrieve operation on __exit__.
Example:
- with WithRetrieval(vim, retrieve_result) as objects:
- for obj in objects:
- # Use obj
-
oslo_vmware.vim_util.
build_object_spec
(client_factory, root_folder, traversal_specs)¶ Builds the object spec.
Parameters: - client_factory – factory to get API input specs
- root_folder – root folder reference; the starting point of traversal
- traversal_specs – filter specs required for traversal
Returns: object spec
-
oslo_vmware.vim_util.
build_property_filter_spec
(client_factory, property_specs, object_specs)¶ Builds the property filter spec.
Parameters: - client_factory – factory to get API input specs
- property_specs – property specs to be collected for filtered objects
- object_specs – object specs to identify objects to be filtered
Returns: property filter spec
-
oslo_vmware.vim_util.
build_property_spec
(client_factory, type_='VirtualMachine', properties_to_collect=None, all_properties=False)¶ Builds the property spec.
Parameters: - client_factory – factory to get API input specs
- type – type of the managed object
- properties_to_collect – names of the managed object properties to be collected while traversal filtering
- all_properties – whether all properties of the managed object need to be collected
Returns: property spec
-
oslo_vmware.vim_util.
build_recursive_traversal_spec
(client_factory)¶ Builds recursive traversal spec to traverse managed object hierarchy.
Parameters: client_factory – factory to get API input specs Returns: recursive traversal spec
-
oslo_vmware.vim_util.
build_selection_spec
(client_factory, name)¶ Builds the selection spec.
Parameters: - client_factory – factory to get API input specs
- name – name for the selection spec
Returns: selection spec
-
oslo_vmware.vim_util.
build_traversal_spec
(client_factory, name, type_, path, skip, select_set)¶ Builds the traversal spec.
Parameters: - client_factory – factory to get API input specs
- name – name for the traversal spec
- type – type of the managed object
- path – property path of the managed object
- skip – whether or not to filter the object identified by param path
- select_set – set of selection specs specifying additional objects to filter
Returns: traversal spec
-
oslo_vmware.vim_util.
cancel_retrieval
(vim, retrieve_result)¶ Cancels the retrieve operation if necessary.
Parameters: - vim – Vim object
- retrieve_result – result of RetrievePropertiesEx API call
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
continue_retrieval
(vim, retrieve_result)¶ Continue retrieving results, if available.
Parameters: - vim – Vim object
- retrieve_result – result of RetrievePropertiesEx API call
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
find_extension
(vim, key)¶ Looks for an existing extension.
Parameters: - vim – Vim object
- key – the key to search for
Returns: the data object Extension or None
-
oslo_vmware.vim_util.
get_http_service_request_spec
(client_factory, method, uri)¶ Build a HTTP service request spec.
Parameters: - client_factory – factory to get API input specs
- method – HTTP method (GET, POST, PUT)
- uri – target URL
-
oslo_vmware.vim_util.
get_inventory_path
(vim, entity_ref, max_objects=100)¶ Get the inventory path of a managed entity.
Parameters: - vim – Vim object
- entity_ref – managed entity reference
- max_objects – maximum number of objects that should be returned in a single call
Returns: inventory path of the entity_ref
-
oslo_vmware.vim_util.
get_moref
(value, type_)¶ Get managed object reference.
Parameters: - value – value of the managed object
- type – type of the managed object
Returns: managed object reference with given value and type
-
oslo_vmware.vim_util.
get_object_properties
(vim, moref, properties_to_collect, skip_op_id=False)¶ Get properties of the given managed object.
Parameters: - vim – Vim object
- moref – managed object reference
- properties_to_collect – names of the managed object properties to be collected
- skip_op_id – whether to skip putting opID in the request
Returns: properties of the given managed object
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
get_object_properties_dict
(vim, moref, properties_to_collect)¶ Get properties of the given managed object as a dict.
Parameters: - vim – Vim object
- moref – managed object reference
- properties_to_collect – names of the managed object properties to be collected
Returns: a dict of properties of the given managed object
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
get_object_property
(vim, moref, property_name, skip_op_id=False)¶ Get property of the given managed object.
Parameters: - vim – Vim object
- moref – managed object reference
- property_name – name of the property to be retrieved
- skip_op_id – whether to skip putting opID in the request
Returns: property of the given managed object
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
get_objects
(vim, type_, max_objects, properties_to_collect=None, all_properties=False)¶ Get all managed object references of the given type.
It is the caller’s responsibility to continue or cancel retrieval.
Parameters: - vim – Vim object
- type – type of the managed object
- max_objects – maximum number of objects that should be returned in a single call
- properties_to_collect – names of the managed object properties to be collected
- all_properties – whether all properties of the managed object need to be collected
Returns: all managed object references of the given type
Raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException
-
oslo_vmware.vim_util.
get_vc_version
(session)¶ Return the dot-separated vCenter version string. For example, “1.2”.
Parameters: session – vCenter soap session Returns: vCenter version
-
oslo_vmware.vim_util.
register_extension
(vim, key, type, label='OpenStack', summary='OpenStack services', version='1.0')¶ Create a new extention.
Parameters: - vim – Vim object
- key – the key for the extension
- type – Managed entity type, as defined by the extension. This matches the type field in the configuration about a virtual machine or vApp
- label – Display label
- summary – Summary description
- version – Extension version number as a dot-separated string