saltext.vcf.utils.vim¶
vSphere SOAP/VMODL connection helpers (pyVmomi).
Used for capabilities that vSphere REST doesn’t yet expose — vSAN imperative ops, Auto Deploy, Fault Tolerance, PerfManager historical counters, PropertyCollector real-time subscriptions, AlarmManager authoring, ExtensionManager, LicenseAssignmentManager, PBM policy authoring.
The pyvmomi package is a hard dependency of saltext-vcf. Connect
to vCenter (or directly to an ESXi host) once per (host, username) pair
and cache the ServiceInstance. Modules call get_service_instance()
and operate on si.content to reach the various managers.
Config is read from Salt opts/pillar under the same saltext.vcf.vcenter
key as utils/vcenter (REST), so REST and SOAP modules share one
credential block:
saltext.vcf:
vcenter:
host: mgmt-vc.vcf.nimbus.internal
username: administrator@vsphere.local
password: VMware123!VMware123!
verify_ssl: false
- saltext.vcf.utils.vim.get_config(opts, profile=None)[source]¶
SOAP shares the REST vCenter config — no separate pillar key.
- saltext.vcf.utils.vim.get_service_instance(opts, profile=None)[source]¶
Return a connected pyVmomi
ServiceInstance.Cached per
(host, username). Useinvalidate_service_instanceto force a fresh connection (e.g. after a session timeout).
- saltext.vcf.utils.vim.invalidate_service_instance(opts, profile=None)[source]¶
Disconnect and drop the cached ServiceInstance for this target.
- saltext.vcf.utils.vim.content(opts, profile=None)[source]¶
Shortcut:
get_service_instance(opts).RetrieveContent().
- saltext.vcf.utils.vim.wait_for_task(task, *, timeout=300, poll_interval=0.5)[source]¶
Block until a pyVmomi
*_Taskfinishes, then returntask.info.result.pyVmomi’s
*_Taskmethods are async: they return as soon as vCenter accepts the request, before the operation has actually taken effect. Callers that immediately query the resulting state race the task; wrap every mutating SOAP call with this helper.Polls
task.info.stateeverypoll_intervalseconds (default 0.5) up totimeoutseconds (default 300). RaisesRuntimeErroron task error andTimeoutErrorif the task hasn’t finished in time.
- saltext.vcf.utils.vim.session_cookie(opts, profile=None)[source]¶
Return the
vmware_soap_sessioncookie from the cached ServiceInstance.Used to authenticate HTTP requests to vCenter
/folder/?dsName=…style file-transfer endpoints (datastore upload/download, OVF push/pull). The cookie value is wrapped asvmware_soap_session=<token>ready for aCookieheader.