oslovmware(1)

OSLOVMWARE(1) oslo.vmware OSLOVMWARE(1)

NAME

oslovmware - oslo.vmware 4.6.0

The Oslo VMware library provides support for common VMware operations and APIs.

CONTENTS

Installation

At the command line:

$ pip install oslo.vmware


Or, if you have virtualenvwrapper installed:

$ mkvirtualenv oslo.vmware
$ pip install oslo.vmware


Using oslo.vmware

Usage

Example usage of getting a handle to a vSphere session and retrieving all the ESX hosts in a server:

from oslo_vmware import api
from oslo_vmware import vim_util
# Get a handle to a vSphere API session
session = api.VMwareAPISession(

'10.1.2.3', # vSphere host endpoint
'administrator', # vSphere username
'password', # vSphere password
10, # Number of retries for connection failures in tasks
0.1 # Poll interval for async tasks (in seconds) ) # Example call to get all the managed objects of type "HostSystem" # on the server. result = session.invoke_api(
vim_util, # Handle to VIM utility module
'get_objects', # API method name to invoke
session.vim, 'HostSystem', 100) # Params to API method (*args)


CHANGES

4.6.0

  • Skip installation to speed up pep8
  • Run pyupgrade to clean up Python 2 syntaxes
  • Replace deprecated defusedxml.lxml
  • reno: Update master for unmaintained/2023.1
  • pre-commit: Bump versions
  • Add note about requirements lower bounds
  • Remove Python 3.8 support
  • Declare Python 3.12 support
  • Fix wrong tox minversion
  • Update master for stable/2024.2

4.5.0

  • reno: Update master for unmaintained/zed
  • Update master for stable/2024.1
  • reno: Update master for unmaintained/xena
  • reno: Update master for unmaintained/wallaby
  • reno: Update master for unmaintained/victoria

4.4.0

  • reno: Update master for unmaintained/yoga
  • Update python classifier in setup.cfg

4.3.0

  • Imported Translations from Zanata
  • Add PBM WSDL for vSphere 8.0
  • Update master for stable/2023.2

4.2.0

  • Bump bandit and make oslo.messaging compatible with latest rules
  • Imported Translations from Zanata
  • Revert "Moves supported python runtimes from version 3.8 to 3.10"
  • Moves supported python runtimes from version 3.8 to 3.10
  • Update master for stable/2023.1

4.1.1

Fix issues related to tox4

4.1.0

  • Add Python3 antelope unit tests
  • Update master for stable/zed
  • remove unicode literal from code

4.0.1

  • remove unicode literal from code
  • Imported Translations from Zanata
  • Imported Translations from Zanata
  • Fix formatting of release list

4.0.0

  • Download ISO in more simple way
  • Drop python3.6/3.7 support in testing runtime
  • Add Python3 zed unit tests
  • Update master for stable/yoga

3.10.0

  • Replace suds-jurko with suds-community
  • Don't use 'requests.PreparedRequest'
  • Add Python3 yoga unit tests
  • Update master for stable/xena

3.9.1

setup.cfg: Replace dashes with underscores

3.9.0

  • Ignore already deleted lease
  • Remove lower-constraints remnants
  • Add serialize_object() helper function
  • Move flake8 as a pre-commit local target
  • Add Python3 xena unit tests
  • Update master for stable/wallaby

3.8.0

  • Add PBM WSDL for vSphere 7.0
  • Use TOX_CONSTRAINTS_FILE
  • Use py3 as the default runtime for tox
  • Imported Translations from Zanata
  • Add Python3 wallaby unit tests
  • Update master for stable/victoria
  • Adding pre-commit

3.7.0

  • [goal] Migrate testing to ubuntu focal
  • Bump bandit version

3.6.0

Add backend-independent access to cookiejar

3.5.0

Add moref helper functions

3.4.0

  • Validation of VMDK upload completion
  • Fix hacking min version to 3.0.1
  • Imported Translations from Zanata
  • Switch to newer openstackdocstheme and reno versions
  • Remove the unused coding style modules
  • Remove translation sections from setup.cfg
  • Align contributing doc with oslo's policy
  • Bump default tox env from py37 to py38
  • Add py38 package metadata
  • Add release notes links to doc index
  • Add Python3 victoria unit tests
  • Update master for stable/ussuri

3.3.1

  • Use unittest.mock instead of third party mock
  • Document disable flake8/hacking warnings

3.3.0

Update hacking for Python3

3.2.1

  • Fix object has no attribute 'readinto' in Python3
  • Update the tox minversion parameter
  • Pass "base_image_ref" to backend when transfer volume to image
  • Drop use of six

3.2.0

3.1.0

  • remove outdated header
  • Ensure lease polling raises proper exception
  • reword releasenote for py27 support dropping
  • Adds standard file operation functions
  • Add ability to change read chunk size

3.0.0

[ussuri][goal] Drop python 2.7 support and testing

2.35.0

  • Pass "store_id" to backend when transfer volume to image
  • tox: Trivial cleanup
  • Switch to Ussuri jobs
  • tox: Keeping going with docs
  • Update master for stable/train

2.34.1

  • Follow the new PTI for document build
  • Add Python 3 Train unit tests
  • Add local bindep.txt
  • Sync Sphinx requirement

2.34.0

  • Dropping the py35 testing
  • Ensure that log message with non-ascii code does not raise exception
  • Set locale to english
  • Update NFC lease progress
  • Add nosec to skip bandit check
  • Replace git.openstack.org URLs with opendev.org URLs

2.33.0

  • OpenDev Migration Patch
  • When looping call fails do not log the exception trace
  • Fix invalid escape sequence warning
  • Fix doc build error under Python 3
  • Update master for stable/stein
  • Return None if no suitable datastore is found
  • SDRS recommendation for create VM

2.32.2

  • add python 3.7 unit test job
  • Change python3.5 job to python3.7 job on Stein+
  • Use template for lower-constraints
  • Change openstack-dev to openstack-discuss
  • delete useless indent
  • Clean up .gitignore references to personal tools

2.32.1

  • Add DVS utility methods
  • Check if there is a context set before updating the store
  • Imported Translations from Zanata
  • add lib-forward-testing-python3 test job
  • add python 3.6 unit test job
  • Set request context when polling vCenter tasks
  • import zuul job settings from project-config
  • py37: deal with Exception repr changes
  • Update reno for stable/rocky

2.31.0

  • Utility method to check SDRS enabled status
  • Add function for getting recommended datastore
  • Add utility function for datastore clusters
  • Switch to stestr

