VMware vAPI Runtime
raw JSON → 9.0.0.0 verified Mon Apr 27 auth: no python
VMware vAPI Runtime library provides the core infrastructure for consuming VMware vSphere Automation and Cloud Foundation APIs. Current version 2.61.2. Release cadence is tied to VMware SDK releases, approximately quarterly.
pip install vmware-vapi-runtime Common errors
error ImportError: No module named vapi ↓
cause Package namespace changed from 'vapi' to 'vmware.vapi' in version 9.0.0.0.
fix
Update imports to 'from vmware.vapi...'
error ModuleNotFoundError: No module named 'vmware.vapi.vsphere.client' ↓
cause The helper module was introduced in 9.0.0.0; older versions require manual client construction.
fix
Upgrade to vmware-vapi-runtime >=9.0.0.0 or use older import pattern: from vmware.vapi.core import StubConfiguration
error suds.WebFault: Server raised fault: 'The request requires user authentication.' ↓
cause Authentication context not properly set or credentials missing.
fix
Ensure correct security context is attached: e.g., create_user_password_security_context(username, password)
Warnings
breaking In version 9.0.0.0, the package namespace changed from `vapi` to `vmware.vapi`. All imports must be updated. ↓
fix Replace 'from vapi...' with 'from vmware.vapi...'
breaking The `create_vsphere_client` helper function was added in 9.0.0.0, replacing manual StubConfiguration setup. ↓
fix Use `from vmware.vapi.vsphere.client import create_vsphere_client`
deprecated SOAP-based API calls via `suds` are deprecated and will be removed in future releases. ↓
fix Migrate to REST API calls using requests library.
Imports
- VapiClient wrong
from vapi.client import VapiClientcorrectfrom vmware.vapi.vsphere.client import VapiClient - StubConfiguration wrong
from vapi.core import StubConfigurationcorrectfrom vmware.vapi.core import StubConfiguration - SecurityContext wrong
from vapi.security import SecurityContextcorrectfrom vmware.vapi.security import SecurityContext
Quickstart
import os
from vmware.vapi.vsphere.client import create_vsphere_client
from vmware.vapi.security.user_password import create_user_password_security_context
# Authentication
username = os.environ.get('VSPHERE_USER', 'administrator@vsphere.local')
password = os.environ.get('VSPHERE_PASSWORD', '')
server = os.environ.get('VSPHERE_SERVER', 'vcenter.example.com')
security_context = create_user_password_security_context(username, password)
client = create_vsphere_client(server=server, username=username, password=password)
# List VMs
vm_list = client.vcenter.VM.list()
print(vm_list)