WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple

VMware VSAN APIs

02.11.2014 by William Lam // 15 Comments

For customers who are currently evaluating VMware VSAN, the vSphere Web Client is the primary interface for managing and configuring VSAN. However, these exact same VSAN operations can also be accessed programmatically from an Automation perspective. Given that I had spent quite a bit of time playing with VSAN in the lab and exploring some of its APIs, I thought it might be useful to share some of the common VSAN operations mapped to their respective APIs.

There are two main categories of operations that you should be aware of when working with VSAN:

  • VSAN specific operations
  • VM Storage Policy operations

VSAN Operations

The VSAN specific operations are available as part of the vSphere 5.5 API and the list below are the supported operations:

Enable/Disable VSAN on a vSphere Cluster (automatic claiming):

  • Use the ReconfigureComputeResource_Task() and set spec->vsanConfig->enabled to either true or false & spec->vsanConfig->defaultConfig->autoClaimStorage to true

Manual Disk Claiming for an ESXi host:

  • Each ESXi host provides a vsanSystem manager at configManager->vsanSystem which provides the following methods for disk management
    • AddDisks_Task()
    • InitializeDisks_Task()
    • QueryDisksForVsan()
    • QueryHostStatus()
    • RemoveDisk_Task()
    • RemoveDiskMapping_Task()
    • UpdateVsan_Task()

Enable VSAN traffic type for a VMkernel interface

  • Use the ReconfigureComputeResource_Task() and set spec->vsanHostConfigSpec->HostSystem to the ESXi host you wish to configure and  spec->vsanHostConfigSpec->networkInfo->port->device to the specific VMkernel interface you wish to enable VSAN traffic type on

Internal VSAN manager for accessing low level CMMDS (Clustering Monitoring, Membership and Directory Services), object & disk management APIs:

  • Each ESXi host provides a vsanInternalSystem manager at configManager->vsanInternalSystem which provides the following methods for working with the lower level system of VSAN
    • QueryCmmds()
    • QueryObjectsOnPhysicalVsanDisk()
    • QueryPhysicalVsanDisks()
    • QueryVsanObjects()

Change the VM Storage Policy for a Virtual Machine Home OR Virtual Machine Home and Virtual Disk:

  • Use the ReconfigVM_Task() and set spec->vmProfile to the VM Storage Policy ID

Change the VM Storage Policy for Virtual Machine Virtual Disk:

  • Use the ReconfigVM_Task() and set spec->deviceChange->device to the specif Virtual Disk to be reconfigured and set  spec->deviceChange->vmProfile to the VM Storage Policy ID

Enter Maintenance Mode for an ESXi host in a VSAN Cluster:

  • Use the EnterMaintenanceMode_Task() and set spec->
    maintenanceSpec->vsanMode->objectAction to the specific data accessibility mode defined here

Create and Delete directories on a VSAN Datastore:

  • Use the DatastoreNamespaceManager which provides the following two methods
    • CreateDirectory()
    • DeleteDirectory()

SPBM

For VM Storage Policies, VSAN leverages the SPBM (Storage Policy Based Management) framework which allows administrators to create policies that define specific storage capabilities such as performance and reliability that can then be applied to a Virtual Machine. The SPBM API is exposed as a separate API endpoint in vCenter Server and will be required if you wish to create additional VM Storage Policy leveraging VSAN storage capabilities.

Query list of available VM Storage Profiles defined:

  • Use PbmQueryProfile()

Create VM Storage Policy:

  • Use PbmCreate()

Delete VM Storage Policy:

  • Use PbmDelete()

Check VM Storage Policy Compliance:

  • Use PbmCheckCompliance()

Given a Virtual Machine Home or Virtual Disk, provide associated VM Storage Profile:

  • Use PbmQueryAssociatedEntity()

Given a VM Storage Profile, provide the associated Virtual Machine Home or Virtual Disk:

PbmQueryAssociatedEntity
  • Use PbmQueryAssociatedProfiles()
PbmQueryAssociatedProfiles

Hopefully this provides a good overview of some of the common VSAN / SPBM operations and their associated API methods. If I have some spare cycles, I may create some sample scripts leveraging some of these API methods. In the meantime, you can check out these RVC (vSphere SDK for Ruby) modules leveraging both VSAN and SPBM APIs here and here.

Additional Resources:

  • If you wish to evaluate VSAN and its associated APIs, please sign up for the public beta here.
  • Sign up for a special VSAN event here
  • VM Storage Policy APIs aka Storage Profile APIs will be available in vSphere 5.5
  • SPBM (Storage Policy Based Management) MOB in vSphere 5.5

Categories // VSAN, vSphere 5.5 Tags // rvc, spbm, VSAN, vSphere 5.5, vSphere API

Having some fun with the Marvel Comics API & vSphere SDK for Python

02.10.2014 by William Lam // 2 Comments

