vMotion : Cr?er une grille de compatibilit
Code :
$ListVM=get-vm | Sort-Object -Property Host
$ListHOST=get-vmhost
$viewSI = Get-View ‘ServiceInstance’
$viewVmProvChecker = Get-View $viewSI.Content.VmProvisioningChecker
$Resultat = $ListVM | ForEach-Object {
$obj=New-Object PSObject
$myVM=$_
$obj | add-Member Noteproperty -name Name -value $myVM.name
$obj | add-Member Noteproperty -name CurrentHost -value $myVM.host
$ListHOST | ForEach-Object {
$myHost=$_
$resultCheck=$viewVmProvChecker.QueryVMotionCompatibilityEx(($myVM).Id, ($myHost).Id)
$nbErreur=($resultCheck[0].Error | measure-object | select -Property count).count
write-host « $myVM vers $myHost : $nbErreur » -foregroundcolor blue
$obj | add-Member Noteproperty -name ($myHost.name) -value ($nbErreur)
}
$obj
}
$Resultat | out-gridview
Ca donne un chouette tableau. o? le chiffre correspond au nombre de problemes rencontr?s pour le vMotion.
Pour connaitre la cause d’un echec :
function get-vmotionProblems{
Param([string]$vmName, [string]$vmHost)
$viewSI = Get-View 'ServiceInstance'
$viewVmProvChecker = Get-View $viewSI.Content.VmProvisioningChecker
$resultCheck=$viewVmProvChecker.QueryVMotionCompatibilityEx((Get-VM -name $vmName).Id, (get-vmhost -name $vmhost).Id)
($resultCheck[0].error)| foreach { $_.LocalizedMessage }
}
Qu’on utilise comme ceci :
get-vmotionProblems -vmName MA_VM01 -vmHost MON_ESX02
Laisser un commentaire