2.30.0

  • Add release notes link to README
  • Add traversal spec for datastoreFolder
  • Fix docstring which breaks doc generation
  • fix tox python3 overrides

2.29.2

2.29.1

Specify CA store when making secure connections with urllib3

2.29.0

  • Fix session re-establish failure with PBM APIs
  • Refactor _start_transfer
  • PBM WSDL for vSphere 6.7
  • Remove stale pip-missing-reqs tox test
  • fix a typo:s/extention/extension
  • Trivial: Update pypi url to new url
  • set default python to python3

2.28.0

  • fix lower constraints and uncap eventlet
  • Updated from global requirements
  • add lower-constraints job
  • pypy is not checked at gate
  • Updated from global requirements

2.27.0

  • Updated from global requirements
  • Update links in README
  • Updated from global requirements
  • Imported Translations from Zanata
  • Imported Translations from Zanata
  • Update reno for stable/queens
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements

2.26.0

  • Cleanup test-requirements
  • Updated from global requirements
  • Fix the repeating titles

2.25.0

  • Remove -U from pip install
  • Avoid tox_install.sh for constraints support
  • Remove setting of version/release from releasenotes
  • Updated from global requirements
  • Updated from global requirements
  • Imported Translations from Zanata

2.24.0

  • Updated from global requirements
  • Updated from global requirements
  • Imported Translations from Zanata
  • Updated from global requirements
  • Update reno for stable/pike
  • Updated from global requirements

2.23.0

  • Update URLs in documents according to document migration
  • rearrange existing documentation to fit the new standard layout
  • Switch from oslosphinx to openstackdocstheme
  • Enable warning-is-error in doc build
  • Use request_handler() for ExtensionManager APIs
  • Improving cover testenv

2.22.1

Add hacking rule to prevent log translations

2.22.0

Updated from global requirements

2.21.0

  • Do not prune some special XML elements which are empty
  • Updated from global requirements

2.20.0

  • Updated from global requirements
  • Wrong member variable name in class Datastore
  • Make sure host in maintenance mode excluded from image upload
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements

2.19.0

  • Trivial: Remove testscenarios from test-requirements.txt
  • Remove log translations

2.18.0

  • Updated from global requirements
  • [Fix gate]Update test requirement
  • Updated from global requirements
  • Make the mock call in MemoryCacheTest forward-compatible
  • Updated from global requirements
  • Updated from global requirements
  • Improve unit test coverage
  • pbr.version.VersionInfo needs package name (oslo.xyz and not oslo_xyz)
  • Add in support for removeKey
  • Use https for references to openstack.org
  • Update reno for stable/ocata

2.17.0

  • Fix setting the SOAP headers for remote calls
  • Remove references to Python 3.4
  • Updated from global requirements
  • Remove some useless log messages
  • Add operation ID for remote calls
  • Fix image meta-data update for Glance v2
  • Add Constraints support
  • Updated from global requirements

2.16.0

  • Files with no code must be left completely empty
  • Add 'uncommitted' field to the 'Datastore' class
  • Add SPBM WSDL for vSphere 6.5
  • Show team and repo badges on README
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Trivial fixes to the usage doc
  • Imported Translations from Zanata
  • Imported Translations from Zanata
  • Updated from global requirements
  • Remove mox3 in test-requirement.txt
  • [TrivialFix] Replace 'assertTrue(a in b)' with 'assertIn(a, b)'
  • Updated from global requirements

2.15.0

  • Enable release notes translation
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Update home page link in cfg file
  • Updated from global requirements
  • Set pool size for HTTPS connections
  • Update reno for stable/newton
  • Improve logging for task updates

2.14.0

  • Updated from global requirements
  • Fix TypeError:six.StringIO(resp.content) must be str or None, not bytes

2.13.0

  • Method to download file to VMware server
  • Pass connection timeout so that invoke_api will not wait forever

2.12.0

  • Updated from global requirements
  • Add http_method to download_stream_optimized_data
  • Refactor the image transfer
  • Remove discover from test-requirements
  • Updated from global requirements

2.11.0

  • Updated from global requirements
  • Add a py35 tox venv for upcoming py35 support
  • Updated from global requirements
  • Remove unnecessary properties from image-meta
  • Updated from global requirements
  • Updated from global requirements

2.10.0

Updated from global requirements

2.9.0

Imported Translations from Zanata

2.8.0

  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Refactor VmdkWriteHandle and VmdkReadHandle
  • Updated from global requirements
  • Add reno for release notes management
  • Support download of virtual disk in ova container
  • Updated from global requirements
  • Updated from global requirements

2.7.0

  • Updated from global requirements
  • Trivial: ignore openstack/common in flake8 exclude list

2.6.0

  • Updated from global requirements
  • Imported Translations from Zanata
  • Updated from global requirements
  • Updated from global requirements
  • Should not raise Exception before connection close
  • Remove explicit use of asserts
  • Move bandit into pep8

2.5.0

  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements

2.4.0

Updated from global requirements

2.3.0

  • Remove bandit.yaml in favor of defaults
  • Updated from global requirements
  • Update translation setup
  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • Imported Translations from Zanata
  • Updated from global requirements
  • Use oslo_utils reflection to get function name

2.2.1

  • Python 3 deprecated the logger.warn method in favor of warning
  • Put py34 first in the env order of tox
  • assertIsNone(val) instead of assertEqual(None,val)

2.2.0

  • isoformat instead of deprecated timeutils.strtime
  • Overwrite VMwareDriverException message
  • Updated from global requirements
  • Updated from global requirements
  • Clean requirements
  • Trival: Remove 'MANIFEST.in'

2.1.0

Updated from global requirements

2.0.0

  • Updated from global requirements
  • Updated from global requirements
  • Remove python 2.6 classifier
  • Remove python 2.6 and cleanup tox.ini
  • Imported Translations from Zanata
  • Updated from global requirements

1.23.0

Updated from global requirements

1.22.0

  • Updated from global requirements
  • Fix coverage configuration and execution
  • No need for Oslo Incubator Sync
  • Add support for SSL thumbprint when using FileWriteHandle
  • Define WithRetrieval context
  • Imported Translations from Zanata
  • Add shields.io version/downloads links/badges into README.rst
  • docs - Set pbr 'warnerrors' option for doc build
  • clean up auto-doc api build
  • do not show the full release history in the main table of contents
  • clean up readme and documentation titles
  • Change ignore-errors to ignore_errors
  • Updated from global requirements
  • Add support for using HTTP POST in VmdkWriteHandle
  • Add unit tests for FileHandle._create_connection
  • Update the documentation

