WilliamLam.com

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

Exploring VSAN APIs Part 1 - Enable VSAN Cluster

03.04.2014 by William Lam // Leave a Comment

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

vsan-cluster-mgmt-0
To enable VSAN, you can run the "enable" operation along with an optional --autoclaim option which defaults to enable for automatic claiming:

./vsanClusterManagement.pl --server vcenter55-1 --operation enable --cluster VSAN-Cluster

vsan-cluster-mgmt-1
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.

vsan-cluster-mgmt-2
If login to your vSphere Web Client, we should see that VSAN has been successfully enabled just like you would if you were to manually perform the operation through the UI.

vsan-cluster-mgmt-3
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.

  1. Exploring VSAN APIs Part 1 – Enable VSAN Cluster
  2. Exploring VSAN APIs Part 2 – Query available SSDs
  3. Exploring VSAN APIs Part 3 – Enable VSAN Traffic Type
  4. Exploring VSAN APIs Part 4 – VSAN Disk Mappings
  5. Exploring VSAN APIs Part 5 – VSAN Host Status
  6. Exploring VSAN APIs Part 6 – Modifying Virtual Machine VM Storage Policy
  7. Exploring VSAN APIs Part 7 – VSAN Datastore Folder Management
  8. Exploring VSAN APIs Part 8 – Maintenance Mode
  9. Exploring VSAN APIs Part 9 – VSAN Component count
  10. Exploring VSAN APIs Part 10 – VSAN Disk Health

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

Why you should rename the default VSAN Datastore name

02.18.2014 by William Lam // 10 Comments

Something that I have noticed early on when working with VSAN is that the VSAN datastore name is automatically selected for you and will always default to vsanDatastore. This is not a bad thing as it simplifies the setup of VSAN which is already dead simple. To enable VSAN, it is simply checking a box in the configuration of your vSphere Cluster just like you would when enabling vSphere DRS or HA.

From an operational standpoint, I think this can be a potential issue. What happens when you have a multiple VSAN Clusters under the same vSphere Datacenter object or even across different vSphere Datacenter objects? I recently came across this while re-building one of my lab environments, can you spot the problem in the screenshot below?

Here we have two VSAN Datastores within the same vSphere Datacenter. Datastore names under a single vSphere Datacenter must be unique. I am sure some of you may have already experienced this with local datastore names using the default "datastore1". vSphere will automatically append "(n)" to the name where n is the number of instances seen in the environment.

In this next example, we have two VSAN Datastores but they are split across two vSphere Datacenters. Since unique name is enforced at the Dataenter boundary, it is even worse now because you have the same name used across both VSAN Clusters.

Even though a user will most likely drill down into a specific environment when provisioning a Virtual Machine, I think it is critical to have a good naming scheme for your infrastructure. What happens when you have someone run an audit of all your VMs and all they showed for their datastore name was "vsanDatastore" and you had multiple VSAN Clusters? Would it not be more useful to have a bit more details in the datastore name to help map it back to some logical/physical container that is a bit more meaningful? I personally would think so and would help in times of troubleshooting where time is of the essence. 

Luckily this can easily be remediated since a VSAN Datastore operates just like any other datastore in which you can rename it. VSAN itself does not use the name to uniquely identify the datastore, it implements a unique UUID for each of the VSAN datastores. Simply renaming the VSAN Datastore to something more appropriate such as including the name of the vSphere Cluster will come a long when you need to correlate a Virtual Machine back to a particular compute/storage resource. 

I wonder if it would be a useful to have a feature in VSAN to automatically append the vSphere Cluster name to the default VSAN Datastore name? What do you think? 

Categories // VSAN Tags // ESXi 5.5, VSAN, vsanDatastore, vSphere 5.5

vdq - A useful little VSAN utility

02.14.2014 by William Lam // 9 Comments

While re-building a couple of my Nested ESXi VMs for VSAN using some newer builds, I came across a nifty little VSAN utility called vdq which I assume stands for either VMware Disk Query or VSAN Disk Query. I actually found this utility by accident while poking around in the ESXi Shell as I was looking for a quick way to inspect the disks and I know there are a couple other methods which are officially supported by VMware such as RVC or ESXCLI.

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

vdq provides two useful commands, one that queries the disks on your ESXi host and show whether they are eligible or not for VSAN. The other is the disk mappings once VSAN has been configured and enabled on your ESXi host.

To query the disks on your ESXi host, you can run the following command: vdq -q

You will be presented with a lot of useful information such as the disk device name, VSAN node UUID, the state of the disk (whether or not it can be used by VSAN or if it is already in use), reason which includes more details, whether the disk is an SSD or HDD and also if the device is in a PDL (Permanent Device Loss) state.

You can also specify the -H option which makes the output a bit more readable as the default output is using Python. In this next screenshot, if we enable VSAN through the vSphere Web Client we now see that the VSANUUID property is now populated and the state of the disks have now changed.

The next command that is also handy once VSAN is enabled is to quickly get the VSAN disk group mapping by running the following command: vdq -i

With this command you can quickly find out the SSD that is front-ending the set of HDD for a given disk group. This command came in handy while re-building my ESXi hosts as I wanted to blow away the existing VSAN configuration. To do so, you would need to use ESXCLI and by leveraging vdq, I was able to quickly get the disk mappings and more importantly a command I could easily remember.

In general, I would still recommend using either ESXCLI or RVC which is already pretty simple to use but thought I share this little tip if you ever need to just quickly inspect an ESXi host for VSAN.

Categories // VSAN Tags // ESXi 5.5, vdq, VSAN, vSphere 5.5

  • « Previous Page
  • 1
  • …
  • 47
  • 48
  • 49
  • 50
  • 51
  • …
  • 53
  • 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

 

Loading Comments...