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.
Jeff Creek says
Nice article.
Typo - ' . . . datastore options for vLCS is actually much richer when using the vSphere API. '
William Lam says
Thanks for catch Jeff. Just fixed
Anthony Furr says
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?
Raf says
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 ...
Peter Anderson says
When I use this code or the code from code capture it always results in the vCLS continually redeploying. In the GUI it looks fine. If I delete it from the GUI and then add the vSAN datastore it works fine.