VMware vSphere Automation SDK for Python

repository·master·Indexed 21 days ago

https://github.com/vmware/vsphere-automation-sdk-python

A Python SDK providing programmatic access to vSphere and VMware Cloud on AWS APIs for automating infrastructure management tasks, including VM lifecycle, networking, and organization management. It includes client libraries for VMware Cloud on AWS Console, DRaaS, NSX-T, and NSX-T on VMC Policy APIs.

Tokens
15.6K
Snippets
51
Records
90
Agent score
73%

What's inside vmware-vsphere-automation-sdk-python

  1. Available SDK client libraries

    master

    The vsphere-automation-sdk-python repository provides several client libraries located in the lib directory for testing and development. These libraries contain client stubs for various VMware services:

    • vmwarecloud_aws: Client stubs for VMware Cloud on AWS Console APIs.
    • vmwarecloud_draas: Client stubs for VMware Cloud (VMC) Disaster Recovery as a Service (DRaaS) APIs.
    • nsx-python-sdk: Client stubs for VMware NSX-T APIs.
    • nsx-vmc-policy-python-sdk: Client stubs for VMware NSX-T on VMC Policy APIs.
    • nsx-vmc-aws-integration-python-sdk: Client stubs for VMware NSX-T AWS integration app APIs (used for AWS underlay management).
  2. Available Content Library API sample workflows

    master

    The following sample scripts demonstrate various workflows available via the Content Library APIs:

    • CRUD operations: Managing a content library (library_crud.py).
    • Content Updates: Updating the content of a library item (content_update.py).
    • OVF Deployment: Deploying an OVF library item to a resource pool (deploy_ovf_template.py).
    • OVF Import/Export: Importing an OVF package into a library or downloading an OVF template (ovf_import_export.py).
    • OVA Import: Importing an OVA package as an OVF library item (signed_ova_import.py).
    • Publish/Subscribe: Basic workflow for publishing and subscribing to content libraries (library_publish_subscribe.py).
    • VM Capture: Capturing an existing virtual machine into a content library (vm_template_capture.py).
    • ISO Management: Mounting and unmounting ISO items (iso_mount.py).
    • VM Template Creation: Creating a library item from a virtual machine template (create_vm_template.py).
    • VM Template Deployment: Deploying a virtual machine from a library item containing a template (deploy_vm_template.py).
  3. Use snapservice API samples for Protection Groups and Snapshots

    master

    This directory provides Python samples for interacting with snapservice APIs, specifically for managing Protection Groups and their snapshots.

    Available Samples

    Protection Group Operations:

    • list_protection_groups.py: Lists existing protection groups.
    • create_protection_group.py: Creates a new protection group.
    • delete_protection_groups.py: Deletes specified protection groups.

    Snapshot Operations:

    • delete_protection_group_snapshots.py: Deletes snapshots associated with a protection group.
  4. Explore VMware Cloud on AWS API samples

    master

    The samples/vmc directory contains practical examples for interacting with VMware Cloud on AWS APIs. The samples are organized by functional area:

    • orgs: Operations related to organizations.
    • sddc: Operations related to Software-Defined Data Centers (SDDCs).
    • draas: Operations related to Disaster Recovery as a Service (DRaaS) APIs.
    • networks: Operations related to networking APIs.
    • helpers: Utility methods and helper functions used across the VMware Cloud on AWS API samples.
  5. Use ESXi Hardware Compatibility APIs

    master

    The ESXi Hardware Compatibility feature allows you to generate hardware compatibility reports for a specific ESXi host against a target ESXi version. This is achieved through four primary API operations:

    • Compatibility Data Download: Updates the local compatibility data on the vCenter using the latest version from the VMware Official repository.
    • Compatibility Data Status: Retrieves information regarding when the vCenter's compatibility datastore was last synchronized with the VMware Official Repository.
    • Compatibility Releases: Lists the available ESXi releases for a specific host that can be used as targets for a compatibility report.
    • Compatibility Report: Generates the actual compatibility report for a source host against a chosen target version.
  6. Use the Patching API (applmgt) for vCenter updates

    master

    The Patching API (part of the applmgt group) allows you to manage vCenter Server appliance updates. It is divided into two main functional areas:

    1. Pending: Used to perform patching operations for pending updates (precheck, validate, stage, and install).
    2. Update: Used to check the status of an ongoing update operation.

    Testbed Requirements:

    • Component updates: Requires vCenter Server appliance version 8.0 or above.
    • Full patches: Requires vCenter Server appliance version 6.7 or above.
  7. How to authenticate with vCenter using OAuth

    master

    To authenticate with a vCenter Server (VC 7.0+) using OAuth, follow these conceptual steps:

    1. Identify the Identity Provider: Find the Identity Provider associated with your vCenter IP/hostname (use list_external_identity_providers.py to discover this).
    2. Locate Endpoints: Extract the auth, discovery, and token endpoints from the Identity Provider object.
    3. Acquire Access Token: Request an access token from the endpoints using the parameters specific to your chosen grant type (e.g., client credentials or authorization code).
    4. Exchange for SAML: Convert the acquired access/ID token into a SAML token (use exchange_access_id_token_for_saml.py for this step).
    5. Login: Use the resulting SAML assertion to log in to vCenter as a bearer token.
  8. Use Defer History Data Import APIs

    master

    The Defer History Data Import feature allows historical data and performance metrics to be imported in the background after a vCenter upgrade, reducing total downtime. This feature is specifically for upgrades or migrations from vCenter versions 6.0 and 6.5 that use an external database.

    You can manage the import process using the following operations:

    • Check the status of the defer history data import.
    • Pause the defer history data import.
    • Resume the defer history data import.
    • Cancel the defer history data import.
  9. Use Discovery and Plan APIs for lifecycle management

    master

    The Discovery and Plan APIs allow for managing the lifecycle of VMware products (vSphere, vSAN, ESXi, etc.) within a VCSA environment. The feature is divided into three functional areas:

    1. Discovery: Used to manually add and manage VMware products in the catalog.
    2. Report: Used to download reports generated by interoperability or pre-check operations.
    3. Update Client: Used to list available updates/upgrades (currently supporting ESXi and vCenter) and plan patches or upgrades.

    Testbed Requirement:

    • Requires vCenter Server appliance version 7.0 or above.
  10. Understand vLCM Cluster Hardware Compatibility (HCL) APIs

    master

    The vSphere Lifecycle Manager (vLCM) Hardware Compatibility (HCL) APIs allow you to verify that driver and firmware components for hardware components (specifically those used by vSAN) are certified against your current ESXi version and present in the vSAN VCG.

    Using the Hardware Compatibility Details API, you can retrieve:

    • Overall cluster compliance status.
    • Base image version.
    • PCI device compliance.
    • Storage device compliance.
    • Specific supported devices within detailed sections.

    Feature Support by Release

    • vSphere 7.0: IO Controllers
    • vSphere 7.0 U3: IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller
    • vSphere 8.0: IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller, Intel VMD NVMe, RDMA NIC