saltext.vcf.utils.esxi

ESXi host connection helpers — standalone/unmanaged ESXi only.

All communication uses the pyVmomi SOAP/VMODL stack (/sdk). This works on any ESXi host regardless of whether the vAPI endpoint (/api/*) is present, which is important because shuttle-deployed test hosts omit that service.

On hosts that have been joined to a vCenter, the REST /api/session endpoint is blocked (400 on real VCF 9.2). For hosts managed by vCenter, cluster- level configuration is done via the Configuration Profile API; see saltext.vcf.clients.cluster_config.

Config is read from Salt opts/pillar under saltext.vcf.esxi:

saltext.vcf:
  esxi:
    host: esxi-test.example.com
    username: root
    password: secret
    verify_ssl: false
saltext.vcf.utils.esxi.get_config(opts, profile=None)[source]

Extract ESXi connection config from Salt opts/pillar.

saltext.vcf.utils.esxi.get_service_instance(opts, profile=None)[source]

Return a connected pyVmomi ServiceInstance for the ESXi host.

Cached per (host, port, username). Use invalidate_service_instance() to force a fresh connection.

saltext.vcf.utils.esxi.invalidate_service_instance(opts, profile=None)[source]

Disconnect and drop the cached ServiceInstance for this host.

saltext.vcf.utils.esxi.get_host_system(opts, profile=None)[source]

Return the vim.HostSystem for a standalone ESXi host.

Locate the single HostSystem via a ContainerView rather than by hard-coded child-entity indexing. On real ESXi 9.1 GA Datacenter.host is not a stable attribute traversal — the working path is Datacenter.hostFolder.childEntity[0].host[0], which is fragile. A ContainerView is protocol-idiomatic, tolerates any intermediate folder layout, and behaves identically on multi- host trees (returning the first match).