Migrating your VMs from vSphere to vCloud Director and vice versa

There was an interesting question on the VMware community forums and I thought it would be good to blog about it – How can you move your VMs in and out of your cloud that is managed by vCloud Director?

I’m not talking here about vMotion, but rather the native place your VM is running in. You might think that everything at the end is running inside ESX (and you are right) but there is one thing you might know about. If you try to migrate a VM that was originally created by vCloud Director and place it in an ESX server that is not managed/prepared by vCD, you will simply not be able to. You will get an error similar to the following:

Shocking? Not really. This is something very important to always keep your cloud VMs within the boundaries of vCD.

Let’s take a closer look.

Migrating the VMs from vSphere to vCloud Director:    

If you want to migrate a VM from your vSphere environment to vCD, you can simply go to your Organization -> My Cloud -> vApps -> and then choose the “Import from vSphere” icon in the tool bar.

You will then get a dialog box asking you which VM you want to migrate from the vSphere inventory, and whether you want to move or copy it.

So far it’s pretty straight forward. Now let’s see how to do that the other way around.

Migrating the VMs from vCloud Director to vSphere:

As I mentioned above, if you tried to migrate a VM that was originally created in vCD to a host that is not part of your cloud recourses (aka not prepared by vCD), you will get an error preventing you from doing that. The reason being is that all the cloud VMs are actually pinned by a custom vCenter fields in the database to differentiate them from the other native vSphere VMs. These custom fields start with: system.service.vmware.vsla and then followed by the vCD system ID (in my case its HyperCloud as you see in the first screenshot).

Now, how can you remove that field in order to migrate your VM outside of your cloud? there are two ways to do that:

1 – You can simply unregister your VM from vCenter Server (using your vSphere Client), and then browse to you datastore, write click on the VM’s VMX file and select “Add to inventory”. By doing that you will be able to automatically remove the custom field and add the VM as if it was never created in your cloud. Of course you may Storage-vMotion the VM later on to another datastore/location for easier management.

2 – The second way is to browse through your vCenter mob browser and remove that custom field manually as shown in the screenshot below.

Of course i’m more in favor of the first option. It’s easier and cleaner!

UPDATE: Duncan Epping over at Yellow-Bricks.com wrote another solid solution for this. Make sure to read his article at this link. Duncan and I don’t seem to be agree on some points, but that’s the beauty of blogging – different views and opinions is always important.

Share Button