Skip to main content

Client library for vSphere Automation APIs

Project description

VMware vCenter Server

VMware vCenter Server library contains client bindings for VMware vCenter Server Automation APIs. This library is part of vSphere Automation SDK for Python.

Package (PyPI) | REST API documentation

Getting started

Prerequisites

  • Python 3.8+ is required to use this package.

Install the package

pip install vmware-vcenter

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.9.8 (main, Nov 10 2021, 06:03:50)
[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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

vmware_vcenter-8.0.3.0-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file vmware_vcenter-8.0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vmware_vcenter-8.0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8b7d3ab3ee0d9ec906801a4cd467efaf2eeed78ab770eb6f747f03893efe89
MD5 3f4b0b9a5835f43b0a940bd2a3d33666
BLAKE2b-256 bb9c70878502a1ca09900a986c2509edb8fee16e89b0f8d1d1238d940d1d95b4

See more details on using hashes here.

Supported by

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