I want to assign a vSphere with Tanzu license to a Supervisor Cluster programmatically. I can successfully assign licenses for vCenter, vSphere and vSAN to the respective objects, but I cannot get it to work for Tanzu licenses. It does not work with Ansible and I cannot fully get it to work with PowerCLI.
After some research and a lot of digging (I sniffed the traffic when assigning the license manually through the vSphere Web Client), I came up with the following code:
$lm = Get-View -Id LicenseManager
$lam = Get-View -Id $lm.LicenseAssignmentManager
$ClusterMoID = (Get-Cluster -Name "ClusterDisplayName").ExtensionData.MoRef.Value
$lam.UpdateAssignedLicense("wcp-$($ClusterMoID)-7e0ec2d0-5eb4-4f84-b681-bd72c93e83e1", 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX', $null)
With this code I can assign a license. But it is currently impossible for me to get/guess the correct entity ID. Let me explain: The above code uses the UpdateAssignedLicense method. For other objects, like a cluster, you can retrieve quite human readable entity IDs like domain-c7, for example. The entity ID for the corresponding Supervisor Cluster will then be wcp-domain-c7. But this ID does not work when trying to assign a license. Through inspection of the POST requests of the vSphere Web Client when assigning a license to a Supervisor Cluster manually, I found out, that it uses a different entity ID in the format wcp-domain-c7-SOME-WEIRD-UUID. If I just copy & paste that entity ID to UpdateAssignedLicense, I can successfully assign that license. But I do not find a away to get that entity ID with that UUID.
So, does someone know another way to assign a vSphere with Tanzu license to a Supervisor Cluster programmatically or does someone know how to get the entity ID of a Supervisor Cluster with that UUID?
I am using vSphere 7.0 U3, btw.
Have you checked if that UUID is available under
(Get-WMCluster -Cluster "MyCluster").ExtensionData
You might also give the REST API a try, for example the Get Clusters Topology call.
Via PowerCLI with
Invoke-GetClusterNamespaceManagementTopology -Cluster "MyCluster"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Unfortunately,
(Get-WMCluster -Cluster "ClusterDisplayName").ExtensionData
does not contain any UUIDs.
Invoke-GetClusterNamespaceManagementTopology -Cluster "ClusterEntityId"
returns a UUID, but it is not the UUID of the wcp-domain-c7-UUIDUUID-UUID-UUID-UUID-UUIDUUIDUUID object. Having a look at the vSphere Web Client again, that entity ID with that UUID seems to be the ID of an "Asset" (com.vmware.license.asset). Is there a way to query assets?
To dig even deeper, is there a way to lookup UUIDs in vCenter? If I can lookup that UUID, I may find objects that I can lookup instead to get to that UUID.
Additional info: I was curious, why I can assign licenses for vSphere, vCenter and vSAN by the entity ID without any UUID. I checked vSphere Web Client again and observed, that the vSphere Web Client uses <ENTITY_ID>-<UUID> for all license assets. E. g. for ESXi hosts: host-11-UUIDUUID-UUID-UUID-UUID-UUIDUUIDUUID. And that UUID is the same for all license assets (also for the Supervisor Cluster). So, where does it come from? Is it a bug, that I cannot license a Supervisor Cluster just by its entity ID (e. g. wcp-domain-c7) like all other assets?
I don't know, perhaps you should ask your TAM or open an SR
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can get guid using command:
/usr/lib/vmware-vmafd/bin/vmafd-cli get-ldu --server-name localhost
$TanzuClusterID = sshpass -p $vc_root_password ssh -o "StrictHostKeyChecking=no" "$vc_root_user@$vcenter_server" "/usr/lib/vmware-vmafd/bin/vmafd-cli get-ldu --server-name localhost"
$ClusterMoID = (Get-Cluster -Name "$cluster_name").ExtensionData.MoRef.Value
[string]$tz_entry_id = "wcp-" + $ClusterMoID + "-" + $TanzuClusterID
$license_manager = (Get-View $Global:DefaultVIServers.ExtensionData.content.LicenseManager)
$license_manager.AddLicense($tanzu_license,$null)