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:
Create VM Storage Policy:
- Use PbmCreate()
Delete VM Storage Policy:
- Use PbmDelete()
Check VM Storage Policy Compliance:
Given a Virtual Machine Home or Virtual Disk, provide associated VM Storage Profile:
Given a VM Storage Profile, provide the associated Virtual Machine Home or Virtual Disk:
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