1.21.0

  • Updated from global requirements
  • Use SSL thumbprints for NFC transfer
  • Updated from global requirements
  • Update bandit.yaml to the latest

1.20.0

  • Updated from global requirements
  • Updated from global requirements
  • Updated from global requirements
  • flake8 - remove unused rules
  • Imported Translations from Transifex
  • Allow http connection pool size to be configured

1.19.0

  • Imported Translations from Transifex
  • Imported Translations from Transifex

1.18.0

  • Make usage doc easier to understand for library consumers
  • Updated from global requirements
  • Imported Translations from Transifex
  • Updated from global requirements
  • Updated from global requirements
  • Remove username from logs
  • Updated from global requirements

1.17.0

  • Update log level of session related logs
  • Fix mock calls
  • Updated from global requirements
  • Mask/truncate vCenter credentials in suds logs
  • Imported Translations from Transifex

1.16.0

  • Add tox target to find missing requirements
  • Updated from global requirements
  • Fix exception to string in py34
  • Updated from global requirements

0.15.0

  • Updated from global requirements
  • Updated from global requirements
  • Add in support for ManagedObjectNotFound exception
  • Deprecate unused exceptions
  • Raise VimFaultException for unknown faults
  • Exception hierarchy refactoring
  • Updated from global requirements
  • Update progress lease every 60 seconds
  • Updated from global requirements
  • Fix bandit tox environment to properly run
  • Updated from global requirements

0.14.0

  • Remove oslo namespace package
  • Port test from Nova
  • Imported Translations from Transifex

0.13.1

  • Imported Translations from Transifex
  • Revert "Raise VimFaultException for unknown faults"

0.13.0

  • Add ToolsUnavailable exception
  • Add support for dynamicProperty
  • Remove support for Python 3.3
  • Updated from global requirements
  • Remove run_cross_tests.sh
  • Use suds-jurko on Python 2
  • Updated from global requirements
  • Imported Translations from Transifex
  • Updated from global requirements
  • Raise VimFaultException for unknown faults
  • Imported Translations from Transifex
  • Add NoDiskSpaceException
  • Add utility function to get profiles by IDs
  • Add bandit to tox for security static analysis
  • Add SPBM WSDL for vSphere 6.0

0.12.0

  • Uncap library requirements for liberty
  • Cleanup README.rst and setup.cfg
  • Update to latest hacking
  • Imported Translations from Transifex
  • Revert "VMWare NSXv: Common components"
  • Updated from global requirements
  • Move pylint dependency to tox.ini
  • Move exception related tests to new module

0.11.1

  • Switch to non-namespaced module imports
  • Imported Translations from Transifex
  • Move missing tests to new oslo_vmware location

0.11.0

  • Imported Translations from Transifex
  • Add get_datastore_by_ref method to oslo.vmware
  • Change use of random to random.SystemRandom

0.10.0

  • Imported Translations from Transifex
  • Updated from global requirements
  • Handle SPBM SecurityError
  • PBM utility method to retrieve profiles of a VM
  • Updated from global requirements
  • Imported Translations from Transifex
  • Add missing links to README
  • VMWare NSXv: Common components

0.9.0

  • Imported Translations from Transifex
  • Updated from global requirements
  • Correct usage to oslo_vmware
  • Fix line wrapping
  • Updated from global requirements
  • Correct the doc usage example
  • Fix missing project name in installation doc
  • Imported Translations from Transifex
  • Imported Translations from Transifex
  • Fix race during session creation
  • Make setup.cfg packages include oslo.vmware
  • Updated from global requirements
  • Move files out of the namespace package
  • Use ToggleLazy fixture from oslo.i18n
  • Use _is_valid_ipv6 from oslo.utils
  • Allow checking api session
  • Updated from global requirements
  • Updated from global requirements
  • Add pbr to installation requirements
  • Update urllib3 requirements
  • Workflow documentation is now in infra-manual
  • Fix re-create session during transient failures
  • Imported Translations from Transifex

0.8.0

  • Switch to use requests/urllib3 and enable cacert validation
  • Updated from global requirements
  • Updated from global requirements
  • Enable support for python 3.x
  • Updated from global requirements

0.7.0

  • Updated from global requirements
  • Imported Translations from Transifex
  • Activate pep8 check that _ is imported
  • Do not log when reraising an exception
  • Imported Translations from Transifex
  • Updated from global requirements
  • Add unit test for VC 5.1 web fault handling
  • Fix to get exception detail with vCenter 5.1
  • Download image API to bypass vCenter
  • Updated from global requirements
  • Updated from global requirements
  • Enable the PBM WSDL to be updated
  • Support building wheels (PEP-427)
  • Fixup autoindex.rst only if it exists
  • Supress error logs when exception is thrown
  • Fix handling of fault details
  • Fix UnboundLocalError during WebFault handling
  • Use faultstring attribute in suds.WebFault.fault
  • Imported Translations from Transifex
  • Fix the log message for progress
  • Add API to get the entity inventory path
  • VimExceptions need to support i18n objects
  • Switch to using oslo.utils
  • Use custom transport adapter for file URLs
  • getText can be called only when doc is not None
  • Updated from global requirements
  • Add unit test for suds cache expiration
  • Add a memory based shared cache

0.6.0

  • Updated from global requirements
  • VMware: Enable vCenter SSL certificate validation
  • Add DuplicateName exception
  • Add 'details' property to VMwareDriverException
  • Enable oslo.i18n for oslo.vmware
  • Add API to enable calling module to register an exception
  • Imported Translations from Transifex
  • Add docs target and generate api docs
  • Updated from global requirements
  • Work toward Python 3.4 support and testing
  • warn against sorting requirements
  • Add exception for TaskInProgress
  • Updated from global requirements
  • Refactoring to reduce noise in log files
  • Imported Translations from Transifex
  • Add missing session parameter to get_summary
  • Updated from global requirements
  • Switch off caching to prevent cache poisoning by local attacker
  • Support for copying streamOptimized disk to file
  • Add support for the DatastoreURL object
  • Add methods to the Datastore objects
  • Imported Translations from Transifex
  • Add Pylint testenv environment

