A couple of weeks back I had provided an overview on some the most common VSAN operations and the specific vSphere APIs that were required to perform the operation. It was no surprise to me that there were some folks already interested in automating the management and consumption of VSAN, I know that was one of the first thing I thought about when playing with VSAN in my home lab.
The great thing about having an API is that it can be consumed in a variety of ways, you can use one of the vSphere SDKs supporting languages like Java, .NET, Perl and even PowerShell with the new VSAN specific cmdlets. I thought it might be useful to explore some of these APIs in greater detail and even provide some working sample scripts that can help others looking to automate VSAN. I know for myself, I learn best when I can see working examples.
Disclaimer: These scripts are provided for informational and educational purposes only. It should be thoroughly tested before attempting to use in a production environment.
VSAN is enabled at the vSphere Cluster level and just like you do today with vSphere HA/DRS, it is just a couple of clicks. To demonstrate the ability to enable, disable and to check current state of VSAN on a vSphere Cluster, I have created the following sample vSphere SDK for Perl script called vsanClusterManagement.pl
There is a vsanClusterConfigInfo property that is part of a vSphere Cluster (ComputeResource) that specifies whether VSAN is enabled and if it is configured to auto-claim or manual mode. To make changes to a vSphere Cluster, you will need to use the ReconfigureComputeResource_Task() method which is demonstrated in the sample script.
To check the current VSAN configuration for a given vSphere Cluster, you can run the "query" operation:
./vsanClusterManagement.pl --server vcenter55-1 --operation query --cluster VSAN-Cluster
./vsanClusterManagement.pl --server vcenter55-1 --operation enable --cluster VSAN-Cluster
If we re-run the query operation, you will now notice there is more information about the VSAN Cluster including VSAN Cluster UUID, the current claim mode and all the ESXi nodes in the cluster along with their VSAN NODE UUID.
If you decided to select "manual" instead of having VSAN automatically claim the SSD and HDD for you, then you will probably need to know which disks are eligible for VSAN. In Part 2 of this series, we will take a look a look at how we can identify available SSDs for use with VSAN.
- Exploring VSAN APIs Part 1 – Enable VSAN Cluster
- Exploring VSAN APIs Part 2 – Query available SSDs
- Exploring VSAN APIs Part 3 – Enable VSAN Traffic Type
- Exploring VSAN APIs Part 4 – VSAN Disk Mappings
- Exploring VSAN APIs Part 5 – VSAN Host Status
- Exploring VSAN APIs Part 6 – Modifying Virtual Machine VM Storage Policy
- Exploring VSAN APIs Part 7 – VSAN Datastore Folder Management
- Exploring VSAN APIs Part 8 – Maintenance Mode
- Exploring VSAN APIs Part 9 – VSAN Component count
- Exploring VSAN APIs Part 10 – VSAN Disk Health