Recently, I needed to move 100+ VMs in a VMware environment from an AMD cluster (4.x) to an Intel cluster (5.x). Here are the details and steps I took to accomplish this with PowerCLI:
Storage: This work did not include moving the VM files to different datastores/LUNs or upgrading datastores, since the storage changes could be handled separately at a later time and do not require an outage.
Time constraints: The migration could take no longer than about 1 hour, while the VMs were already down. Due to my limited PowerCLI experience, I ended up dividing the VMs into three separate groups/scripts and running them concurrently. This met the 1 hour requirement, which made everyone happy!
Networking: The old cluster and new cluster were on different distributed vswitches, and the old cluster could not be added to the newer 5.x dvswitch. I knew that this would cause a problem with even cold migrations. Therefore, as part of the move, I needed to create a temporary 4.x “transfer” dvswitch w/ a “transfer” dvportgroup. The idea of using a “transfer” dvswitch was taken from this awesome blog post: http://www.v-front.de/2012/02/how-to-smoothly-migrate-vm-from-one-dvs.html. I prepared three separate CSV files for the three different groups, with the old and new dvportgroup info.
Disclaimer: I’m a PowerCLI noob. The PowerCLI scripts I share may be incredibly simple or not that exciting (to you). However, if I’m posting it, that means it worked for me and I found it useful. 🙂
After searching the Interwebs to see if others had performed similar work, I found the following discussion in the VMware Communities Forum: http://communities.vmware.com/thread/320568?start=0&tstart=0. Thanks to “bentech201110141” and Luc Dekens, I was able to use the PowerCLI script mentioned and modify it to fit the solution.
The Logical:
For each VM in the AMD cluster, specified in CSV file –
- Change dvportgroup for VM to port group on “transfer” dvswitch
- Move VM to destination host
- Change dvportgroup for VM to the correct port group on destination dvswitch
- Start VM
PowerCLI Script:
$vms = Import-CSV c:\csmoveinput
foreach ($vm in $vms){
$VMdestination = Get-VMHost $vm.VMhost
$Network = $vm.VLAN
Get-VM -Name $vm.name | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected:$true -Confirm:$false -NetworkName dvTransfer
Move-VM -vm $vm.name -Destination $VMdestination
Get-VM -Name $vm.name | Get-NetworkAdapter | Set-NetworkAdapter -StartConnected:$true -Confirm:$false -NetworkName $Network
Start-VM -vm $vm.name
}