0.5.0

  • _trunc_id to check if the session_id is not None
  • Port the Datastore and DatastorePath objects
  • Log additional details of suds faults
  • Enabled hacking check H305
  • Imported Translations from Transifex
  • Add constant for ESX datacenter path (HTTP access)
  • Store PBM wsdl in the oslo.vmware git repository
  • Bump hacking to version 0.9.2
  • Fix seek and tell in BlockingQueue
  • Add support for using extensions
  • The 'result' variable in RetryDecorator may be undefined
  • Imported Translations from Transifex
  • Fix docstrings of constructors
  • Do not log the full session ID
  • Refactor the PBM support
  • Fix wrong usage of assertRaises
  • Translations: make use of _LE, _LI and _LW

0.4.0

  • Sync excutils from Oslo
  • Updated from global requirements
  • Use assertIsNone
  • Bump hacking to 0.9.x series
  • replace iterator.next() with next(iterator)
  • remove definitions of Python Source Code Encoding
  • Setup for translation
  • Updated from global requirements
  • cleaning up index.rst file
  • Add networkFolder in the traversal spec
  • Ensure port support does not break backward compatibility
  • replace string format arguments with function parameters
  • Support for IPv6 and Non-standard ports
  • Support 'InvalidPowerState' exception
  • Don't translate debug level logs in oslo-vmware
  • Updated from global requirements
  • Sync changes from Nova error_util.py
  • Updated from global requirements
  • Remove __del__ usage in oslo.vmware driver
  • Add a test to oslo.vmware test_image_transfer
  • import run_cross_tests.sh from incubator
  • Fix vim25:InvalidRequest when no profiles exist
  • VMware: treat cases when SOAP reply does not have a body
  • Add unittest method "test_download_flat_image"
  • Add missing unit tests for VMwareAPISession

0.3

  • Updated from global requirements
  • Fix unit tests running unnecessarily slow
  • Enable download of streamOptimized file-like
  • Fix docstrings in VMwareAPISession
  • Ensure that the pbm is not None
  • PBM related utility methods
  • Add PBM client for policy based placement
  • Updated from global requirements
  • Replace unicode() for six.text_type

0.2

  • Remove dependency on log.py from openstack/common
  • Remove vim header

0.1

  • VMware: raise more specific exceptions
  • Move image transfer code in VMware drivers to OSLO
  • Move read/write handles in VMware drivers to OSLO
  • Move API invocation code in VMware drivers to OSLO
  • Move VIM API client code in VMware drivers to OSLO
  • Add eventlet requirement
  • Move utility methods in VMware drivers to OSLO
  • Import necessary files from openstack.common
  • Initial checkin for Oslo VMware Library generated using oslo-cookiecutter

Contributing

If you would like to contribute to the development of oslo's libraries, first you must take a look to this page:

https://specs.openstack.org/openstack/oslo-specs/specs/policy/contributing.html


If you would like to contribute to the development of OpenStack, you must follow the steps in this page:

https://docs.openstack.org/infra/manual/developers.html


Once those steps have been completed, changes to OpenStack should be submitted for review via the Gerrit tool, following the workflow documented at:

https://docs.openstack.org/infra/manual/developers.html#development-workflow


Pull requests submitted through GitHub will be ignored.

Bugs should be filed on Launchpad, not GitHub:

https://bugs.launchpad.net/oslo.vmware


API Reference

oslo_vmware

oslo_vmware package

Subpackages

oslo_vmware.common package

Submodules

oslo_vmware.common.loopingcall module

class oslo_vmware.common.loopingcall.DynamicLoopingCall(f=None, *args, **kw)
Bases: LoopingCallBase

A looping call which sleeps until the next known event.

The function called should return how long to sleep for before being called again.

start(initial_delay=None, periodic_interval_max=None)


class oslo_vmware.common.loopingcall.FixedIntervalLoopingCall(f=None, *args, **kw)
Bases: LoopingCallBase

A fixed interval looping call.

start(interval, initial_delay=None)


oslo_vmware.common.loopingcall.LoopingCall
alias of FixedIntervalLoopingCall

class oslo_vmware.common.loopingcall.LoopingCallBase(f=None, *args, **kw)
Bases: object
stop()

wait()


exception oslo_vmware.common.loopingcall.LoopingCallDone(retvalue=True)
Bases: Exception

Exception to break out and stop a LoopingCall.

The poll-function passed to LoopingCall can raise this exception to break out of the loop normally. This is somewhat analogous to StopIteration.

An optional return-value can be included as the argument to the exception; this return-value will be returned by LoopingCall.wait()


Module contents

oslo_vmware.hacking package

Submodules

oslo_vmware.hacking.checks module

oslo_vmware.hacking.checks.no_translate_logs(logical_line, filename)
N537 - Don't translate logs.

Check for 'LOG.*(_('

Translators don't provide translations for log messages, and operators asked not to translate them.

This check assumes that 'LOG' is a logger.

Parameters
  • logical_line -- The logical line to check.
  • filename -- The file name where the logical line exists.

Returns
None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.


Module contents

oslo_vmware.objects package

Submodules

oslo_vmware.objects.datacenter module

class oslo_vmware.objects.datacenter.Datacenter(ref, name)
Bases: object

oslo_vmware.objects.datastore module

class oslo_vmware.objects.datastore.Datastore(ref, name, capacity=None, freespace=None, uncommitted=None, type=None, datacenter=None)
Bases: object
build_path(*paths)
Constructs and returns a DatastorePath.
Parameters
paths -- list of path components, for constructing a path relative to the root directory of the datastore
Returns
a DatastorePath object


build_url(scheme, server, rel_path, datacenter_name=None)
Constructs and returns a DatastoreURL.
Parameters
  • scheme -- scheme of the URL (http, https).
  • server -- hostname or ip
  • rel_path -- relative path of the file on the datastore
  • datacenter_name -- (optional) datacenter name

Returns
a DatastoreURL object


static choose_host(hosts)

get_connected_hosts(session)
Get a list of usable (accessible, mounted, read-writable) hosts where the datastore is mounted.
Param
session: session
Returns
list of HostSystem managed object references


get_summary(session)
Get datastore summary.
Parameters
datastore -- Reference to the datastore
Returns
'summary' property of the datastore


static is_datastore_mount_usable(mount_info)
Check if a datastore is usable as per the given mount info.

The datastore is considered to be usable for a host only if it is writable, mounted and accessible.

Parameters
mount_info -- HostMountInfo data object
Returns
True if datastore is usable



class oslo_vmware.objects.datastore.DatastorePath(datastore_name, *paths)
Bases: object

Class for representing a directory or file path in a vSphere datatore.

