Nutanix CE : How to create clones from command line


Background

Sometimes, you need to create multiple clones for a single gold image (template). This can be boring using the Prism Element UI if you have more than 10. Hopefully, there is a set of commands that can be initiated from the command line ACLI - Acropolis CLI. ACLI is rich in terms of action that can be done. Actually almost everything VM related can be done using ACLI. Here is how to create clones from a source VM.


Creating clones for a source VM

First, ssh into any of the CVM as nutanix user. Then issue the acli command to get into the acli shell.

$ acli
<acropolis> 

Next list the VMs available on the cluster, locate the one you need to clone from and then user the vm.clone command.

<acropolis> vm.list
VM name             VM UUID                               
Directory           c43bc4e1-ba36-4775-b1eb-4c45c1c3cd13  
GOLD -  Windows 10  6d226201-f10c-444e-b641-385a87f349ab  
GOLD - CentOS7      512597b4-ed7b-4fdb-a9ec-1817107ba661  
Prism Central       9bfc4e26-fcd3-4656-80a5-9558f929e6ef 

<acropolis> vm.clone My_Clone[001..010] clone_from_vm="GOLD - CentOS7"

My_Clone001: complete

My_Clone002: complete

My_Clone003: complete

My_Clone004: complete

My_Clone005: complete

My_Clone006: complete

My_Clone007: complete

My_Clone008: complete

My_Clone009: complete

My_Clone010: complete

This process is extremely fast, the above took less than one second and the VMs are visible in Prism Central immediately.


Extra ACLI commands

Now, if you have enough power in your cluster, you can start them all at once using the following command :

<acropolis> vm.on My_Clone00[1-3]
My_Clone001: complete
My_Clone002: complete
My_Clone003: complete

Again, straight forward and almost immediate. I only started 3 of my clones since I'm limited in compute on my cluster.

Switching those VM off is very similar :

<acropolis> vm.off My_Clone00[1-3]
My_Clone001: complete
My_Clone002: complete
My_Clone003: complete

Now, to remove all the clones, here is the command :

<acropolis> vm.delete My_Clone00[1-9]
Delete 9 VMs? (yes/no) yes
My_Clone001: complete
My_Clone002: complete
My_Clone003: complete
My_Clone004: complete
My_Clone005: complete
My_Clone006: complete
My_Clone007: complete
My_Clone008: complete
My_Clone009: complete
<acropolis> vm.delete My_Clone010
Delete 1 VMs? (yes/no) yes
My_Clone010: complete

Comments

What's hot ?

ShredOS : HDD degaussing with style

Wallbox : Get The Most Of It (with API)