Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

vsphere-automation-sdk-python

> 开发工具
Open source

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API

799 stars0 likes1 views
WebsiteGitHub

About

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API

VMware vSphere Automation SDK for Python

$\color{Red}{\textsf{IMPORTANT NOTICE}}$

For VCF releases 9.0.0.0 and above, please refer to the new VCF SDK Python repository for vSphere libraries.

For NSX libraries, refer to the VMware NSX for Python in Broadcom developer portal.

Table of Contents

  • Abstract
  • Supported vCenter Releases
  • Supported NSX-T Releases
  • VMware Cloud on AWS Support
  • Quick Start Guide
  • Run SDK Samples
  • API Documentation
  • Troubleshooting
  • Support
  • Repository Administrator Resources
  • VMware Resources

Abstract

This document describes the vSphere Automation Python SDK samples that use the vSphere Automation python client library. Additionally, some of the samples demonstrate the combined use of the vSphere Automation and vSphere APIs. To support this combined use, the vSphere Automation Python SDK samples require the vSphere Management SDK packages (pyVmomi) to be installed on the client. The samples have been developed to work with python 3.8+

Supported OnPrem vCenter Releases

vCenter 7.0, 7.0U1, 7.0U2, 7.0U3 , 8.0, 8.0U1, 8.0U2, 8.0U3 Please refer to the notes in each sample for detailed compatibility information.

Supported NSX-T Releases

NSX-T 2.2 - 4.2.0 and VMC 1.7 - 1.24

Latest VMware Cloud on AWS Release:

VMC M24 (1.24) (Release Notes)

Quick Start Guide

Prepare a Python Development Environment

We recommend you to install latest Python and pip on your system.

A Python virtual environment is also highly recommended.

  • Install a virtual env for Python 3

Installing Required Python Packages

SDK package installation commands may differ depending on the environment where it is being installed. The three installation options provided below are for different environments. pip and setuptools are common requirements for these installation types, upgrade to the latest pip and setuptools.

NOTE: The SDK also requires OpenSSL 1.0.1+ in order to support TLS1.1 & 1.2

1. Typical Installation

This is the recommended way to install the SDK. The installation is done from PyPI and Automation SDK Python Github repositories.

Install/Update latest pip from PyPI.

cmd
pip install --upgrade pip

Install/Update setuptools

cmd
pip install --upgrade setuptools

Install SDK packages from Github.

cmd
pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
2. Local installation

Local installation can be used in an environment which either do not have Github access or users do not want to install from Github repository.

cmd
pip install -U 

Where is either install directory of the SDK or location of SDK's zip e.g.

bash
pip install -U vsphere-automation-sdk-python
Or
pip install -U vsphere-automation-sdk-python-8.0.0.0.zip
3. Installation in an air gap environment

For this type of environment an additional step is required to ensure SDK's dependencies are available. Following dependencies have to be downloaded from PyPI and transferred to the air gap environment.

NOTE: This step has to be done in an environment which has PyPI access.

cmd
pip download  -r requirements_pypi.txt -d lib
zip -r lib.zip lib/

Follow these steps in the air gap environment. Unzip the lib.zip under automation SDK home directory.

cmd
unzip lib.zip

Install all the dependencies and packages.

cmd
pip install -U lib/**/*.whl

This is to install the "vSphere-Automation-SDK" which provides an SDK version. It also ensures that all the SDK requirements are installed. If not, the installation will fail.

cmd
pip install -U `pwd`

Connect to a vCenter Server

…

Output in a Python Interpreter:

…

NOTE: If you are using Bash, be sure to use single quote for username and password to preserve the values. If you use double quote, you will have to escape special characters, such as "$". See Bash manual

Connect to VMware Cloud on AWS

python
from vmware.vapi.vmc.client import create_vmc_client

# Connect to VMware Cloud on AWS using refresh token
vmc_client = create_vmc_client('')

# Get organizations associated with calling user.
vmc_client.Orgs.list()

Output in a Python Interpreter:

…

Run SDK Samples

In this section we will walk you through the steps to run the sample code for vSphere and VMware Cloud on AWS APIs.