This provides various helper methods to access components and useful variants of the datastore path.

Example usage:

DatastorePath("datastore1", "_base/foo", "foo.vmdk") creates an object that describes the "[datastore1] _base/foo/foo.vmdk" datastore file path to a virtual disk.

Note:

  • Datastore path representations always uses forward slash as separator (hence the use of the posixpath module).
  • Datastore names are enclosed in square brackets.
  • Path part of datastore path is relative to the root directory of the datastore, and is always separated from the [ds_name] part with a single space.

property basename

property datastore

property dirname

join(*paths)
Join one or more path components intelligently into a datastore path.

If any component is an absolute path, all previous components are thrown away, and joining continues. The return value is the concatenation of the paths with exactly one slash ('/') inserted between components, unless p is empty.

Returns
A datastore path


property parent

classmethod parse(datastore_path)
Constructs a DatastorePath object given a datastore path string.

property rel_path


class oslo_vmware.objects.datastore.DatastoreURL(scheme, server, path, datacenter_path, datastore_name)
Bases: object

Class for representing a URL to HTTP access a file in a datastore.

This provides various helper methods to access components and useful variants of the datastore URL.

connect(method, content_length, cookie)

property datacenter_path

property datastore_name

get_transfer_ticket(session, method)

property path

classmethod urlparse(url)


oslo_vmware.objects.datastore.get_datastore_by_ref(session, ds_ref)
Returns a datastore object for a given reference.
Parameters
  • session -- a vmware api session object
  • ds_ref -- managed object reference of a datastore

Return type
a datastore object


oslo_vmware.objects.datastore.get_dsc_ref_and_name(session, dsc_val)
Return reference and name of the specified datastore cluster.
Parameters
ds_val -- datastore cluster name or datastore cluster moid
Returns
tuple of dastastore cluster moref and datastore cluster name



Returns a key which identifies the most recommended datastore from the specified datastore cluster where the specified VM can be cloned to.

Returns SDRS recommendation key for creating a VM.

oslo_vmware.objects.datastore.sdrs_enabled(session, dsc_ref)
Check if Storage DRS is enabled for the given datastore cluster.
Parameters
  • session -- VMwareAPISession object
  • dsc_ref -- datastore cluster moref



Module contents

Submodules

oslo_vmware.api module

Session and API call management for VMware ESX/VC server.

This module contains classes to invoke VIM APIs. It supports automatic session re-establishment and retry of API invocations in case of connection problems or server API call overload.

class oslo_vmware.api.RetryDecorator(max_retry_count=-1, inc_sleep_time=10, max_sleep_time=60, exceptions=())
Bases: object

Decorator for retrying a function upon suggested exceptions.

The decorated function is retried for the given number of times, and the sleep time between the retries is incremented until max sleep time is reached. If the max retry count is set to -1, then the decorated function is invoked indefinitely until an exception is thrown, and the caught exception is not in the list of suggested exceptions.


class oslo_vmware.api.VMwareAPISession(host, server_username, server_password, api_retry_count, task_poll_interval, scheme='https', create_session=True, wsdl_loc=None, pbm_wsdl_loc=None, port=443, cacert=None, insecure=True, pool_size=10, connection_timeout=None, op_id_prefix='oslo.vmware')
Bases: object

Setup a session with the server and handles all calls made to it.

Example:
api_session = VMwareAPISession('10.1.2.3', 'administrator',
'password', 10, 0.1, create_session=False, port=443)
result = api_session.invoke_api(vim_util, 'get_objects',
api_session.vim, 'HostSystem', 100)


invoke_api(module, method, *args, **kwargs)
Wrapper method for invoking APIs.

The API call is retried in the event of exceptions due to session overload or connection problems.

Parameters
  • module -- module corresponding to the VIM API call
  • method -- method in the module which corresponds to the VIM API call
  • args -- arguments to the method
  • kwargs -- keyword arguments to the method

Returns
response from the API call
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


is_current_session_active()
Check if current session is active.
Returns
True if the session is active; False otherwise


logout()
Log out and terminate the current session.

property pbm

pbm_wsdl_loc_set(pbm_wsdl_loc)

property vim

wait_for_lease_ready(lease)
Waits for the given lease to be ready.

This method return when the lease is ready. In case of any error, appropriate exception is raised.

Parameters
lease -- lease to be checked for
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


wait_for_task(task)
Waits for the given task to complete and returns the result.

The task is polled until it is done. The method returns the task information upon successful completion. In case of any error, appropriate exception is raised.

Parameters
task -- managed object reference of the task
Returns
task info upon successful completion of the task
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException



oslo_vmware.constants module

Shared constants across the VMware ecosystem.

oslo_vmware.dvs_util module

oslo_vmware.dvs_util.add_port_group(session, dvs_moref, name, vlan_id=None, trunk_mode=False)
Add a new port group to the dvs_moref
Parameters
  • session -- vCenter soap session
  • dvs_moref -- managed DVS object reference
  • name -- the name of the port group
  • vlan_id -- vlan_id for the port
  • trunk_mode -- indicates if the port will have trunk mode or use specific tag above

Returns
The new portgroup moref


oslo_vmware.dvs_util.delete_port_group(session, portgroup_moref)
Delete a specific port group
Parameters
  • session -- vCenter soap session
  • portgroup_moref -- managed portgroup object reference



oslo_vmware.dvs_util.get_dvs_moref(value)
Get managed DVS object reference.
Parameters
value -- value of the DVS managed object
Returns
managed object reference with given value and type 'VmwareDistributedVirtualSwitch'


oslo_vmware.dvs_util.get_port_group_spec(session, name, vlan_id, trunk_mode=False)
Gets the port group spec for a distributed port group
Parameters
  • session -- vCenter soap session
  • name -- the name of the port group
  • vlan_id -- vlan_id for the port
  • trunk_mode -- indicates if the port will have trunk mode or use specific tag above

Returns
The configuration for a port group.


oslo_vmware.dvs_util.get_portgroups(session, dvs_moref)
Gets all configured portgroups on the dvs_moref
Parameters
  • session -- vCenter soap session
  • dvs_moref -- managed DVS object reference

Returns
List of tuples that have the following format: (portgroup name, port group moref)


oslo_vmware.dvs_util.get_trunk_vlan_spec(session, start=0, end=4094)
Gets portgroup trunk vlan spec.
Parameters
  • session -- vCenter soap session
  • start -- the starting id
  • end -- then end id

Returns
The configuration when a port uses trunk mode. This allows a guest to manage the vlan id.


