Skip to main content

Python SDK for VMware Cloud Foundation (VCF) — SDDC Manager, NSX-T Policy API, and vCenter REST API

Project description

vmware-vcf — Python SDK for VMware Cloud Foundation

A comprehensive Python SDK for programmatically managing VMware Cloud Foundation (VCF) infrastructure — SDDC Manager, NSX-T, and vCenter. Also includes an Ansible collection.

pip install vmware-vcf

Clients

Client API Auth
SDDCManager SDDC Manager REST API (100% of Broadcom spec) JWT with auto-refresh
NSXManager NSX-T Policy API HTTP Basic
VCenter vCenter REST API Session-based
CloudBuilder Cloud Builder API HTTP Basic

Quick Start

from vcf_sdk import SDDCManager, NSXManager, VCenter

# SDDC Manager
with SDDCManager("sddc.lab.dev", "admin@local", "password") as sddc:
    # List hosts
    hosts = sddc.hosts.list(status="COMMISSIONED")
    
    # Commission new hosts (validates first, then executes)
    task = sddc.hosts.commission([{
        "fqdn": "esxi-05.lab.dev",
        "username": "root",
        "password": "password",
        "storageType": "VSAN_ESA",
        "networkPoolId": "pool-uuid"
    }])
    
    # Wait for completion
    sddc.tasks.wait_for_completion(task.id, timeout=3600)
    
    # Manage identity providers
    providers = sddc.identity_providers.list()
    
    # Configure certificates
    sddc.certificates.set_microsoft_ca(
        server_url="https://ca.lab.dev/certsrv",
        username="admin", password="pass", template_name="VMware"
    )

# NSX-T
with NSXManager("nsx.lab.dev", "admin", "password") as nsx:
    # Create a segment (PATCH = idempotent)
    nsx.segments.create_or_update("web-segment", {
        "display_name": "Web Segment",
        "transport_zone_path": "/infra/sites/default/enforcement-points/default/transport-zones/tz-overlay",
        "connectivity_path": "/infra/tier-1s/t1-gateway",
        "subnets": [{"gateway_address": "192.168.1.1/24"}]
    })
    
    # Create firewall policy with rules
    nsx.security_policies.create_or_update("app-policy", {
        "display_name": "App Isolation",
        "category": "Application",
        "rules": [{
            "id": "allow-https",
            "action": "ALLOW",
            "source_groups": ["/infra/domains/default/groups/web-servers"],
            "services": ["/infra/services/HTTPS"]
        }]
    })

# vCenter
with VCenter("vcenter.lab.dev", "administrator@vsphere.local", "password") as vc:
    vms = vc.vms.list(power_states="POWERED_ON")
    datastores = vc.infrastructure.list_datastores()
    vc.tagging.attach("tag-id", "VirtualMachine", "vm-42")

SDDC Manager — 34 Managers

Hosts, clusters, domains, tasks, credentials, certificates, identity providers, network pools, licenses, bundles/upgrades, users/roles, DNS/NTP, backup, compliance, federation, Aria Suite, edge clusters, AVNs, ALB clusters, brownfield import, check sets, compatibility matrices, config drift, manifests, notifications, product catalogs, resource functionalities, trusted certificates, VASA providers, VCF components, version aliases, vSAN HCL/health, system config.

NSX-T Policy API — 44 Managers

Networking: Segments + ports, Tier-0/Tier-1 gateways (locale services, interfaces, static routes, BGP, OSPF, prefix/community lists, route maps, redistribution).

Security: Groups, distributed firewall policies/rules, gateway policies, services, context profiles, IDS/IPS, firewall exclude list, cluster security, predefined policies.

Load Balancing: Services, virtual servers, pools, monitors, application profiles, persistence profiles, SSL profiles.

VPN: IPSec (services, sessions, endpoints, IKE/tunnel/DPD profiles), L2 VPN.

Network Services: NAT, DHCP server/relay, DNS forwarder zones.

IP Management: IP pools + subnets + allocations, IP blocks + block subnets.

Fabric: Transport zones, edge clusters/nodes, host/edge transport nodes, TN collections/profiles, host switch profiles, edge HA profiles, sites, enforcement points, compute sub-clusters.

Multi-tenancy: Projects, VPCs (subnets, ports, groups, security/gateway policies, NAT, routes, IP allocations, DHCP bindings).

Profiles: IP/MAC discovery, spoof guard, segment security, QoS, gateway QoS, flood protection + bindings.

EVPN: Config, tenants, tunnel endpoints.

vCenter REST API — 11 Managers

VMs (lifecycle + power), content library (local + subscribed), namespace management (Tanzu/VKS), tagging (categories + tags + associations), infrastructure (clusters, datacenters, datastores, hosts, networks, resource pools, storage policies), OVF deployment, VM hardware (disks, NICs, CPU, memory), snapshots, DRS rules, folders, guest customization.

Version Awareness

The SDK auto-detects VCF and NSX versions on connect and warns when accessing endpoints not available on the connected version.

sddc = SDDCManager("sddc.lab.dev", "admin@local", "password")
print(sddc.version)  # "9.0.2.0"
# Accessing VPC features on NSX < 4.1.1 logs a warning

Ansible Collection

ansible-galaxy collection install ./ansible_collections/darrylcauldwell/vcf

Modules: vcf_host, vcf_cluster, vcf_domain, vcf_credential, vcf_dns, vcf_certificate, vcf_identity_provider, vcf_nsx_segment, vcf_nsx_gateway, vcf_nsx_firewall, vcf_nsx_nat.

- name: Commission hosts
  darrylcauldwell.vcf.vcf_host:
    sddc_hostname: sddc-manager.lab.dev
    sddc_username: admin@local
    sddc_password: "{{ vault_sddc_password }}"
    state: present
    host_spec:
      - fqdn: esxi-05.lab.dev
        username: root
        password: "{{ vault_esxi_password }}"
        storageType: VSAN_ESA
        networkPoolId: "{{ network_pool_id }}"

Development

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v --cov=vcf_sdk
ruff check vcf_sdk/ tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vmware_vcf-0.2.0.tar.gz (90.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vmware_vcf-0.2.0-py3-none-any.whl (104.6 kB view details)

Uploaded Python 3

File details

Details for the file vmware_vcf-0.2.0.tar.gz.

File metadata

  • Download URL: vmware_vcf-0.2.0.tar.gz
  • Upload date:
  • Size: 90.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for vmware_vcf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 90c8ae2b70f782e2213a56d5d1530e8b43160aad13b45adb5acbe3f2733b7a7d
MD5 b9f005802942a83180a79ed24ffa6e88
BLAKE2b-256 89f57d1e6a7fa49baade8dac9e33cd0a8e4c8a90aac7f8d5db8a705710a67043

See more details on using hashes here.

File details

Details for the file vmware_vcf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vmware_vcf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 104.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for vmware_vcf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa688da3e9351ec8e4ebbdc9da346b6d53c5bd687d64ba342038692a11df226
MD5 8d9d8204892b117e1bf5f6861d9def40
BLAKE2b-256 5aebae252bacb7e5ee42a45e03a5f28dda008a72fa6b3f6d4b46efc3399db0b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page