December 22, 2024

vSAN Management API Cookbook for Python

Virtual SAN 6.2 has been out for a few months now. More and more customers are adopting Virtual SAN in many use cases including Tier 1 and business critical applications.

Virtual SAN leverages Storage Policy Based Management to individually tailor a virtual machine’s protection and performance profile. This lessens the burden of storage provisioning operations on administrators.

Deploying Virtual SAN is pretty simple. When using Virtual SAN Ready Nodes, or vSphere hosts with approved hardware, it is as easy launching a wizard and clicking next, next, next. Another option, is to use Virtual SAN in an Engineered Appliance, like VxRAIL, which includes additional management capabilities of many tasks.

Management of vSphere through tools other than the UI has been around for a while. Tools including the vSphere CLI, vSphere PowerCLI, vSphere Management API make management of vSphere very extensible. Virtual SAN Management in these tools has been somewhat limited until recently.

In Virtual SAN 6.2, a new Virtual SAN Management API was introduced. This API is an extension of the vSphere Management API. It gives administrators/developers the ability to manage all aspects of Virtual SAN via API.

Python CookbookIn an effort to get some examples together, we’ve put together a cookbook with a few sample code snippets, illustrating just a few of the things that can be accomplished using the Virtual SAN Management API.

It focuses on using Python to perform tasks like deploying Virtual SAN, configuring a Stretched Cluster, and perform an On-Disk Format upgrade.

These are some of the most common tasks that administrators perform when deploying or managing Virtual SAN.

Each “recipe” illustrates the actions an administrator might perform in the vSphere Web Client and provides some sample code to do the same in Python. While the cookbook does not provide the final code, it does reference the VMware Developer Center, where a copy of the script can be found.

The vsanDeploy.py sample script can be seen tagging VMkernel interfaces, enabling Virtual SAN on each cluster, and claiming disks.

The upgradeVSAN.py sample script can be seen here upgrading a Hybrid VSAN cluster and an All-Flash cluster. Notice also that deduplication and compression are enabled in the All-Flash cluster in conjunction with the upgrade.

 

The Virtual SAN Management API isn’t limited to Python as the only language it can be used with. There are also SDKs for other languages including Ruby, Perl, C#, and Java.

Sample scripts for the Virtual SAN Management API, as well as the vSphere API and more, can be found at the VMware Developer Center.

Get the Virtual SAN Management API Cookbook for Python here: http://www.vmware.com/content/dam/digitalmarketing/vmware/en/pdf/techpaper/VSAN-API-Cookbook-for-Python.pdf

Look for code provided by the community and get started automating Virtual SAN today!

This was originally posted on the VMware Virtual Blocks site: https://blogs.vmware.com/virtualblocks/2016/07/27/vsan-api-cookbook-for-python/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.