oslo_vmware.dvs_util.get_vlan_spec(session, vlan_id)
Gets portgroup vlan spec.
Parameters
  • session -- vCenter soap session
  • vlan_id -- the vlan_id for the port

Returns
The configuration when a single vlan_id is used for a port


oslo_vmware.exceptions module

Exception definitions.

exception oslo_vmware.exceptions.AlreadyExistsException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 409

msg_fmt = 'Resource already exists.'


exception oslo_vmware.exceptions.CannotDeleteFileException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 403

msg_fmt = 'Cannot delete file.'


exception oslo_vmware.exceptions.DuplicateName(message=None, cause=None, details=None, **kwargs)
Bases: VimException
msg_fmt = 'Duplicate name.'


exception oslo_vmware.exceptions.FileAlreadyExistsException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 409

msg_fmt = 'File already exists.'


exception oslo_vmware.exceptions.FileFaultException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 409

msg_fmt = 'File fault.'


exception oslo_vmware.exceptions.FileLockedException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 403

msg_fmt = 'File locked.'


exception oslo_vmware.exceptions.FileNotFoundException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 404

msg_fmt = 'File not found.'


exception oslo_vmware.exceptions.ImageTransferException(message, cause=None)
Bases: VMwareDriverException

Thrown when there is an error during image transfer.


exception oslo_vmware.exceptions.InvalidPowerStateException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 409

msg_fmt = 'Invalid power state.'


exception oslo_vmware.exceptions.InvalidPropertyException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 400

msg_fmt = 'Invalid property.'


exception oslo_vmware.exceptions.ManagedObjectNotFoundException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 404

msg_fmt = 'Managed object not found.'


exception oslo_vmware.exceptions.MissingParameter(message=None, details=None, **kwargs)
Bases: VMwareDriverException
msg_fmt = 'Missing parameter : %(param)s'


exception oslo_vmware.exceptions.NoDiskSpaceException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
msg_fmt = 'Insufficient disk space.'


exception oslo_vmware.exceptions.NoPermissionException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 403

msg_fmt = 'No Permission.'


exception oslo_vmware.exceptions.NotAuthenticatedException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
code = 403

msg_fmt = 'Not Authenticated.'


exception oslo_vmware.exceptions.TaskInProgress(message=None, cause=None, details=None, **kwargs)
Bases: VimException
msg_fmt = 'Entity has another operation in process.'


exception oslo_vmware.exceptions.ToolsUnavailableException(message=None, cause=None, details=None, **kwargs)
Bases: VimException
msg_fmt = 'VMware Tools is not running.'


exception oslo_vmware.exceptions.UseLinkedCloneConfigurationFault(message=None, details=None, **kwargs)
Bases: VMwareDriverConfigurationException
msg_fmt = 'No default value for use_linked_clone found.'


exception oslo_vmware.exceptions.VMwareDriverConfigurationException(message=None, details=None, **kwargs)
Bases: VMwareDriverException

Base class for all configuration exceptions.

msg_fmt = 'VMware Driver configuration fault.'


exception oslo_vmware.exceptions.VMwareDriverException(message=None, details=None, **kwargs)
Bases: Exception

Base oslo.vmware exception

To correctly use this class, inherit from it and define a 'msg_fmt' property. That msg_fmt will get printf'd with the keyword arguments provided to the constructor.

property description

property msg

msg_fmt = 'An unknown exception occurred.'


exception oslo_vmware.exceptions.VimAttributeException(message, cause=None)
Bases: VMwareDriverException

Thrown when a particular attribute cannot be found.


exception oslo_vmware.exceptions.VimConnectionException(message, cause=None)
Bases: VMwareDriverException

Thrown when there is a connection problem.


exception oslo_vmware.exceptions.VimException(message=None, cause=None, details=None, **kwargs)
Bases: VMwareDriverException

The base exception class for all VIM related exceptions.


exception oslo_vmware.exceptions.VimFaultException(fault_list, message, cause=None, details=None)
Bases: VimException

Exception thrown when there are unrecognized VIM faults.

property description


exception oslo_vmware.exceptions.VimSessionOverLoadException(message, cause=None)
Bases: VMwareDriverException

Thrown when there is an API call overload at the VMware server.


oslo_vmware.exceptions.get_fault_class(name)
Get a named subclass of VimException.

oslo_vmware.exceptions.register_fault_class(name, exception)

oslo_vmware.exceptions.translate_fault(localized_method_fault, excep_msg=None)
Produce proper VimException subclass object,

The exception is based on a vmodl.LocalizedMethodFault.

Parameters
excep_msg -- Message to set to the exception. Defaults to localizedMessage of the fault.


oslo_vmware.image_transfer module

Functions and classes for image transfer between ESX/VC & image service.

oslo_vmware.image_transfer.copy_stream_optimized_disk(context, timeout_secs, write_handle, **kwargs)
Copy virtual disk from VMware server to the given write handle.
Parameters
  • context -- context
  • timeout_secs -- time in seconds to wait for the copy to complete
  • write_handle -- copy destination
  • kwargs -- keyword arguments to configure the source VMDK read handle

Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError


oslo_vmware.image_transfer.download_file(read_handle, host, port, dc_name, ds_name, cookies, upload_file_path, file_size, cacerts, timeout_secs)
Download file to VMware server.
Parameters
  • read_handle -- file read handle
  • host -- VMware server host name or IP address
  • port -- VMware server port number
  • dc_name -- name of the datacenter which contains the destination datastore
  • ds_name -- name of the destination datastore
  • cookies -- cookies to build the cookie header while establishing http connection with VMware server
  • upload_file_path -- destination datastore file path
  • file_size -- source file size
  • cacerts -- CA bundle file to use for SSL verification
  • timeout_secs -- timeout in seconds to wait for the download to complete



oslo_vmware.image_transfer.download_flat_image(context, timeout_secs, image_service, image_id, **kwargs)
Download flat image from the image service to VMware server.
Parameters
  • context -- image service write context
  • timeout_secs -- time in seconds to wait for the download to complete
  • image_service -- image service handle
  • image_id -- ID of the image to be downloaded
  • kwargs -- keyword arguments to configure the destination file write handle

Raises
VimConnectionException, ImageTransferException, ValueError


