Where I work, we use VMware to virtualize the majority of our servers. Last year, we bought four new servers in order to provide more resources to our virtual evironment, and also to aid in the upgrade to vSphere 4 from VI3. The plan was to power off all virtual machines and perform an offline migration of all the VMs from the old cluster to the new cluster. However, we were also migrating from the vSwitch to the distributed virtual switch (dvSwitch).
To start out, I upgraded VMware vCenter Server to version 4.x. After that was done, I created a new cluster and added all four new hosts to it. I then mapped all of the same LUNs to the new cluster that were already mapped to the old cluster. This allowed me to do a migration from the old cluster to the new without having to worry about storage migrations. Next, I created the new dvSwitch with all the same port groups as the old vSwitch. It was important to make sure all VLAN IDs were present. Finally, I powered off all virtual machines.
Now for the interesting part. I wrote a PowerShell script to automate the migration of the VMs from the old cluster to the new. At the same time, it looks at the vSwitches and maps them to their equivalent dvSwitch port group by looking for matching VLALN IDs. For example, if there is a vSwitch port group called “Monkey” with VLAN ID of 123, it will check the dvSwitch port groups and map that to whichever one also has VLAN ID 123.