Oslo VMware
raw JSON → 4.9.0 verified Fri May 01 auth: no python
The Oslo VMware library provides common VMware-related utilities and API interaction patterns for OpenStack projects. It wraps the pyVmomi library for vSphere API access, offering simplified authentication, session management, and operations like VM creation, datastore management, and network configuration. Current version 4.9.0 requires Python >=3.10. Release cadence is tied to OpenStack releases, typically one per cycle.
pip install oslo.vmware Common errors
error ModuleNotFoundError: No module named 'oslo.vmware' ↓
cause Package name changed from dotted to underscore notation in version 4.0.0.
fix
Install 'oslo.vmware' via pip and import using 'oslo_vmware' (e.g., 'from oslo_vmware import VMwareAPISession').
error ModuleNotFoundError: No module named 'oslo_vmware' ↓
cause Library not installed or installed as 'oslo-vmware' on PyPI but the importable package is 'oslo_vmware'.
fix
Run 'pip install oslo.vmware' (with a dot, not a hyphen) to install the package, then import as 'oslo_vmware'.
error AttributeError: 'NoneType' object has no attribute 'xxx' ↓
cause The VSphere API returned None for a managed object due to invalid credentials or missing permissions.
fix
Double-check credentials host, username, password and ensure the user has the necessary vSphere privileges.
error ConnectionError: Failed to connect to vCenter ↓
cause Network unreachable or vCenter not running at the given host.
fix
Verify the VSPHERE_HOST URL (e.g., 'https://vcsa.domain.com/sdk') and ensure network connectivity.
error ValueError: Invalid argument 'insecure' ↓
cause Using the deprecated 'insecure' parameter removed in newer versions.
fix
Replace 'insecure=True' with 'ca_file=None' or provide a proper CA bundle path.
Warnings
breaking In oslo_vmware 4.x, the import path changed from oslo.vmware to oslo_vmware. Code using the old dotted import will raise ModuleNotFoundError. ↓
fix Replace 'from oslo.vmware import ...' with 'from oslo_vmware import ...'.
breaking The minimum required Python version is now 3.10. Older Python versions are unsupported. ↓
fix Upgrade Python to 3.10 or later.
deprecated Support for the 'insecure' parameter in VMwareAPISession is deprecated. Use the 'ca_file' parameter with a CA bundle instead. ↓
fix Replace 'insecure=True' with 'ca_file="/path/to/ca.crt"' or set the corresponding environment variable.
gotcha Session creation fails without proper credentials. Ensure VSPHERE_HOST, VSPHERE_USER, and VSPHERE_PASSWORD are set in the environment, or pass them directly. ↓
fix Check that environment variables are defined or provide arguments to VMwareAPISession.
Imports
- VMwareAPISession wrong
from oslo.vmware import VMwareAPISessioncorrectfrom oslo_vmware import VMwareAPISession - get_http wrong
from oslo.vmware import get_httpcorrectfrom oslo_vmware import get_http
Quickstart
import os.environ
from oslo_vmware import VMwareAPISession
session = VMwareAPISession(
host=os.environ.get('VSPHERE_HOST', ''),
username=os.environ.get('VSPHERE_USER', ''),
password=os.environ.get('VSPHERE_PASSWORD', ''),
api_retry_count=5,
task_poll_interval=1.0
)
print('Connected to vSphere')