oslo_vmware.image_transfer.download_image(image, image_meta, session, datastore, rel_path, bypass=True, timeout_secs=7200)
Transfer an image to a datastore.
Parameters
  • image -- file-like iterator
  • image_meta -- image metadata
  • session -- VMwareAPISession object
  • datastore -- Datastore object
  • rel_path -- path where the file will be stored in the datastore
  • bypass -- if set to True, bypass vCenter to download the image
  • timeout_secs -- time in seconds to wait for the xfer to complete



oslo_vmware.image_transfer.download_stream_optimized_data(context, timeout_secs, read_handle, **kwargs)
Download stream optimized data to VMware server.
Parameters
  • context -- image service write context
  • timeout_secs -- time in seconds to wait for the download to complete
  • read_handle -- handle from which to read the image data
  • kwargs -- keyword arguments to configure the destination VMDK write handle

Returns
managed object reference of the VM created for import to VMware server
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError


oslo_vmware.image_transfer.download_stream_optimized_image(context, timeout_secs, image_service, image_id, **kwargs)
Download stream optimized image from image service to VMware server.
Parameters
  • context -- image service write context
  • timeout_secs -- time in seconds to wait for the download to complete
  • image_service -- image service handle
  • image_id -- ID of the image to be downloaded
  • kwargs -- keyword arguments to configure the destination VMDK write handle

Returns
managed object reference of the VM created for import to VMware server
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError


oslo_vmware.image_transfer.upload_image(context, timeout_secs, image_service, image_id, owner_id, **kwargs)
Upload the VM's disk file to image service.
Parameters
  • context -- image service write context
  • timeout_secs -- time in seconds to wait for the upload to complete
  • image_service -- image service handle
  • image_id -- upload destination image ID
  • kwargs -- keyword arguments to configure the source VMDK read handle

Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError


oslo_vmware.image_util module

oslo_vmware.image_util.get_vmdk_name_from_ovf(ovf_handle)
Get the vmdk name from the given ovf descriptor.

oslo_vmware.pbm module

VMware PBM service client and PBM related utility methods

PBM is used for policy based placement in VMware datastores. Refer http://goo.gl/GR2o6U for more details.

class oslo_vmware.pbm.Pbm(protocol='https', host='localhost', port=443, wsdl_url=None, cacert=None, insecure=True, pool_maxsize=10, connection_timeout=None, op_id_prefix='oslo.vmware')
Bases: Service

Service class that provides access to the Storage Policy API.

retrieve_service_content()

set_soap_cookie(cookie)
Set the specified vCenter session cookie in the SOAP header
Parameters
cookie -- cookie to set



oslo_vmware.pbm.convert_datastores_to_hubs(pbm_client_factory, datastores)
Convert given datastore morefs to PbmPlacementHub morefs.
Parameters
  • pbm_client_factory -- Factory to create PBM API input specs
  • datastores -- list of datastore morefs

Returns
list of PbmPlacementHub morefs


oslo_vmware.pbm.filter_datastores_by_hubs(hubs, datastores)
Get filtered subset of datastores corresponding to the given hub list.
Parameters
  • hubs -- list of PbmPlacementHub morefs
  • datastores -- all candidate datastores

Returns
subset of datastores corresponding to the given hub list


oslo_vmware.pbm.filter_hubs_by_profile(session, hubs, profile_id)
Filter and return hubs that match the given profile.
Parameters
  • hubs -- PbmPlacementHub morefs
  • profile_id -- profile ID

Returns
subset of hubs that match the given profile
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


oslo_vmware.pbm.get_all_profiles(session)
Get all the profiles defined in VC server.
Returns
PbmProfile data objects
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


oslo_vmware.pbm.get_pbm_wsdl_location(vc_version)
Return PBM WSDL file location corresponding to VC version.
Parameters
vc_version -- a dot-separated version string. For example, "1.2".
Returns
the pbm wsdl file location.


oslo_vmware.pbm.get_profile_id_by_name(session, profile_name)
Get the profile UUID corresponding to the given profile name.
Parameters
profile_name -- profile name whose UUID needs to be retrieved
Returns
profile UUID string or None if profile not found
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


oslo_vmware.pbm.get_profiles(session, vm)
Query storage profiles associated with the given vm.
Parameters
  • session -- VMwareAPISession instance
  • vm -- vm reference

Returns
profile IDs


oslo_vmware.pbm.get_profiles_by_ids(session, profile_ids)
Get storage profiles by IDs.
Parameters
  • session -- VMwareAPISession instance
  • profile_ids -- profile IDs

Returns
profile objects


oslo_vmware.rw_handles module

Classes defining read and write handles for image transfer.

This module defines various classes for reading and writing files including VMDK files in VMware servers. It also contains a class to read images from glance server.

class oslo_vmware.rw_handles.FileHandle(file_handle)
Bases: object

Base class for VMware server file (including VMDK) access over HTTP.

This class wraps a backing file handle and provides utility methods for various sub-classes.

close()
Close the file handle.

fileno()
returns the integer file descriptor by default this is not supported and raises IOError

flush()
flushes the internal buffer

get_size()
Get size of the file to be read.
Raises
NotImplementedError


read(chunk_size)
Read a chunk of data.
Parameters
chunk_size -- read chunk size
Raises
NotImplementedError


seek(offset)
sets the file's current position at the offset
Parameters
offset -- offset


tell()
Get the position of File Handle
Returns
position


write(data)
Write data to the file.
Parameters
data -- data to be written
Raises
NotImplementedError



class oslo_vmware.rw_handles.FileReadHandle(host_or_url, port=None, data_center_name=None, datastore_name=None, cookies=None, file_path=None, scheme='https', cacerts=False, thumbprint=None)
Bases: FileHandle

Read handle for a file in VMware server.

close()
Closes the connection.

get_size()
Get size of the file to be read.
Raises
NotImplementedError


read(length)
Read data from the file. :param length: amount of data to be read :raises: VimConnectionException, VimException


class oslo_vmware.rw_handles.FileWriteHandle(host_or_url, port=None, data_center_name=None, datastore_name=None, cookies=None, file_path=None, file_size=None, scheme='https', cacerts=False, thumbprint=None)
Bases: FileHandle

Write handle for a file in VMware server.

close()
Get the response and close the connection.

write(data)
Write data to the file.
Parameters
data -- data to be written
Raises
VimConnectionException, VimException



class oslo_vmware.rw_handles.ImageReadHandle(glance_read_iter)
Bases: object

Read handle for glance images.

close()
Close the read handle.

This is a NOP.


get_next()
Get the next item from the image iterator.

read(chunk_size)
Read an item from the image data iterator.

The input chunk size is ignored since the client ImageBodyIterator uses its own chunk size.



