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 // 2 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
  • How to bootstrap vSAN Express Storage Architecture (ESA) on unsupported hardware?

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

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 technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

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

Recent

  • Automated ESXi Installation with a USB Network Adapter using Kickstart 02/01/2023
  • How to bootstrap ESXi compute only node and connect to vSAN HCI Mesh? 01/31/2023
  • Quick Tip - Easily move or copy VMs between two Free ESXi hosts? 01/30/2023
  • vSphere with Tanzu using Intel Arc GPU 01/26/2023
  • Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS) 01/25/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...