WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS)

Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS)

01.25.2023 by William Lam // 4 Comments

One of the recent features of the vSphere Cluster Services (vCLS) is the ability configure the vSphere Datastores that vCLS is allowed to use to provision the required service VMs, which can be on a vSphere Cluster under Configure->vSphere Cluster Services->Datastores as shown in the screenshot below.


In addition to the vSphere UI, you can also programmatically update this configuration using the vSphere API and with tools like PowerCLI as one of the interfaces to the API.

While responding to a user with a code example, I came to learn that managing the datastore options for vCLS is actually much richer when using the vSphere API. In addition to specifying the list of allowed datastores, you can also specify the list of datastores that are NOT allowed which might be easier to filter out or you can even specify the vSphere Tag category as a way to automatically indicate all datastores that can be used by vCLS. The vCLS datastore configuration is stored as part of the vSphere Cluster under SystemVMsConfigSpec, which you can see the three different options.

To demonstrate the original use case, the following PowerCLI snippet can be used to update a vSphere Cluster with the desired list of datastores that you want vCLS to use.

$clusterName = "Supermicro-Cluster"
$allowedVCLSDatastores = @("sm-vsanDatastore")

$cluster = Get-Cluster $clusterName

$allowedDatastores = @()
foreach ($datastoreName in $allowedVCLSDatastores) {
    $datastoreMoRefId = (Get-Datastore $datastoreName).ExtensionData.MoRef

    $tmp = New-Object VMware.Vim.ClusterDatastoreUpdateSpec
    $tmp.datastore = $datastoreMoRefId
    $allowedDatastores+=$tmp
}

$systemConfigSpec = New-Object VMware.Vim.ClusterSystemVMsConfigSpec
$systemConfigSpec.allowedDatastores = $allowedDatastores

$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.systemVMsConfig = $systemConfigSpec

$task = $cluster.ExtensionData.ReconfigureComputeResource_Task($spec, "modify")
$task1 = Get-Task -Id ("Task-$($task.value)")
$task1 | Wait-Task

Once the operation has completed, you can check via he vSphere UI or via vSphere API that you now have updated the datastore allowed list by running the following command:

(Get-Cluster $clusterName).ExtensionData.ConfigurationEx.SystemVMsConfig


I will leave it to reader as a learning exercise to explore the other two vCLS datastore configuration options including using vSphere Tag category or list of datastores that vCLS is not allowed to use.

More from my site

  • How to configure Hardware Compatibility List (HCL) database for vSphere Lifecycle Manager (vLCM) in an air-gapped environment?
  • How to automate checking for new vCenter Server updates in vSphere Lifecycle Manager (vLCM)?
  • Quick Tip - Downloading ESXi Image (ISO or ZIP) from vSphere Lifecycle Manager (vLCM)
  • Changes to vSphere Client Login UI customizations in vSphere 6.7
  • USB Network Native Driver Fling for ESXi 8.0 Update 1

Categories // Automation, PowerCLI, vSphere 7.0, vSphere 8.0 Tags // vCLS, vSphere 7.0, vSphere 8.0

Comments

  1. Jeff Creek says

    01/25/2023 at 1:00 pm

    Nice article.
    Typo - ' . . . datastore options for vLCS is actually much richer when using the vSphere API. '

    Reply
    • William Lam says

      01/25/2023 at 1:51 pm

      Thanks for catch Jeff. Just fixed

      Reply
  2. Anthony Furr says

    02/22/2023 at 5:36 pm

    I am in need of adding this to our ESXi host config automation. To leverage these namespaces, what version of PowerCLI do I need to be running?

    Reply
  3. Raf says

    03/13/2023 at 1:36 am

    Hello William,
    It seems this is not persistent across Vcenter reboot ....
    I did TagCategory Exclusions which worked flawlessly but this config disappear after a Vcenter reboot (VCSA 7.0U3J).

    I've just opened case 23414462603 at GSS ...

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC) across Private, Hybrid and Public Cloud

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Custom vCenter Server Role using vSphere Terraform Provider on VMware Cloud on AWS 06/05/2023
  • Will this Arm SoC work with ESXi-Arm? 06/02/2023
  • Converting VirtualBox VDI (Virtual Disk Image) to VMDK for use with ESXi 8.x 05/31/2023
  • Quick Tip - How to monitor when ESXi filesystem and partitions are filling up? 05/30/2023
  • DDR5 SODIMM capable kits for ESXi 05/30/2023

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 © 2023

 

Loading Comments...