WilliamLam.com

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

Exploring VSAN APIs Part 7 - VSAN Datastore Folder Management

03.26.2014 by William Lam // 1 Comment

In addition to storing your Virtual Machines, you may also want to use the VSAN Datastore to store your operating system ISOs in case you do not have an external repository and would like to keep everything local. If you use the vSphere Web Client to perform this operation, you will notice that you will need to first create a top-level directory before you can upload an ISO or a file to the VSAN Datastore.

vsan-datastore-directory-management-0
The reason for this is that the VSAN Datastore does not support files in the top level directory, so you will have to first create a top-level directory and then upload the files under that directory. To create these top-level directories, a new DatastoreNameSpaceManager is introduced in the vSphere 5.5 API which manages the creation and deletion of these directories. Once these top-level directories exists, you can then use the regular fileManager API to manage your files and sub-directories within the VSAN Datastore. To demonstrate the creation of a top-level directory and sub-directory in a VSAN Datastore, I have created a sample vSphere SDK for Perl script called vsanDatstoreFolderMgmt.pl

 Disclaimer:  These scripts are provided for informational and educational purposes only. It should be thoroughly tested before attempting to use in a production environment.

In this example, I will create a top-level directory in the VSAN Datastore called ISO and then a sub-directory under that called Linux by running the following command:

./vsanDatstoreFolderMgmt.pl --server vcenter55-1.primp-industries.com --username root --vsan-datastore vsanDatastore --root-folder ISO --sub-folder Linux

vsan-datastore-directory-management-1
The script will first call the DatastoreNameSpaceManager CreateDirectory() API method which will then create the top-level directory and then using the fileManager's MakeDirectory() API method to create the sub-directory. If we take a look at our VSAN Datastore using the vSphere Web Client, we can see that our new top-level directory has been created along with our sub-directory.

vsan-datastore-directory-management-2
For deleting sub-directories and the top-level directories, there is the DeleteDatastoreFile_Task() and DeleteDirectory() API method respectively.

  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 // Uncategorized, VSAN, vSphere 5.5 Tags // folder, VSAN, vsanDatastore, 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

  • « Previous Page
  • 1
  • 2

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...