class oslo_vmware.rw_handles.VmdkHandle(session, lease, url, file_handle)
Bases: FileHandle

VMDK handle based on HttpNfcLease.

update_progress()
Updates progress to lease.

This call back to the lease is essential to keep the lease alive across long running write/read operations.

Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException



class oslo_vmware.rw_handles.VmdkReadHandle(session, host, port, vm_ref, vmdk_path, vmdk_size)
Bases: VmdkHandle

VMDK read handle based on HttpNfcLease.

close()
Releases the lease and close the connection.
Raises
VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException


read(chunk_size=65536)
Read a chunk of data from the VMDK file.
Parameters
chunk_size -- size of read chunk
Returns
the data
Raises
VimException


tell()
Get the position of File Handle
Returns
position



class oslo_vmware.rw_handles.VmdkWriteHandle(session, host, port, rp_ref, vm_folder_ref, import_spec, vmdk_size, http_method='PUT')
Bases: VmdkHandle

VMDK write handle based on HttpNfcLease.

This class creates a vApp in the specified resource pool and uploads the virtual disk contents.

close()
Releases the lease and close the connection.
Raises
VimAttributeException, VimSessionOverLoadException, VimConnectionException


get_imported_vm()
"Get managed object reference of the VM created for import.
Raises
VimException


tell()
Get the position of File Handle
Returns
position


write(data)
Write data to the file.
Parameters
data -- data to be written
Raises
VimConnectionException, VimException



oslo_vmware.service module

Common classes that provide access to vSphere services.

class oslo_vmware.service.CompatibilitySudsClient(*args, **kwargs)
Bases: Client

suds client with added cookiejar attribute

The cookiejar properties allow reading/setting the cookiejar used by the underlying transport.

property cookiejar


class oslo_vmware.service.LocalFileAdapter(pool_maxsize=10)
Bases: HTTPAdapter

Transport adapter for local files.

See http://stackoverflow.com/a/22989322

send(request, stream=False, timeout=None, verify=True, cert=None, proxies=None)
Sends request for a local file.


class oslo_vmware.service.MemoryCache
Bases: ObjectCache
get(key)
Retrieves the value for a key or None.

put(key, value, time=3600)
Sets the value for a key.


class oslo_vmware.service.RequestsTransport(cacert=None, insecure=True, pool_maxsize=10, connection_timeout=None)
Bases: Transport
open(request)
Open the url in the specified request. @param request: A transport request. @type request: L{Request} @return: An input stream. @rtype: stream @raise TransportError: On all transport errors.

send(request)
Send soap message. Implementations are expected to handle:
  • proxies
  • I{http} headers
  • cookies
  • sending message
  • brokering exceptions into L{TransportError}


@param request: A transport request. @type request: L{Request} @return: The reply @rtype: L{Reply} @raise TransportError: On all transport errors.



class oslo_vmware.service.Response(stream, status=200, headers=None)
Bases: BytesIO

Response with an input stream as source.

get_all(name, default)

getheaders(name)

info()

property msg

read(chunk_size, **kwargs)
Read at most size bytes, returned as a bytes object.

If the size argument is negative, read until EOF is reached. Return an empty bytes object at EOF.


release_conn()


class oslo_vmware.service.Service(wsdl_url=None, soap_url=None, cacert=None, insecure=True, pool_maxsize=10, connection_timeout=None, op_id_prefix='oslo.vmware')
Bases: object

Base class containing common functionality for invoking vSphere services

static build_base_url(protocol, host, port)

get_http_cookie()
Return the vCenter session cookie.

property service_content


class oslo_vmware.service.ServiceMessagePlugin
Bases: MessagePlugin

Suds plug-in handling some special cases while calling VI SDK.

EMPTY_ELEMENTS = ['VirtualMachineEmptyProfileSpec']

add_attribute_for_value(node)
Helper to handle AnyType.

Suds does not handle AnyType properly. But VI SDK requires type attribute to be set when AnyType is used.

Parameters
node -- XML value node


marshalled(context)
Modifies the envelope document before it is sent.

This method provides the plug-in with the opportunity to prune empty nodes and fix nodes before sending it to the server.

Parameters
context -- send context


prune(el)


class oslo_vmware.service.SudsLogFilter(name='')
Bases: Filter

Filter to mask/truncate vCenter credentials in suds logs.

filter(record)
Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.



oslo_vmware.version module

oslo_vmware.vim module

class oslo_vmware.vim.Vim(protocol='https', host='localhost', port=None, wsdl_url=None, cacert=None, insecure=True, pool_maxsize=10, connection_timeout=None, op_id_prefix='oslo.vmware')
Bases: Service

Service class that provides access to the VIM API.

retrieve_service_content()


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_moref_type(moref)
Get the type of a managed object reference

This function accepts a string representation of a ManagedObjectReference like VirtualMachine:vm-123, but is also able to extract it from the actual object as returned by the API.


oslo_vmware.vim_util.get_moref_value(moref)
Get the value/id of a managed object reference

This function accepts a string representation of a ManagedObjectReference like VirtualMachine:vm-123 or only vm-123, but is also able to extract it from the actual object as returned by the API.


oslo_vmware.vim_util.get_obj_spec(client_factory, obj, select_set=None)
Builds the Object Spec object.

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_prop_filter_spec(client_factory, obj_spec, prop_spec)
Builds the Property Filter Spec Object.

oslo_vmware.vim_util.get_prop_spec(client_factory, spec_type, properties)
Builds the Property Spec Object.

oslo_vmware.vim_util.get_properties_for_a_collection_of_objects(vim, type_, obj_list, properties, max_objects=None)
Gets the list of properties for the collection of objects of the type specified.

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.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


oslo_vmware.vim_util.register_extension(vim, key, type, label='OpenStack', summary='OpenStack services', version='1.0')
Create a new extension.
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



oslo_vmware.vim_util.serialize_object(obj)
Convert Suds object into serializable format - a dict.

oslo_vmware.vim_util.storage_placement_spec(client_factory, dsc_ref, type, clone_spec=None, config_spec=None, relocate_spec=None, vm_ref=None, folder=None, clone_name=None, res_pool_ref=None, host_ref=None)

Module contents

RELEASE NOTES

Read also the oslo.vmware Release Notes.

INDICES AND TABLES

  • Index
  • Module Index
  • Search Page

AUTHOR

Author name not set

COPYRIGHT

2025, OpenStack Foundation

April 2, 2025 4.6.0