Question
Cloner une VM - Ordre des actions a respecter
- Zedd
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 45
- Remerciements reçus 0
il y a 14 ans 5 mois #10435
par Zedd
Cloner une VM - Ordre des actions a respecter a été créé par Zedd
Bonjour,
Nous essayons dans ma société de cloner des VM Hyper-V d'un serveur à l'autre.
Le serveur 1 est celui dit \"de prod\", où tournent les VM.
Le serveur 2 est ce lui de \"backup\", où se trouve les clones de nos VM, uniquement dans un but de sauvegarde.
Elles ne sont jamais allumées, sauf si le serveur 1 ou une VM du 1 a un soucis, pour éviter une interruption trop longue des services.
Juste pour éviter les interrogations des lecteurs, on n'utilise pas DPM, et nous n'avons pas de SAN, nous avons juste ces 2 serveurs et on doit réussir à faire avec..
Ce script doit faire ceci DANS L'ORDRE :
suppression de la VM de backup (il n'aime pas si elle est déjà en place)
Arrêt de la VM d'origine
Clonage de l'original vers le backup
Démarrage de l'original.
Le problème avec ce script, le démarrage final n'attend pas que le clonage soit terminé.
Pourtant, tout le début se passe sans encombre.
La suppression se fait jusqu'au bout, puis seulement lorsqu'elle est terminée, l'arrêt se lance.
La VM s'arrête proprement, et seulement lorsqu'elle est terminée, le clonage débute.
On s'attendait à ce que le démarrage attende que le clonage soit fini pour commencer, mais non.
Il tente de démarrer tout de suite, et du coup la commande plante, et la VM ne redémarre pas après clonage.
Autre soucis (secondaire, ça ne semble pas poser de pb), on a une erreur durant le clonage qu'on arrive pas à comprendre, et donc à résoudre :
\"
Erreur (802)
Le fichier HardwareProfile Profil1890305d-44dc-430f-af86-273ac5eae6ca est déjà utilisé par un autre HardwareProfile.
Action recommandée
Attendez que l'objet devienne disponible, puis recommencez l'opération.
\"
Script de clonage :
[code:1]
echo \"début du travail\" > c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Lecture de l'etat\" >> c:\scripts\nvcontapharm.txt
$VMList = Get-WmiObject -Namespace root\virtualization Msvm_ComputerSystem -ComputerName nvhyperv01
$VMList = $VMList | Where-Object {$_.ElementName -eq 'nvcontapharm'}
$VMList | Format-Table ElementName,EnabledState -Autosize >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
if ($VMList | Where-Object {$_.EnabledState -eq 2})
{
echo \"suppression de la machine de backup\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm_bk\"
$VM = Get-Vm $VmName
Remove-VM $VM
rd \"\\10.10.10.2\e$\Hyper-V\Machines_Virtuelles\nvcontapharm_bk\"
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"arret de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Shutdown-VM $VM >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Debut du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
Set-VirtualFloppyDrive -RunAsynchronously -VMMServer localhost -NoMedia -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
New-VirtualNetworkAdapter -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -PhysicalAddress \"00:0C:76:E3:«»DF:9D\" -PhysicalAddressType Static -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -VLanEnabled $false -Synthetic -VMNetworkOptimizationEnabled $false -MACAddressesSpoofingEnabled $false
New-VirtualDVDDrive -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -Bus 0 -LUN 1
$CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq \"1.00 GHz Pentium III Xeon\"}
New-HardwareProfile -VMMServer localhost -Owner \"NOVAOPHT\novanet\" -CPUType $CPUType -Name \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\" -Description \"Configuration matérielle temporaire utilisée pour créer un ordinateur virtuel/modèle\" -CPUCount 1 -MemoryMB 1024 -ExpectedCPUUtilization 20 -DiskIO 0 -CPUMax 100 -CPUReserve 0 -NetworkUtilization 0 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder \"CD\", \"IdeHardDrive\", \"PxeBoot\", \"Floppy\" -LimitCPUFunctionality $false -LimitCPUForMigration $false -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VirtualNetworkAdapter = Get-VirtualNetworkAdapter -VMMServer localhost -All | where {$_.ID -eq \"ebe76bfb-8bf2-49b4-9d2b-5d4cd5609d3f\"}
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $VirtualNetworkAdapter -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VM = Get-VM -VMMServer localhost -Name \"nvcontapharm\" | where {$_.VMHost.Name -eq \"nvhyperv01.novacel.local\"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq \"10.10.10.2\"}
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
$OperatingSystem = Get-OperatingSystem -VMMServer localhost | where {$_.Name -eq \"Windows XP Professional\"}
New-VM -VM $VM -Name \"nvcontapharm_bk\" -Description \"\" -Owner \"NOVAOPHT\novanet\" -VMHost $VMHost -Path \"e:\Hyper-V\Machines_Virtuelles\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -RunAsynchronously -HardwareProfile $HardwareProfile -OperatingSystem $OperatingSystem -RunAsSystem -StartAction TurnOnVMIfRunningWhenVSStopped -DelayStart 0 -UseHardwareAssistedVirtualization $true -StopAction SaveVM
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Fin du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
}
else
{
echo \"La VM est arretee, on ne fait rien.\" >> c:\scripts\nvcontapharm.txt
exit
}
[/code:1]
Si vous avez une idée..
Cdt,
Zedd
Nous essayons dans ma société de cloner des VM Hyper-V d'un serveur à l'autre.
Le serveur 1 est celui dit \"de prod\", où tournent les VM.
Le serveur 2 est ce lui de \"backup\", où se trouve les clones de nos VM, uniquement dans un but de sauvegarde.
Elles ne sont jamais allumées, sauf si le serveur 1 ou une VM du 1 a un soucis, pour éviter une interruption trop longue des services.
Juste pour éviter les interrogations des lecteurs, on n'utilise pas DPM, et nous n'avons pas de SAN, nous avons juste ces 2 serveurs et on doit réussir à faire avec..
Ce script doit faire ceci DANS L'ORDRE :
suppression de la VM de backup (il n'aime pas si elle est déjà en place)
Arrêt de la VM d'origine
Clonage de l'original vers le backup
Démarrage de l'original.
Le problème avec ce script, le démarrage final n'attend pas que le clonage soit terminé.
Pourtant, tout le début se passe sans encombre.
La suppression se fait jusqu'au bout, puis seulement lorsqu'elle est terminée, l'arrêt se lance.
La VM s'arrête proprement, et seulement lorsqu'elle est terminée, le clonage débute.
On s'attendait à ce que le démarrage attende que le clonage soit fini pour commencer, mais non.
Il tente de démarrer tout de suite, et du coup la commande plante, et la VM ne redémarre pas après clonage.
Autre soucis (secondaire, ça ne semble pas poser de pb), on a une erreur durant le clonage qu'on arrive pas à comprendre, et donc à résoudre :
\"
Erreur (802)
Le fichier HardwareProfile Profil1890305d-44dc-430f-af86-273ac5eae6ca est déjà utilisé par un autre HardwareProfile.
Action recommandée
Attendez que l'objet devienne disponible, puis recommencez l'opération.
\"
Script de clonage :
[code:1]
echo \"début du travail\" > c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Lecture de l'etat\" >> c:\scripts\nvcontapharm.txt
$VMList = Get-WmiObject -Namespace root\virtualization Msvm_ComputerSystem -ComputerName nvhyperv01
$VMList = $VMList | Where-Object {$_.ElementName -eq 'nvcontapharm'}
$VMList | Format-Table ElementName,EnabledState -Autosize >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
if ($VMList | Where-Object {$_.EnabledState -eq 2})
{
echo \"suppression de la machine de backup\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm_bk\"
$VM = Get-Vm $VmName
Remove-VM $VM
rd \"\\10.10.10.2\e$\Hyper-V\Machines_Virtuelles\nvcontapharm_bk\"
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"arret de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Shutdown-VM $VM >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Debut du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
Set-VirtualFloppyDrive -RunAsynchronously -VMMServer localhost -NoMedia -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
New-VirtualNetworkAdapter -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -PhysicalAddress \"00:0C:76:E3:«»DF:9D\" -PhysicalAddressType Static -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -VLanEnabled $false -Synthetic -VMNetworkOptimizationEnabled $false -MACAddressesSpoofingEnabled $false
New-VirtualDVDDrive -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -Bus 0 -LUN 1
$CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq \"1.00 GHz Pentium III Xeon\"}
New-HardwareProfile -VMMServer localhost -Owner \"NOVAOPHT\novanet\" -CPUType $CPUType -Name \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\" -Description \"Configuration matérielle temporaire utilisée pour créer un ordinateur virtuel/modèle\" -CPUCount 1 -MemoryMB 1024 -ExpectedCPUUtilization 20 -DiskIO 0 -CPUMax 100 -CPUReserve 0 -NetworkUtilization 0 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder \"CD\", \"IdeHardDrive\", \"PxeBoot\", \"Floppy\" -LimitCPUFunctionality $false -LimitCPUForMigration $false -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VirtualNetworkAdapter = Get-VirtualNetworkAdapter -VMMServer localhost -All | where {$_.ID -eq \"ebe76bfb-8bf2-49b4-9d2b-5d4cd5609d3f\"}
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $VirtualNetworkAdapter -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VM = Get-VM -VMMServer localhost -Name \"nvcontapharm\" | where {$_.VMHost.Name -eq \"nvhyperv01.novacel.local\"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq \"10.10.10.2\"}
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
$OperatingSystem = Get-OperatingSystem -VMMServer localhost | where {$_.Name -eq \"Windows XP Professional\"}
New-VM -VM $VM -Name \"nvcontapharm_bk\" -Description \"\" -Owner \"NOVAOPHT\novanet\" -VMHost $VMHost -Path \"e:\Hyper-V\Machines_Virtuelles\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -RunAsynchronously -HardwareProfile $HardwareProfile -OperatingSystem $OperatingSystem -RunAsSystem -StartAction TurnOnVMIfRunningWhenVSStopped -DelayStart 0 -UseHardwareAssistedVirtualization $true -StopAction SaveVM
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Fin du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
}
else
{
echo \"La VM est arretee, on ne fait rien.\" >> c:\scripts\nvcontapharm.txt
exit
}
[/code:1]
Si vous avez une idée..
Cdt,
Zedd
Connexion ou Créer un compte pour participer à la conversation.
- Matthew BETTON
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 968
- Remerciements reçus 0
il y a 14 ans 5 mois #10436
par Matthew BETTON
Réponse de Matthew BETTON sur le sujet Re:Cloner une VM - Ordre des actions a respecter
Bonjour,
Zedd écrit:
Hasard ou coïncidence ?
Voir ici : powershell-scripting.com/index.php?optio...id=10426&catid=6
Merovingien s'était répondu à lui-même, il y a 3 jours :
@ +
Matthew<br><br>Message édité par: Matthew BETTON, à: 17/10/11 16:06
Zedd écrit:
Le problème avec ce script, le démarrage final n'attend pas que le clonage soit terminé.
Hasard ou coïncidence ?
Voir ici : powershell-scripting.com/index.php?optio...id=10426&catid=6
Merovingien s'était répondu à lui-même, il y a 3 jours :
Dans les options New-VM il y en a une qui est :
-RunAsynchronously
Cette option Spécifie que le travail s'exécute de manière asynchrone, de sorte que le contrôle retourne immédiatement à l'interface de commande.
Il suffisait de l'enlever.
@ +
Matthew<br><br>Message édité par: Matthew BETTON, à: 17/10/11 16:06
Connexion ou Créer un compte pour participer à la conversation.
- Zedd
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 45
- Remerciements reçus 0
il y a 14 ans 5 mois #10437
par Zedd
Réponse de Zedd sur le sujet Re:Cloner une VM - Ordre des actions a respecter
Excélent !
Oui, belle coincidence, ça fait 2 semaines que je me creuse la tête... J'aurais du fouiller plus avant de poster.
Merci encore pour le lien !
Zedd
Oui, belle coincidence, ça fait 2 semaines que je me creuse la tête... J'aurais du fouiller plus avant de poster.
Merci encore pour le lien !
Zedd
Connexion ou Créer un compte pour participer à la conversation.
- Merovingien
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 7
- Remerciements reçus 0
il y a 14 ans 4 mois #10503
par Merovingien
Réponse de Merovingien sur le sujet Re:Cloner une VM - Ordre des actions a respecter
l'objet Hardware profile est créé lors du clone:
Il collecte les informations matériels de la VM source et l'enregistre dans la variable $HardwareProfile.
Regarde vers la fin de ton script :
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Si tu regardes dans SCVMM => Librairie => Profil tu le verra apparaitre.
Personnellement j'ai créé un script qui supprime ce profile avant le clonage.
Finalement je me rends compte qu'il vaut mieux le supprimé après le clonage. Car si tu as plusieurs VM à cloner, tu te retrouves avec plusieurs profiles qui peuvent t'induire en erreur.
Il te faut ajouter à la fin de ton script une action qui supprime ce profile :
Get-VMMServer -ComputerName NomDuServeurSCVMM
$HWProfile = Get-HardwareProfile | where { $_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Remove-HardwareProfile -HardwareProfile $HWProfile
Pour le problème de transfert, je t'ai répondu sur ma question. Tu as le lien plus haut de Mathieu.
Cdt,
Merovingien
Message édité par: Merovingien, à: 26/10/11 10:13<br><br>Message édité par: Merovingien, à: 26/10/11 10:14
Il collecte les informations matériels de la VM source et l'enregistre dans la variable $HardwareProfile.
Regarde vers la fin de ton script :
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Si tu regardes dans SCVMM => Librairie => Profil tu le verra apparaitre.
Personnellement j'ai créé un script qui supprime ce profile avant le clonage.
Finalement je me rends compte qu'il vaut mieux le supprimé après le clonage. Car si tu as plusieurs VM à cloner, tu te retrouves avec plusieurs profiles qui peuvent t'induire en erreur.
Il te faut ajouter à la fin de ton script une action qui supprime ce profile :
Get-VMMServer -ComputerName NomDuServeurSCVMM
$HWProfile = Get-HardwareProfile | where { $_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Remove-HardwareProfile -HardwareProfile $HWProfile
Pour le problème de transfert, je t'ai répondu sur ma question. Tu as le lien plus haut de Mathieu.
Cdt,
Merovingien
Message édité par: Merovingien, à: 26/10/11 10:13<br><br>Message édité par: Merovingien, à: 26/10/11 10:14
Connexion ou Créer un compte pour participer à la conversation.
- Zedd
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 45
- Remerciements reçus 0
il y a 14 ans 4 mois #10509
par Zedd
Réponse de Zedd sur le sujet Re:Cloner une VM - Ordre des actions a respecter
Bonjour,
Super, ça m'a effectivement enlevé l'erreur qui apparaissait.
Concernant le problème de transfert, il n'apparait qu'en cas de clonage.
Les MAJ conseillées sont soit déjà installées, soit non efficaces, soit refusées par le système.
Je continue à plancher la dessus.
Pour ceux que ça intéresse, Voici le script tel qu'il est aujourd'hui :
[code:1]
echo \"début du travail\" > c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Lecture de l'etat\" >> c:\scripts\nvcontapharm.txt
$VMList = Get-WmiObject -Namespace root\virtualization Msvm_ComputerSystem -ComputerName nvhyperv01
$VMList = $VMList | Where-Object {$_.ElementName -eq 'nvcontapharm'}
$VMList | Format-Table ElementName,EnabledState -Autosize >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
if ($VMList | Where-Object {$_.EnabledState -eq 2})
{
echo \"suppression de la machine de backup\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm_bk\"
$VM = Get-Vm $VmName
Remove-VM $VM
rd \"\\10.10.10.2\e$\Hyper-V\Machines_Virtuelles\nvcontapharm_bk\"
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"arret de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Shutdown-VM $VM >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Debut du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
Set-VirtualFloppyDrive -VMMServer localhost -NoMedia -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
New-VirtualNetworkAdapter -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -PhysicalAddress \"00:0C:76:E3:«»DF:9D\" -PhysicalAddressType Static -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -VLanEnabled $false -Synthetic -VMNetworkOptimizationEnabled $false -MACAddressesSpoofingEnabled $false
New-VirtualDVDDrive -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -Bus 0 -LUN 1
$CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq \"1.00 GHz Pentium III Xeon\"}
New-HardwareProfile -VMMServer localhost -Owner \"NOVAOPHT\novanet\" -CPUType $CPUType -Name \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\" -Description \"Configuration matérielle temporaire utilisée pour créer un ordinateur virtuel/modèle\" -CPUCount 1 -MemoryMB 1024 -ExpectedCPUUtilization 20 -DiskIO 0 -CPUMax 100 -CPUReserve 0 -NetworkUtilization 0 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder \"CD\", \"IdeHardDrive\", \"PxeBoot\", \"Floppy\" -LimitCPUFunctionality $false -LimitCPUForMigration $false -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VirtualNetworkAdapter = Get-VirtualNetworkAdapter -VMMServer localhost -All | where {$_.ID -eq \"ebe76bfb-8bf2-49b4-9d2b-5d4cd5609d3f\"}
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $VirtualNetworkAdapter -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VM = Get-VM -VMMServer localhost -Name \"nvcontapharm\" | where {$_.VMHost.Name -eq \"nvhyperv01.novacel.local\"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq \"10.10.10.2\"}
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
$OperatingSystem = Get-OperatingSystem -VMMServer localhost | where {$_.Name -eq \"Windows XP Professional\"}
New-VM -VM $VM -Name \"nvcontapharm_bk\" -Description \"\" -Owner \"NOVAOPHT\novanet\" -VMHost $VMHost -Path \"e:\Hyper-V\Machines_Virtuelles\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -HardwareProfile $HardwareProfile -OperatingSystem $OperatingSystem -RunAsSystem -StartAction TurnOnVMIfRunningWhenVSStopped -DelayStart 0 -UseHardwareAssistedVirtualization $true -StopAction SaveVM
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Fin du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Suppression du profile\" >> c:\scripts\nvcontapharm.txt
Get-VMMServer -ComputerName nvhyperv01
$HWProfile = Get-HardwareProfile | where { $_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Remove-HardwareProfile -HardwareProfile $HWProfile
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Demarrage de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Start-VM $VM >> c:\scripts\nvcontapharm.txt
}
else
{
echo \"La VM est arretee, on ne fait rien.\" >> c:\scripts\nvcontapharm.txt
exit
}
echo \"Fin du travail\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Envoi du récap par mail\" >> c:\scripts\nvcontapharm.txt
$expediteur = \"adresse@domaine.com\"
$destinataire = \"adresse@domaine.com\"
$serveur = \"172.16.0.67\"
$fichier = \"c:\scripts\nvcontapharm.txt\"
$objet = \"Clonage Hyper-V NVContapharm - Recap du \" + [System.DateTime]::Now
$texte = \"Vous trouverez en PJ le recap du clonage de nvcontapharm\"
$message = new-object System.Net.Mail.MailMessage $expediteur, $destinataire, $objet, $texte
$attachment = new-object System.Net.Mail.Attachment $fichier
$message.Attachments.Add($attachment)
$SMTPclient = new-object System.Net.Mail.SmtpClient $serveur
$SMTPAuthUsername = \"adresse@domaine.local\"
$SMTPAuthPassword = \"mon_mdp\"
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername, $SMTPAuthPassword)
$SMTPclient.Send($message)
[/code:1]
Super, ça m'a effectivement enlevé l'erreur qui apparaissait.
Concernant le problème de transfert, il n'apparait qu'en cas de clonage.
Les MAJ conseillées sont soit déjà installées, soit non efficaces, soit refusées par le système.
Je continue à plancher la dessus.
Pour ceux que ça intéresse, Voici le script tel qu'il est aujourd'hui :
[code:1]
echo \"début du travail\" > c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Lecture de l'etat\" >> c:\scripts\nvcontapharm.txt
$VMList = Get-WmiObject -Namespace root\virtualization Msvm_ComputerSystem -ComputerName nvhyperv01
$VMList = $VMList | Where-Object {$_.ElementName -eq 'nvcontapharm'}
$VMList | Format-Table ElementName,EnabledState -Autosize >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
if ($VMList | Where-Object {$_.EnabledState -eq 2})
{
echo \"suppression de la machine de backup\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm_bk\"
$VM = Get-Vm $VmName
Remove-VM $VM
rd \"\\10.10.10.2\e$\Hyper-V\Machines_Virtuelles\nvcontapharm_bk\"
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"arret de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Shutdown-VM $VM >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Debut du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
Set-VirtualFloppyDrive -VMMServer localhost -NoMedia -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
New-VirtualNetworkAdapter -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -PhysicalAddress \"00:0C:76:E3:«»DF:9D\" -PhysicalAddressType Static -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -VLanEnabled $false -Synthetic -VMNetworkOptimizationEnabled $false -MACAddressesSpoofingEnabled $false
New-VirtualDVDDrive -VMMServer localhost -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -Bus 0 -LUN 1
$CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq \"1.00 GHz Pentium III Xeon\"}
New-HardwareProfile -VMMServer localhost -Owner \"NOVAOPHT\novanet\" -CPUType $CPUType -Name \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\" -Description \"Configuration matérielle temporaire utilisée pour créer un ordinateur virtuel/modèle\" -CPUCount 1 -MemoryMB 1024 -ExpectedCPUUtilization 20 -DiskIO 0 -CPUMax 100 -CPUReserve 0 -NetworkUtilization 0 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder \"CD\", \"IdeHardDrive\", \"PxeBoot\", \"Floppy\" -LimitCPUFunctionality $false -LimitCPUForMigration $false -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VirtualNetworkAdapter = Get-VirtualNetworkAdapter -VMMServer localhost -All | where {$_.ID -eq \"ebe76bfb-8bf2-49b4-9d2b-5d4cd5609d3f\"}
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $VirtualNetworkAdapter -VirtualNetwork \"Carte Physique VM - Réseau virtuel\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41
$VM = Get-VM -VMMServer localhost -Name \"nvcontapharm\" | where {$_.VMHost.Name -eq \"nvhyperv01.novacel.local\"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq \"10.10.10.2\"}
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
$OperatingSystem = Get-OperatingSystem -VMMServer localhost | where {$_.Name -eq \"Windows XP Professional\"}
New-VM -VM $VM -Name \"nvcontapharm_bk\" -Description \"\" -Owner \"NOVAOPHT\novanet\" -VMHost $VMHost -Path \"e:\Hyper-V\Machines_Virtuelles\" -JobGroup f00aba00-fa48-4d91-8161-66ae04ecfb41 -HardwareProfile $HardwareProfile -OperatingSystem $OperatingSystem -RunAsSystem -StartAction TurnOnVMIfRunningWhenVSStopped -DelayStart 0 -UseHardwareAssistedVirtualization $true -StopAction SaveVM
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Fin du clonage de la machine\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Suppression du profile\" >> c:\scripts\nvcontapharm.txt
Get-VMMServer -ComputerName nvhyperv01
$HWProfile = Get-HardwareProfile | where { $_.Name -eq \"Profil1890305d-44dc-430f-af86-273ac5eae6ca\"}
Remove-HardwareProfile -HardwareProfile $HWProfile
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Demarrage de la machine\" >> c:\scripts\nvcontapharm.txt
get-VMMServer \"nvhyperv01\"
$VmName = \"nvcontapharm\"
$VM = Get-Vm $VmName
Start-VM $VM >> c:\scripts\nvcontapharm.txt
}
else
{
echo \"La VM est arretee, on ne fait rien.\" >> c:\scripts\nvcontapharm.txt
exit
}
echo \"Fin du travail\" >> c:\scripts\nvcontapharm.txt
get-date >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"
\" >> c:\scripts\nvcontapharm.txt
echo \"Envoi du récap par mail\" >> c:\scripts\nvcontapharm.txt
$expediteur = \"adresse@domaine.com\"
$destinataire = \"adresse@domaine.com\"
$serveur = \"172.16.0.67\"
$fichier = \"c:\scripts\nvcontapharm.txt\"
$objet = \"Clonage Hyper-V NVContapharm - Recap du \" + [System.DateTime]::Now
$texte = \"Vous trouverez en PJ le recap du clonage de nvcontapharm\"
$message = new-object System.Net.Mail.MailMessage $expediteur, $destinataire, $objet, $texte
$attachment = new-object System.Net.Mail.Attachment $fichier
$message.Attachments.Add($attachment)
$SMTPclient = new-object System.Net.Mail.SmtpClient $serveur
$SMTPAuthUsername = \"adresse@domaine.local\"
$SMTPAuthPassword = \"mon_mdp\"
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername, $SMTPAuthPassword)
$SMTPclient.Send($message)
[/code:1]
Connexion ou Créer un compte pour participer à la conversation.
- Merovingien
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 7
- Remerciements reçus 0
il y a 14 ans 4 mois #10510
par Merovingien
Réponse de Merovingien sur le sujet Re:Cloner une VM - Ordre des actions a respecter
Bonjour,
Le clonage de VM via SCVMM se fait par le protocole BITS. C'est un transfert en arrière plan qui utilise le port sécurisé HTTPS.
J'ai eu ce souci au début, sauf que moi je passe par un switch. Et il se trouve que sur ce switch mon port était paramétré pour un débit à 100Mb/s. Je l'ai modifié de façon à avoir 1Gb/s. Et c'est carrément mieux. Le transfert d'une VM de 20Gb se fait en 8mn.
Pour en revenir au protocole BITS, c'est voulu qu'il n'utilise pas toute la bande passante car il prend en compte la QOS (Gestion du réseau) afin de ne pas prendre toute la bande passante. J'ai cherché un moyen de modifier le taux de transfert mais je n'ai rien trouvé.
Cdt,
Merovingien
Le clonage de VM via SCVMM se fait par le protocole BITS. C'est un transfert en arrière plan qui utilise le port sécurisé HTTPS.
J'ai eu ce souci au début, sauf que moi je passe par un switch. Et il se trouve que sur ce switch mon port était paramétré pour un débit à 100Mb/s. Je l'ai modifié de façon à avoir 1Gb/s. Et c'est carrément mieux. Le transfert d'une VM de 20Gb se fait en 8mn.
Pour en revenir au protocole BITS, c'est voulu qu'il n'utilise pas toute la bande passante car il prend en compte la QOS (Gestion du réseau) afin de ne pas prendre toute la bande passante. J'ai cherché un moyen de modifier le taux de transfert mais je n'ai rien trouvé.
Cdt,
Merovingien
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.060 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Cloner une VM - Ordre des actions a respecter