Unleash the power of the NTNX-AVM – Move VM from one container to another container (AHV) with move_vm

This post is related to AHV only!!! Make sure a recent backup of the VM exist!

In the last weeks customers asked me how to move a VM from one AHV container to another AHV container on the same cluster. The answer is: “There is no PRISM/GUI option for this and the manual task is pretty difficult”. So i wrote a script called move_vm which I show in this post to simplify this.

But why should you move a VM?

There are several reasons for this.

container settings don’t fit

different containers for different organization units

DR/backup concepts based on containers

Automation based on containers

… and more

Example: Let’s say the customer started with two containers:

ISO – just for templates and CD/DVD ISO images

prod – productions environment

Now he realizes that some of the server VMs would be great for compression but some are not. He used the best practices to figure out which server VMs would fit.

You may noticed that there are two VMs now with the same name. I believe it makes sense to keep the old VM unless you are sure the new copy works.

You can use the option “–delete” to delete the source VM. The advantage is that the new network adapters will have the same MAC address then the source VM!

Move just one vDisk/disk of the VM from container prod_comp back to prod

I renamed the new Move_VM_Test1 to Move_VM_Test2 for the next part.

Let’s say you would like to move just one vDisk from a container prod_comp back to prod because you found that inline compression makes no sense. An example maybe the “transaction log” vdisk of a MS SQL Server.

First we need to find out which vdisks exist and how the mapping looks like. This can be done with the “–list_mapping” option.

which means that there are four vdisks and two CD/DVD drives. Let’s say we identified that the the second vdisk: “scsi.1” is the one we would like to move back to container prod. In this case we need to specify the whole mapping when calling the move_vm tool to only move the second vdisk. Copy and paste is the way to go!

You may ask: “Why is the whole VM cloned and not only the vdisk?” Yep you are right. This would be the better way. This is how this tool works atm. This is more a copy then a move but it works and its pretty fast because only the vdisk “scsi.1” needs to be copied.

You could specify the option “–delete” the delete the source VM and to make sure the new network adapters get the same MAC address.

There we go.

For all the people who wants to know more, this is an overview how this tool works:

Upload vDisk from source VM to image service. This is needed while a direct copy is not possible