VMware Solutions Discussions

Accessing VSC information through vmware api/powercli?

tflammger
3,223 Views

Our VDI team is interested in being more cognizent of where datastores live in the cluster so that patching and boot storms don't swamp one node. We have VSC7 appliance deployed which gives all the information they need into the web client by making the aggregate location of a datastore known. This needs to be built into thier automation tools however, which run on .NET and powercli through the vmware APIs. Not having any experience with how vcenter works I'm pretty in the dark here, is there a way to get at the aggregate information VSC provides via powercli?

 

This is specifically what they're looking to locate:

details.png

2 REPLIES 2

asulliva
3,179 Views

Is using the NetApp PowerShell Toolkit an option? 

 

Would be very simple to map the VMware datastore NFS mount to the ONTAP SVM LIF + junction path to get the volume (and aggr) info.  For block based datastores, it's not much more difficult...use the LUN's naa ID to reverse engineer the ONTAP LUN serial number:

 

$naluns = Get-NcLun
$ds = Get-Datastore | ?{ $_.Type -eq "VMFS" }

$ds | %{
    Write-Host "Finding LUNs for datastore $($_.Name)" 
    $luns = $_ | Get-ScsiLun | ?{ $_.CanonicalName -match "naa.600a0980*" }

    if ($luns.length -gt 0) {
        Write-Host "    Found $($luns.length) paths"
        $completed = @()

        $luns | %{ 
            if (!$completed.Contains($_.CanonicalName)) {
                $hexSerial = ($_.CanonicalName).Substring(12)
                $serial = for ($i = 0; $i -lt $hexSerial.length; $i += 2) {
                    [char][int]::Parse($hexSerial.substring($i,2), 'HexNumber')
                }

                $ntapSerial = $serial -join ""
                Write-Host "  NetApp LUN serial is: $($ntapSerial)"

                $ntapLun = $naluns | ?{ $_.SerialNumber -eq $ntapSerial }
                Write-Host "    NetApp SVM: $($ntapLun.Vserver)"
                Write-Host "    LUN Path: $($ntapLun.Path)"
                $completed += $_.CanonicalName
            }
        }
    }
}

Note that I think ONTAP has two or three different naa IDs, so you'd want to include all of them in the expression above.

 

Hope that helps.

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

tflammger
3,155 Views

Thanks for the suggestion (thankfully our vmware environment is all NFS so no LUN ID monkeybusiness required).  

I'll have to run it by the developers, see how complicatd it makes things adding another API to their workspace.

No way to do this with native vmware commands though?

 

Public