{"id":13993869,"url":"https://github.com/vmware/vsphere-automation-sdk-python","last_synced_at":"2025-05-14T16:14:00.531Z","repository":{"id":38361871,"uuid":"58790378","full_name":"vmware/vsphere-automation-sdk-python","owner":"vmware","description":"Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API","archived":false,"fork":false,"pushed_at":"2024-08-07T05:10:48.000Z","size":236597,"stargazers_count":747,"open_issues_count":28,"forks_count":312,"subscribers_count":52,"default_branch":"master","last_synced_at":"2024-10-29T15:13:08.344Z","etag":null,"topics":["api-client","bindings","documentation","python","python3","restful-api","samples","vmware-vsphere"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-14T05:02:34.000Z","updated_at":"2024-10-28T12:02:03.000Z","dependencies_parsed_at":"2023-02-09T12:31:56.127Z","dependency_job_id":"a0e2479a-d350-41bc-a080-2ecb20b8dc6f","html_url":"https://github.com/vmware/vsphere-automation-sdk-python","commit_stats":{"total_commits":312,"total_committers":34,"mean_commits":9.176470588235293,"dds":0.8301282051282051,"last_synced_commit":"0e0b9321122e404cb49f6812dcea5bea792c49b2"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fvsphere-automation-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fvsphere-automation-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fvsphere-automation-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fvsphere-automation-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware","download_url":"https://codeload.github.com/vmware/vsphere-automation-sdk-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253767626,"owners_count":21961144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","bindings","documentation","python","python3","restful-api","samples","vmware-vsphere"],"created_at":"2024-08-09T14:02:36.139Z","updated_at":"2025-05-14T16:14:00.488Z","avatar_url":"https://github.com/vmware.png","language":"Python","readme":"# VMware vSphere Automation SDK for Python  \n[![Build Status](https://travis-ci.com/vmware/vsphere-automation-sdk-python.svg?token=v9mEJjcpDiQ9DrYbzyaQ\u0026branch=master)](https://travis-ci.com/vmware/vsphere-automation-sdk-python)\n\n## Table of Contents\n- [Abstract](#abstract)\n- [Supported vCenter Releases](#supported-onprem-vcenter-releases)\n- [Supported NSX-T Releases](#supported-nsx-t-releases)\n- [VMware Cloud on AWS Support](#vmware-cloud-on-aws-support)\n- [Quick Start Guide](#quick-start-guide)\n- [Run SDK Samples](#run-sdk-samples)\n- [API Documentation](#api-documentation)\n- [Troubleshooting](#troubleshooting)\n- [Support](#support)\n- [Repository Administrator Resources](#repository-administrator-resources)\n- [VMware Resources](#vmware-resources)\n\n## Abstract\nThis document describes the vSphere Automation Python SDK samples that use the vSphere Automation\npython client library. Additionally, some of the samples demonstrate the combined use of the\nvSphere Automation and vSphere APIs. To support this combined use, the vSphere Automation Python SDK\nsamples require the vSphere Management SDK packages (pyVmomi) to be installed on the client.\nThe samples have been developed to work with python 3.8+\n\n## Supported OnPrem vCenter Releases\nvCenter 7.0, 7.0U1, 7.0U2, 7.0U3 , 8.0, 8.0U1, 8.0U2, 8.0U3\nPlease refer to the notes in each sample for detailed compatibility information.\n\n## Supported NSX-T Releases\nNSX-T 2.2 - 4.2.0 and VMC 1.7 - 1.24\n\n## Latest VMware Cloud on AWS Release:\nVMC M24 (1.24) ([Release Notes](https://docs.vmware.com/en/VMware-Cloud-on-AWS/0/rn/vmc-on-aws-relnotes.html))\n\n## Quick Start Guide\n\n### Prepare a Python Development Environment\n\nWe recommend you to install latest [Python](http://docs.python-guide.org/en/latest/starting/installation/) and [pip](https://pypi.python.org/pypi/pip/) on your system.\n\nA Python virtual environment is also highly recommended.\n* [Install a virtual env for Python 3](https://docs.python.org/3/tutorial/venv.html)\n\n### Installing Required Python Packages\nSDK package installation commands may differ depending on the environment where it is being installed. The three installation options provided below are for different environments.\n*pip* and *setuptools* are common requirements for these installation types, upgrade to the latest *pip* and *setuptools*.\n\n**NOTE:** The SDK also requires OpenSSL 1.0.1+ in order to support TLS1.1 \u0026 1.2\n\n##### 1. Typical Installation\nThis is the recommended way to install the SDK. The installation is done from [PyPI](https://pypi.org/) and [Automation SDK Python Github](https://github.com/vmware/vsphere-automation-sdk-python) repositories.\n\nInstall/Update latest pip from PyPI.\n```cmd\npip install --upgrade pip\n```\nInstall/Update setuptools\n```cmd\npip install --upgrade setuptools\n```\nInstall SDK packages from Github.\n```cmd\npip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git\n```\n\n##### 2. Local installation\nLocal installation can be used in an environment which either do not have Github access or users do not want to install from Github repository.\n\n```cmd\npip install -U \u003cSDK_DIRECTORY_PATH\u003e\n```\nWhere \u003cSDK_DIRECTORY_PATH\u003e is either install directory of the SDK or location of SDK's zip\ne.g.\n```\npip install -U vsphere-automation-sdk-python\nOr\npip install -U vsphere-automation-sdk-python-8.0.0.0.zip\n```\n##### 3. Installation in an air gap environment\nFor this type of environment an additional step is required to ensure SDK's dependencies are available.\nFollowing dependencies have to be downloaded from PyPI and transferred to the air gap environment.\n\n**NOTE:** This step has to be done in an environment which has PyPI access.\n```cmd\npip download  -r requirements_pypi.txt -d lib\nzip -r lib.zip lib/\n```\nFollow these steps in the air gap environment.\nUnzip the lib.zip under automation SDK home directory.\n```cmd\nunzip lib.zip\n```\nInstall all the dependencies and packages.\n```cmd\npip install -U lib/**/*.whl\n```\nThis 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.\n```cmd\npip install -U `pwd`\n```\n\n### Connect to a vCenter Server\n\n```python\nimport requests\nimport urllib3\nfrom vmware.vapi.vsphere.client import create_vsphere_client\nsession = requests.session()\n\n# Disable cert verification for demo purpose. \n# This is not recommended in a production environment.\nsession.verify = False\n\n# Disable the secure connection warning for demo purpose.\n# This is not recommended in a production environment.\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\n# Connect to a vCenter Server using username and password\nvsphere_client = create_vsphere_client(server='\u003cvc_ip\u003e', username='\u003cvc_username\u003e', password='\u003cvc_password\u003e', session=session)\n\n# List all VMs inside the vCenter Server\nvsphere_client.vcenter.VM.list()\n```\n\nOutput in a Python Interpreter:\n\n```shell\n(venv) het-m03:vsphere-automation-sdk-python het$ python\nPython 3.9.8 (main, Nov 10 2021, 06:03:50)\n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import requests\n\u003e\u003e\u003e import urllib3\n\u003e\u003e\u003e from vmware.vapi.vsphere.client import create_vsphere_client\n\u003e\u003e\u003e session = requests.session()\n\u003e\u003e\u003e session.verify = False\n\u003e\u003e\u003e urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) \n\u003e\u003e\u003e vsphere_client = create_vsphere_client(server='\u003cvc_ip\u003e', username='\u003cvc_username\u003e', password='\u003cvc_password\u003e', session=session)\n\u003e\u003e\u003e vsphere_client.vcenter.VM.list()\n[Summary(vm='vm-58', name='standalone-20e4bd3af-esx.0-vm.0', power_state=State(string='POWERED_OFF'), cpu_count=1, memory_size_mib=256), \n...]\n```\n\n**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](http://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html) \n\n### Connect to VMware Cloud on AWS\n\n```python\nfrom vmware.vapi.vmc.client import create_vmc_client\n\n# Connect to VMware Cloud on AWS using refresh token\nvmc_client = create_vmc_client('\u003crefresh_token\u003e')\n\n# Get organizations associated with calling user.\nvmc_client.Orgs.list()\n```\n\nOutput in a Python Interpreter:\n\n```shell\n(venv) het-m03:vsphere-automation-sdk-python het$ python\nPython 3.9.8 (main, Nov 10 2021, 06:03:50)\n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e from vmware.vapi.vmc.client import create_vmc_client\n\u003e\u003e\u003e vmc_client = create_vmc_client('\u003crefresh_token\u003e')\n\u003e\u003e\u003e vmc_client.Orgs.list()\n[Organization(updated=datetime.datetime(2018, 3, 2, 16, 57, 46), user_id='77aa6e6f-3257-3637-9cd9-14fae3a25b9d', updated_by_user_id='2021b5ae-890b-3472-ba9a-bc8cff776ca7', created=datetime.datetime(2017, 4, 4, 11, 57, 48, 861), version=15, updated_by_user_name='mdreyer@vmware.com', user_name='pgifford@vmware.com', id='2a8ac0ba-c93d-4748-879f-7dc9918beaa5', display_name='VMC-SET', name='j13hqg73', sla='VMC_INTERNAL', project_state='CREATED', properties=OrgProperties(values={'defaultAwsRegions': 'US_WEST_2,US_EAST_1', 'sddcLimit': '5', 'planVersion': '3.0', 'defaultHostsPerSddc': '4', 'invitationCode': '/csp/gateway/slc/api/service-invitations/aa7203c3617bbe755597b8b0ad652', 'enableAWSCloudProvider': 'true', 'enableZeroCloudCloudProvider': 'true', 'accountLinkingOptional': 'false', 'defaultPDXDatacenter': 'pdx2', 'skipSubscriptionCheck': 'true', 'minHostsPerSddc': '4', 'maxHostsPerSddc': '8', 'hostLimit': '16', 'maxHostsPerSddcOnCreate': '4', 'isAllAccess': 'true', 'enabledAvailabilityZones': '{\"us-east-1\":[\"iad6\",\"iad7\",\"iad12\"],\"us-west-2\":[\"pdx1\", \"pdx4\", \"pdx2\"]}'}), cloud_configurations={'AWS': AwsOrgConfiguration(provider='AWS')})\n...]\n```\n\n## Run SDK Samples\n\nIn this section we will walk you through the steps to run the sample code for vSphere \nand VMware Cloud on AWS APIs. \n\n### First, set PYTHONPATH to use SDK helper methods  \n\n* Linux/Mac:\n\n    export PYTHONPATH=${PWD}:$PYTHONPATH\n\n* Windows:\n\n    set PYTHONPATH=%cd%;%PYTHONPATH%\n\n### Run VMware Cloud on AWS Samples\n\n```cmd\n$ python samples/vmc/orgs/organization_operations.py -r \u003crefresh_token\u003e\n```\n\n### Run vSphere Samples\n\nA vSphere test environment is required with the following configuration:\n* 1 vCenter Server\n* 2 ESX hosts\n* 1 NFS Datastore with at least 3GB of free capacity\n\n**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.\n\n#### Running the SDK Sample Setup Script\n\nBefore 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:\n\n* Create 2 test Datacenters \n* Create a test Cluster\n* Create Test Folders for VM Storage\n* Attach the hosts\n* Create a Distributed Switch\n* Create a Distributed Portgroup\n* Attach the NFS datastore (if Selected) to the hosts\n* Copy the [Photon OS](https://vmware.github.io/photon/) ISO image downloaded from [VMware's bintray server](https://dl.bintray.com/vmware/photon) to the datastore\n* Create directories to add sample ports\n\nFirst, edit settings in samples/vsphere/vcenter/setup/testbed.py and replace everything in \u003c \u003e brackets with your environment information. Leave the rest of the settings in this file at their default values.\n\n```python\nconfig[\"SERVER\"]    = \"\u003cvcenter_hostname_or_ip\u003e\"\nconfig[\"USERNAME\"]  = \"\u003cvsphere_username\u003e\"\nconfig[\"PASSWORD\"]  = \"\u003cvsphere_password\u003e\"\n\nconfig[\"ESX_HOST1\"] = \"\u003cESX_host1_ipaddress\u003e\"\nconfig[\"ESX_HOST2\"] = \"\u003cESX_host2_ipaddress\u003e\"\nconfig[\"ESX_USER\"]  = \"\u003cesx_username\u003e\"\nconfig[\"ESX_PASS\"]  = \"\u003cesx_password\u003e\"\n\nconfig[\"USE_NFS\"]   = True\nconfig[\"NFS_HOST\"]  = \"\u003cnfs_ipaddress\u003e\"\nconfig[\"NFS_REMOTE_PATH\"] = \"/store1\"\n```\n\nAt this point, we're ready to run the setup script: \n\n```cmd\n$ python samples/vsphere/vcenter/setup/main.py -sv\n```\n\nAfter 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.\n\nTo view other available command-line options:\n\n```cmd\n$ python samples/vsphere/vcenter/setup/main.py -h\n```\n\n#### Run the vAPI vCenter sample suite:\n\n```cmd\n$ python samples/vsphere/vcenter/setup/main.py -riv\n```\n\n#### Run a specific sample in a standalone mode:\n\n```cmd\n$ python samples/vsphere/vcenter/vm/list_vms.py -v\n```\n\n## API Documentation\n\n### vSphere API Documentation\n\n* [VMware vSphere REST API Reference documentation](https://developer.broadcom.com/xapis/vsphere-automation-api/latest/)\n* [vSphere 8.0 U3 Python APIs (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.3.0/)\n* Previous Releases:\tvSphere [8.0 U2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.2.0/)\n[8.0 U1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.1.0/)\n[8.0 GA](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.1/)\n[8.0.0.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/),\n[7.0 U3](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.0/)\n[7.0 U2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.2.0/),   [7.0 U1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.1.0/),   [7.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.0.1/).\n\n### VMware Cloud on AWS API Documentation\n\n* [VMware Cloud on AWS REST APIs](https://developer.broadcom.com/xapis/vmware-cloud-on-aws-api-reference/latest/) \n* [VMware Cloud on AWS Console Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/vmc/index.html)\n* [VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/vmc-draas/index.html)\n\n\n### NSX API Documentation\n* [NSX-T Data Center](https://docs.vmware.com/en/VMware-NSX-T-Data-Center/index.html)\n* [NSX Manager Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx/index.html) - API for managing NSX-T cluster and transport nodes for on-prem customers\n* [NSX Policy Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx_policy/index.html) - primary API for managing logical networks for on-prem customers\n* [NSX VMC Policy Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx_vmc_policy/index.html) - primary API for managing logical networks for VMC customers\n* [NSX VMC AWS Integration Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx_vmc_aws_integration/index.html) - API for managing AWS underlay networks for VMC customers\n\n## Troubleshooting\n\nCommon issues you may run into while installing the sdk and running samples are listed [here](https://github.com/vmware/vsphere-automation-sdk-python/wiki/Troubleshooting)\n\n## Support\n\nSupport details can be referenced under the **SDK and API Support for Commercial and Enterprise Organizations** section at [Broadcom Developer Portal](https://developer.broadcom.com/support).\n\nFor community support, please open a [Github issue](https://github.com/vmware/vsphere-automation-sdk-python/issues) or start a [Discussion](https://github.com/vmware/vsphere-automation-sdk-python/discussions).\n\n## Repository Administrator Resources\n\n### Board Members\n\nBoard 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.\n\nMembers:\n* Ankit Agrawal (VMware)\n* Jobin George (VMware)\n* Martin Tsvetanov (VMware)\n* Shweta Purohit (VMware)\n* Kunal Singh (VMware)\n\n## VMware Resources\n\n* [vSphere Automation SDK Overview](http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.vapi.progguide.doc/GUID-AF73991C-FC1C-47DF-8362-184B6544CFDE.html)\n* [VMware Sample Exchange](https://code.vmware.com/samples) It is highly recommended to add any and all submitted samples to the VMware Sample Exchange\n* [VMware Code](https://code.vmware.com/home)\n* [VMware Developer Community](https://communities.vmware.com/community/vmtn/developer)\n* VMware vSphere [REST API Reference documentation](https://developer.broadcom.com/xapis/vsphere-automation-api/latest/).\n* [VMware Python forum](https://code.vmware.com/forums/7508/vsphere-automation-sdk-for-python)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fvsphere-automation-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware%2Fvsphere-automation-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fvsphere-automation-sdk-python/lists"}