All Projects → vmware → Vsphere Automation Sdk Python

vmware / Vsphere Automation Sdk Python

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

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Vsphere Automation Sdk Python

Vsphere Automation Sdk Java
Java samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
Stars: ✭ 132 (-70.73%)
Mutual labels:  api-client, restful-api, samples, documentation, bindings
Vsphere Automation Sdk Rest
REST (Postman and JavaScript) samples and API reference documentation for vSphere using the VMware REST API
Stars: ✭ 182 (-59.65%)
Mutual labels:  api-client, restful-api, samples, documentation, bindings
vsphere-automation-sdk-rest
REST (Postman and JavaScript) samples and API reference documentation for vSphere using the VMware REST API
Stars: ✭ 194 (-56.98%)
Mutual labels:  api-client, samples, bindings, restful-api
vsphere-automation-sdk-.net
[DEPRECATED] Please see README. C# samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
Stars: ✭ 67 (-85.14%)
Mutual labels:  api-client, samples, bindings, restful-api
Restful Api Guidelines
A model set of guidelines for RESTful APIs and Events, created by Zalando
Stars: ✭ 1,397 (+209.76%)
Mutual labels:  restful-api, documentation
Awesome Docs With Static Site Generators
Pointers to all templates and implementations based on static site generators
Stars: ✭ 44 (-90.24%)
Mutual labels:  samples, documentation
Datafire
A framework for building integrations and APIs
Stars: ✭ 487 (+7.98%)
Mutual labels:  api-client, restful-api
Express Typescript Boilerplate
A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch
Stars: ✭ 2,293 (+408.43%)
Mutual labels:  restful-api, documentation
Woocommerce.net
A .NET Wrapper for WooCommerce/WordPress REST API
Stars: ✭ 247 (-45.23%)
Mutual labels:  api-client, restful-api
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+2257.87%)
Mutual labels:  api-client, restful-api
YuiAPI
一个浏览器API测试客户端,API文档生成器,支持chrome/firefox/新版edge
Stars: ✭ 25 (-94.46%)
Mutual labels:  api-client, restful-api
Sklearn Doc Zh
📖 [译] scikit-learn(sklearn) 中文文档
Stars: ✭ 4,520 (+902.22%)
Mutual labels:  documentation
Mybatis Plus Doc
MyBatis-Plus Documentation
Stars: ✭ 431 (-4.43%)
Mutual labels:  documentation
The Documentation Compendium
📢 Various README templates & tips on writing high-quality documentation that people want to read.
Stars: ✭ 4,306 (+854.77%)
Mutual labels:  documentation
Roxygen2
Generate R package documentation from inline R comments
Stars: ✭ 428 (-5.1%)
Mutual labels:  documentation
Romplayer
AudioKit Sample Player (ROM Player) - EXS24, Sound Font, Wave Player
Stars: ✭ 445 (-1.33%)
Mutual labels:  samples
Python Redmine
Python Redmine is a library for communicating with a Redmine project management application
Stars: ✭ 440 (-2.44%)
Mutual labels:  api-client
Kubernetes practice
kubernetes实践指南(内容不定期更新中。。。), 欢迎提PR。
Stars: ✭ 428 (-5.1%)
Mutual labels:  documentation
Juliazh.jl
Julia语言中文文档
Stars: ✭ 425 (-5.76%)
Mutual labels:  documentation
Documentation
Issue tracker for Plotly's open-source documentation.
Stars: ✭ 424 (-5.99%)
Mutual labels:  documentation

VMware vSphere Automation SDK for Python

Build Status

Table of Contents

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 2.7.x and 3.3+

Supported OnPrem vCenter Releases

vCenter 6.0, 6.5, 6.7, 7.0, 7.0U1 and 7.0U2. Certain APIs and samples that are introduced in 6.5 release, such as vCenter, Virtual Machine and Appliance Management. Please refer to the notes in each sample for detailed compatibility information.

Supported NSX-T Releases

NSX-T 2.2, 2.3, 3.0 and VMC 1.7, 1.8, 1.9, 1.10, 1.11, 1.12

VMware Cloud on AWS Support

The VMware Cloud on AWS API and samples are currently available as a preview and are subject to change in the future.

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.

Installing Required Python Packages

Be sure to upgrade to the latest pip and setuptools.

pip install --upgrade pip setuptools
pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git

NOTE: The SDK also requires OpenSSL 1.0.1+ if you want to connect to vSphere 6.5+ in order to support TLS1.1 & 1.2

Connect to a vCenter Server

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

# Disable cert verification for demo purpose. 
# This is not recommended in a production environment.
session.verify = False

# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to a vCenter Server using username and password
vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)

# List all VMs inside the vCenter Server
vsphere_client.vcenter.VM.list()

Output in a Python Interpreter:

(venv) het-m03:vsphere-automation-sdk-python het$ python
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> import urllib3
>>> from vmware.vapi.vsphere.client import create_vsphere_client
>>> session = requests.session()
>>> session.verify = False
>>> urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 
>>> vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)
>>> vsphere_client.vcenter.VM.list()
[Summary(vm='vm-58', name='standalone-20e4bd3af-esx.0-vm.0', power_state=State(string='POWERED_OFF'), cpu_count=1, memory_size_mib=256), 
...]

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

from vmware.vapi.vmc.client import create_vmc_client

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

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

Output in a Python Interpreter:

(venv) het-m03:vsphere-automation-sdk-python het$ python
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from vmware.vapi.vmc.client import create_vmc_client
>>> vmc_client = create_vmc_client('<refresh_token>')
>>> vmc_client.Orgs.list()
[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='[email protected]', user_name='[email protected]', 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')})
...]

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

$ python samples/vmc/orgs/organization_operations.py -r <refresh_token>

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.

config["SERVER"]    = "<vcenter_hostname_or_ip>"
config["USERNAME"]  = "<vsphere_username>"
config["PASSWORD"]  = "<vsphere_password>"

config["ESX_HOST1"] = "<ESX_host1_ipaddress>"
config["ESX_HOST2"] = "<ESX_host2_ipaddress>"
config["ESX_USER"]  = "<esx_username>"
config["ESX_PASS"]  = "<esx_password>"

config["USE_NFS"]   = True
config["NFS_HOST"]  = "<nfs_ipaddress>"
config["NFS_REMOTE_PATH"] = "/store1"

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

$ 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:

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

Run the vAPI vCenter sample suite:

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

Run a specific sample in a standalone mode:

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

API Documentation

vSphere API Documentation

VMware Cloud on AWS API Documentation

NSX API Documentation

Troubleshooting

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

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:

  • Anusha Hegde (VMware)
  • Pavan Bidkar (VMware)

VMware Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].