First, set PYTHONPATH to use SDK helper methods

  • Linux/Mac:

    export PYTHONPATH=${PWD}:$PYTHONPATH

  • Windows:

    set PYTHONPATH=%cd%;%PYTHONPATH%

Run VMware Cloud on AWS Samples

cmd
$ python samples/vmc/orgs/organization_operations.py -r 

Run vSphere Samples

A vSphere test environment is required with the following configuration:

  • 1 vCenter Server
  • 2 ESX hosts
  • 1 NFS Datastore with at least 3GB of free capacity

Note Please have the details of these available but do not have any configuration pre-created on vCenter server or ESXi Hosts, for example there should be no existing datacenters, clusters or attached hosts on the vCenter server.

Running the SDK Sample Setup Script

Before executing the samples we'll need to setup the vSphere test environment using one of the sample scripts (samples/vsphere/vcenter/setup/main.py). The script will perform the following:

  • Create 2 test Datacenters
  • Create a test Cluster
  • Create Test Folders for VM Storage
  • Attach the hosts
  • Create a Distributed Switch
  • Create a Distributed Portgroup
  • Attach the NFS datastore (if Selected) to the hosts
  • Copy the Photon OS ISO image downloaded from VMware's bintray server to the datastore
  • Create directories to add sample ports

First, edit settings in samples/vsphere/vcenter/setup/testbed.py and replace everything in brackets with your environment information. Leave the rest of the settings in this file at their default values.

python
config["SERVER"]    = ""
config["USERNAME"]  = ""
config["PASSWORD"]  = ""

config["ESX_HOST1"] = ""
config["ESX_HOST2"] = ""
config["ESX_USER"]  = ""
config["ESX_PASS"]  = ""

config["USE_NFS"]   = True
config["NFS_HOST"]  = ""
config["NFS_REMOTE_PATH"] = "/store1"

At this point, we're ready to run the setup script:

cmd
$ python samples/vsphere/vcenter/setup/main.py -sv

After completion you will see from the output and also the vSphere Client that the environment has now been fully setup and is ready to easily run further samples.

To view other available command-line options:

cmd
$ python samples/vsphere/vcenter/setup/main.py -h

Run the vAPI vCenter sample suite:

cmd
$ python samples/vsphere/vcenter/setup/main.py -riv

Run a specific sample in a standalone mode:

cmd
$ python samples/vsphere/vcenter/vm/list_vms.py -v

API Documentation

vSphere API Documentation

  • VMware vSphere REST API Reference documentation
  • vSphere 8.0 U3 Python APIs (latest)
  • Previous Releases: vSphere 8.0 U2 8.0 U1 8.0 GA 8.0.0.0, 7.0 U3 7.0 U2, 7.0 U1, 7.0.

VMware Cloud on AWS API Documentation

  • VMware Cloud on AWS REST APIs
  • VMware Cloud on AWS Console Python APIs
  • VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) Python APIs

NSX API Documentation

  • NSX-T Data Center
  • NSX Manager Python APIs - API for managing NSX-T cluster and transport nodes for on-prem customers
  • NSX Policy Python APIs - primary API for managing logical networks for on-prem customers
  • NSX VMC Policy Python APIs - primary API for managing logical networks for VMC customers
  • NSX VMC AWS Integration Python APIs - API for managing AWS underlay networks for VMC customers

Troubleshooting

Common issues you may run into while installing the sdk and running samples are listed here

Support

Support details can be referenced under the SDK and API Support for Commercial and Enterprise Organizations section at Broadcom Developer Portal.

For community support, please open a Github issue or start a Discussion.

Repository Administrator Resources

Board Members

Board members are volunteers from the SDK community and VMware staff members, board members are not held responsible for any issues which may occur from running of samples from this repository.

Members:

  • Ankit Agrawal (VMware)
  • Jobin George (VMware)
  • Martin Tsvetanov (VMware)
  • Shweta Purohit (VMware)
  • Kunal Singh (VMware)

VMware Resources

  • vSphere Automation SDK Overview
  • VMware Sample Exchange It is highly recommended to add any and all submitted samples to the VMware Sample Exchange
  • VMware Code
  • VMware Developer Community
  • VMware vSphere REST API Reference documentation.
  • VMware Python forum

Issues· 30 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonapi-clientbindingsdocumentationpython

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具