As a child of the 80's, I still remember waking up super early on a Saturday morning to watch some of my favorite cartoons including Transformers, GI Joe, Ninja Turtles and many of the Marvel cartoon series. Last week I saw an interesting tweet from our former VMware CTO, Steve Herrod:

It looks like Marvel has just released a Marvel Comics REST API which allows developers to access the entire Marvel Comics Universe and build custom applications and websites with that data. So, you might be wondering what does this have to do with VMware and virtualization? Well, when I heard about this API, I knew I had to find a way to incorporate this into a cool VMware project.

I decided to create a sample vSphere SDK for Python (also known as pyvmomi) script that would allow a user to specify a number of random Marvel Characters to select from the Marvel database and then automatically create dummy VMs based on those names which could be used for testing. There were a variety of VMware SDK's (Perl, Ruby, PowerCLI, Java, etc) that I could have used, but I opted for the vSphere SDK for Python given my Python skills were not very strong. This also gave me a good reason to play around with our Python SDK.

There are a couple of things you will need to setup before you can use the sample script:

  1. Setup a Marvel API key
  2. Install vSphere SDK for Python, you can take a look here.
  3. Download the create_random_marvel_vms.py

Disclaimer: There is not much error handling built into the sample script, please use at your own risk.

You will need to edit the script and replace the following two variables: marvel_public_key & marvel_private_key with the API key after creating an account on Marvel's website. One thing I really like about the Marvel API and I know many other vendors also provide this which is an interactive API tester. This allows a user to explore and execute a particular API requests without writing a single line of code to get a better understanding of the results before one starts to develop their application.

To run the script, you will need to pass in the following parameters:

--host : Name of your vCenter Server (only tested with vCenter)
--user : User to login with
--password : Password for the user
--datastore : Name of the datastore in which VMs will be created in
--count : The number of Dummy VMs to create

Here is an example of running the script:

./create_random_marvel_vms.py --host vcenter --user root --password vmware --datastore mini-local-datastore-1 --count 10

As you can see from the screenshot above I have just created 10 random VMs where each name is a random Marvel character extracted using a GET request on /v1/public/characters. If we head over to our vSphere Web Client, we should now see our 10 newly created VMs which contain 1vCPU and 128MB of memory. To keep things simple, I did not add a vDisk but you can easily tweak the dummy VM configuration based on your requirements.

Disclaimer: Data provided by Marvel. © 2014 Marvel

Categories // Uncategorized Tags // createvm, marvel, python, pyVmomi, REST API, vmware

vSphere Web Client Plugin for Custom Attributes

02.07.2014 by William Lam // 19 Comments

I just learned about a very cool vSphere Web Client Plugin that was developed by a fellow vExpert, Patrick Haefner who shared this during the South Germany VMUG back in February of last year. The custom vSphere Web Client Plugin allows administrators to view Custom Attributes in the vSphere Web Client which is currently not available today. The Custom Attributes vSphere Web Client is hosted on the VMUG site and you will need to register to access the download page found here.

Disclaimer: This plugin is not officially supported by VMware, please use at your own risk.

To install the Custom Attributes plugin, you just need to extract the contents of the zip file and you will should see a directory called haif-customfields-ui. You will need to copy this directory to your vCenter Server which is running the vSphere Web Client. This plugin should work on both vSphere 5.1 and 5.5.

For Windows vCenter Server:

  1. Stop the vSphere Web Client service
  2. Copy haif-customfields-ui to C:\Program Files\VMware\Infrastructure\vSphereWebClient\plugin-packages
  3. Start the vSphere Web Client service

For VCSA (vCenter Server Appliance)

  1. Stop the vSphere Web Client service by running /etc/init.d/vsphere-client stop
  2. Copy haif-customfields-ui to /usr/lib/vmware-vsphere-client/plugin-packages
  3. Start the vSphere Web Client service by running /etc/init.d/vsphere-client start

Once the vSphere Web Client has been started, you can now login and for Virtual Machines or ESXi hosts which have Custom Attributes, you should now see a new portlet displaying the Custom Attributes as seen in the screenshot below.

I think this is a really cool plugin and shows how extensible the vSphere Web Client is by leveraging the vSphere Web Client SDK. With a bit of imagination, you can pretty much build anything! Though today Patrick's plugin only allows you to view the Custom Attributes, perhaps if there is enough requests, he may add the ability to modify Custom Attributes. Awesome work Patrick and thanks for sharing it with the community!

Big thanks to Ruediger M. who works as a VMware SE in Germany for sharing this awesome information. This is definitely a plugin I will be installing in my environments 🙂

Categories // vSphere Web Client Tags // custom attributes, plugin, tagging, vSphere, vsphere web client

  • « Previous Page
  • 1
  • …
  • 419
  • 420
  • 421
  • 422
  • 423
  • …
  • 560
  • Next Page »

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025