VM creation automation | Nutanix Community
Skip to main content

Hello All,

I am new to Nutanix and AHV; however, I have a large amount of experience with Hyper-v and SCVMM. One of the things I am trying to do is automate the creation of a vm’s. My end goal is to take an “image” base drive I have uploaded to images containing an install of my windows OS.

Deploy a new vm with that image, have a static IP assigned to the new vm automatically from a pool of IP’s, join my domain, and run a few powershell scripts in the VM. I would have done this all with an IP pool and a template in SCVMM and as much as I have read about templates in AHV I am not seeing anything like it. Am I missing something here?

Do we have a resource on how to configure something like this?

Hey there @skeeter . Let me search for a way to perform this specific task and get back to you. :smile:


By the way @skeeter we have something called aCLI which is a command-line interface to perform lots of tasks on the cluster and manage it.

You can use aCLI for VMs to achieve the above i.e create a VM. aCLI commands are run from the CVM on a cluster. You can try this out in the meantime.:sweat_smile:


Thanks for looking at this @AnishWalia20 . I will look into the aCLI with hopes I can bring these actions into a powershell script I can share with my colleagues. 


Hey @skeeter , sure you can take a look and try out these commands. So you have a Hyper-V cluster I suppose?

Btw you are looking for a Powershell script to achieve the above task?

Here are a list of entities which you can manage using PowerShell CMDlets: https://portal.nutanix.com/page/documents/details?targetId=API_Ref-Acr_v4_6%3APowerShell_Cmdlets_Reference

 

Also this PowerShell CMDlets cheatsheet would be usefull:
 

 

You can checkout the Powershell commands under Acropolis Task administration(2nd column in the above screenshot) to create a new VM,add vDisk to it, add VMNIC to it etc,

Maybe using the above you can create a script to achieve the VM creating task.


@AnishWalia20  I am trying to take my lessons learned from Hyper-v and apply them to a new Nutanix cluster running AHV. Thanks for the resources I will look into them.


Hi , To have DHCP server on your HCI environment then There is a feature called IPAM(Managed Network under virtual network creation window) , Make use of this to assign ip automatically to all your vms , you can deploy multiple vms from an Image and assign IP


Hi @skeeter 

I would have done this all with an IP pool and a template in SCVMM and as much as I have read about templates in AHV I am not seeing anything like it. Am I missing something here?

There are no templates, technically, when managing VMs in Nutanix. There are images and those refer to disks. The logic of creating a VM would be:

  • create a VM using an image uploaded while applying parameters of CPU and RAM;
  • add extra disks and CD-ROM with an image if required
  • configure the VM’s NICs (VLAN and IPAM if necessary)

As opposed to creating a template and provisioning a VM based on a template.


I wrote a small script using acli commands to create a vm. Well it is really just a series of commands in one file.

Then I use a batch file to run putty/plink that will run the commands. I even managed to get user input and loops in it. I just run the batch file which prompts me for a password, VM name and how many NIC’s.

I don’t use it for mass VM creation as I usually just build a server, maybe 2 at a time. But it does help to make sure that all of our VM’s have certain features. For example, I want all of our VM’s to have 2 HD.

Then I use a powershell script to do some post configuration tasks. I just put the PS script into the image and when you log in for the first time you run the PS script. For example we disable ipv6, I install the SCCM agent, etc. I make sure the second HD is the D:

This really makes it so when other people create VM’s they don’t leave out steps.