Hi,
I have a requirement to storage vmotion VMs with size more than 500 GB from one cluster to another cluster . Before that I would like to create a report to check how many datastores in the destination cluster can accommodate how many 500+ GB size VMs.
Please help.
Like this you mean?
$vmSizeGB = 500
Get-Cluster -Name cluster2 |
Get-Datastore -PipelineVariable ds |
where{$_.ExtensionData.Summary.MultipleHostAccess -and $_.FreeSpaceGB -ge $vmSizeGB} |
ForEach-Object -Process {
$free = $ds.FreeSpaceGB
1..[math]::floor($ds.FreeSpaceGB/$vmSizeGB) | %{
'' | Select @{N='VMName';E={"VM$vmNr"}},
@{N='VMSizeGB';E={$vmSizeGB}},
@{N='Datastore';E={$ds.Name}},
@{N='TotalFreeSpaceGB';E={[math]::Round($free)}},
@{N='FreeSpaceGB_AfterMigration';E={[math]::Round($free - $vmSizeGB)}}
$vmNr++
$free -= $vmSizeGB
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-Datastore |
where{$_.ExtensionData.Summary.MultipleHostAccess -and $_.FreeSpaceGB -ge 500} |
Select Name,@{N='Number of VMs';E={[math]::Floor($_.FreeSpaceGB/500)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD for your reply.
If I want to create the report like first 500 GB VM will go to first DS which has more than 500 GB freespace. After moving first VM if the datastore still has 500 + free space then the 2nd VM will move to same datastore otherwise to the next datastore.
Please let me know how to achieve the same.
The script I gave tells you how many VMs can go to each datastore.
Is this now another question for doing the actual vMotion?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nope I just wanted that report in presentable format so that I can show it to the management.
VMName | VMSizeGB | Datastore | TotalFreeSpaceGB | FreeSpaceGB_AfterMigration |
VM1 | 500 | DS1 | 1200 | 700 |
VM2 | 500 | DS1 | 700 | 200 |
VM3 | 500 | DS2 | 700 | 200 |
… |
Like this you mean?
$vmSizeGB = 500
Get-Cluster -Name cluster2 |
Get-Datastore -PipelineVariable ds |
where{$_.ExtensionData.Summary.MultipleHostAccess -and $_.FreeSpaceGB -ge $vmSizeGB} |
ForEach-Object -Process {
$free = $ds.FreeSpaceGB
1..[math]::floor($ds.FreeSpaceGB/$vmSizeGB) | %{
'' | Select @{N='VMName';E={"VM$vmNr"}},
@{N='VMSizeGB';E={$vmSizeGB}},
@{N='Datastore';E={$ds.Name}},
@{N='TotalFreeSpaceGB';E={[math]::Round($free)}},
@{N='FreeSpaceGB_AfterMigration';E={[math]::Round($free - $vmSizeGB)}}
$vmNr++
$free -= $vmSizeGB
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot. Really appreciated.