VMware {code} Community
skehrer1974
Contributor
Contributor

Perl SDK - return list of clusters for DC

I am new to using Perl and the SDK. I am having an issue with a task that was simple with PowerCLI, but for some reason I am having an issue. I am building and interactive tool for deploying VMs from an OVA. The idea is that a user will start the script. It will prompt them for credentials and vCenter IP. This part works and I connect without issue. Next I want it to query vCenter for a list of the managed clusters and create a menu to allow the user to select the cluster they would like to interact with and store it as a variable. I have done this with PowerCLI, but as I said I am having difficulty using the Perl SDK for this. Here's my powercli code

# Define cluster

Write-Host "`nPlease select the desired cluster from the list below:`n"

$myClusters = Get-Cluster

$menu = @{}

for ($i=1;$i -le $myClusters.count; $i++) {

    Write-Host "$i. $($myClusters[$i-1].name)"

    $menu.Add($i,($myClusters[$i-1].name))

    }

Write-Host "`n"

[int]$ans = Read-Host 'Enter selection'

$selection = $menu.Item($ans)

Write-Host "`nThe"$selection" cluster was selected. Querying cluster for hosts and VMs..."

$clusterName = $selection

# End define cluster

Reply
0 Kudos
1 Reply
samsvmware
Enthusiast
Enthusiast

Try simpleclient.pl script with entity type . It will list the entities which you need.

Reply
0 Kudos