VMware Cloud Community
schubertr
Enthusiast
Enthusiast
Jump to solution

vSAN Host - List VMs with Data on It

I have a requiremement to create a dashboard that allows me to select from a list of vSAN hosts. Once it is selected, I should see a list of VMs that have their data on any of the vSAN disks on it.

I'm told this can be done in vSphere using vSAN object mapping, but it is very cumbersome, so I'm looking to see if vROPs is pulling this data from somewhere. 

I did notice in the Object browser, that if I select the vSAN adapter, and then the Capacity and Cache disks, they do show me a heatmap that shows some VMs. Not sure if these are correct, but even so, how can I show them as a list in a nice dashboard?

I'm on vROPs 8.10.1

TIA

Labels (1)
  • i

0 Kudos
1 Solution

Accepted Solutions
schubertr
Enthusiast
Enthusiast
Jump to solution

The below does seem to work in Powershell, I need to provide the vCenter, the login ID/Password and the vSAN host whose objects I'm looking for. I think it needs the latest version of PowerCLi, I'm still testing though so not sure yet... I'm still looking to do this with REST APIs though, need to get vRO workflows/actions in JavaScript (company requirement).

# Prompt for vCenter Server and credentials
$VIServer = Read-Host "Enter the vCenter Server"
$Credential = Get-Credential

# Prompt for the hostname
$HostName = Read-Host "Enter the vSAN hostname"

# Connect to vCenter Server
Connect-VIServer $VIServer -Credential $Credential

# Get all vSAN components
$VsanComponents = Get-VsanComponent

# Retrieve distinct VM names with data on the specified host, excluding templates
$DistinctVMNames = $VsanComponents |
    Where-Object { $_.VsanObject.VM -ne $null -and $_.VsanDisk.VsanDiskGroup.VMHost.Name -eq $HostName } |
    Select-Object -ExpandProperty VsanObject |
    Select-Object -ExpandProperty VM |
    Where-Object { $_.GetType().Name -eq "VirtualMachineImpl" -and $_.Name } |
    Select-Object -ExpandProperty Name -Unique

# Output the distinct VM names
foreach ($VMName in $DistinctVMNames) {
    Write-Host "VM Name: $VMName"
}

# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false

View solution in original post

0 Kudos
9 Replies
KabirAli82
Expert
Expert
Jump to solution

When you say "VMs that have their data on any of the disks". Do you also want to see VMs that have partially data on any of the disks? vSAN could break up a VMDK file into multiple smaller ones and store them on different hosts/disk groups. I don't think vROps will show you that.

The best that you could do is create a view of the vSAN Cluster (not vSAN host). Then use that view to feed another view (host view) where you see the hosts. Then have the host view show the VMs on that host.


Was I helpful? Give a kudo for appreciation!
Braindumping @ http://kablog.nl/
Tweeting @ https://twitter.com/_Kabir_Ali_
0 Kudos
schubertr
Enthusiast
Enthusiast
Jump to solution

Yeah that shows VMs on a host, I basically want to see a host and VMs (even with partial VMDKs or RAID replicas) on it. Our internal vSphere Team mentioned they can see it on vCenter as vSAN object tagging, but it is very cumbersome to look at. 

I'm not sure what they mean by cumbersome, but I think it probably shows Disk IDs which then need to be mapped to the actual VMDKS, and from there the VMs 🙂 

0 Kudos
KabirAli82
Expert
Expert
Jump to solution

You can use the OOB dashboard "vSphere Compute Inventory" as a starting point and make the changes you need. I've linked the widgets together for you, so that you have a good starting point.

 
 

Was I helpful? Give a kudo for appreciation!
Braindumping @ http://kablog.nl/
Tweeting @ https://twitter.com/_Kabir_Ali_
0 Kudos
schubertr
Enthusiast
Enthusiast
Jump to solution

Hmm, this seems to relate VMs to Hosts more in terms of where they are running. However, I need to check if I can get or see any Property that holds the Virtual Objects in vSAN, 

Normally in vSphere UI: -
1) Go to the Cluster and click the Monitor Tab
2) Expand vSAN and select Virtual Objects
3) Expand any VM under that and check any of its disks
4) The "View Placement Details" gets enabled, and when you click this, it shows on which host the particular disk has data on. Depending on RAID and storage policies, a disk may be on multiple hosts

0 Kudos
KabirAli82
Expert
Expert
Jump to solution

Yeah I thought you'd be looking for something like that in vROps. But that's not possible for vROps as it looks at objects and their relationship in a different way then vCenter does.


Was I helpful? Give a kudo for appreciation!
Braindumping @ http://kablog.nl/
Tweeting @ https://twitter.com/_Kabir_Ali_
0 Kudos
schubertr
Enthusiast
Enthusiast
Jump to solution

I'll need to check if I can get this info using PowerCli, maybe use that to populate vROPs using some automation

0 Kudos
KabirAli82
Expert
Expert
Jump to solution

Oh that would be awesome! Let me know if I can help in any way. I think this can be very helpful for the community.


Was I helpful? Give a kudo for appreciation!
Braindumping @ http://kablog.nl/
Tweeting @ https://twitter.com/_Kabir_Ali_
0 Kudos
schubertr
Enthusiast
Enthusiast
Jump to solution

The below does seem to work in Powershell, I need to provide the vCenter, the login ID/Password and the vSAN host whose objects I'm looking for. I think it needs the latest version of PowerCLi, I'm still testing though so not sure yet... I'm still looking to do this with REST APIs though, need to get vRO workflows/actions in JavaScript (company requirement).

# Prompt for vCenter Server and credentials
$VIServer = Read-Host "Enter the vCenter Server"
$Credential = Get-Credential

# Prompt for the hostname
$HostName = Read-Host "Enter the vSAN hostname"

# Connect to vCenter Server
Connect-VIServer $VIServer -Credential $Credential

# Get all vSAN components
$VsanComponents = Get-VsanComponent

# Retrieve distinct VM names with data on the specified host, excluding templates
$DistinctVMNames = $VsanComponents |
    Where-Object { $_.VsanObject.VM -ne $null -and $_.VsanDisk.VsanDiskGroup.VMHost.Name -eq $HostName } |
    Select-Object -ExpandProperty VsanObject |
    Select-Object -ExpandProperty VM |
    Where-Object { $_.GetType().Name -eq "VirtualMachineImpl" -and $_.Name } |
    Select-Object -ExpandProperty Name -Unique

# Output the distinct VM names
foreach ($VMName in $DistinctVMNames) {
    Write-Host "VM Name: $VMName"
}

# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false

0 Kudos
KabirAli82
Expert
Expert
Jump to solution

Sweet! I think your biggest challenge is going to be mapping the vSAN objects to objects in vROps.


Was I helpful? Give a kudo for appreciation!
Braindumping @ http://kablog.nl/
Tweeting @ https://twitter.com/_Kabir_Ali_
0 Kudos