The Nutanix REST API (v3) allows for automated VM deployments, which is useful for scripting, CI/CD pipelines, or bulk VM provisioning. For more
information, see Nutanix KB 6440 – Create a VM using Nutanix REST API v3 and Nutanix API v3 – Creating a Linux VM with Cloud-Init – Nutanix.dev.
Trend Micro recommends the following VM configuration:
-
VM Name:
Nutanix-rest-connector-vm
-
vCPUs: 4 (1 socket × 4 vCPUs)
-
Memory: 8 GB (8192 MB)
-
Disk: Cloned from image
Nutaminx-connector-image
-
Disk Bus: IDE
-
Network: Subnet
New-VLAN265
(DHCP)
Before starting, ensure that the required VM image has already been uploaded to the
Nutanix Image Service and that the target network subnet (VLAN) has been created.
Procedure
- Gather Required UUIDsREST API requires UUIDs for images and subnets instead of names.
- Get the image UUID:
curl -u "admin:<password>" -k \ -H "Content-Type: application/json" \ -X POST https://<cluster-ip>:9440/api/nutanix/v3/images/list \ -d '{"kind":"image","filter":"name==Nutaminx-connector-image"}'
-
Purpose: Retrieve the UUID of the image
Nutaminx-connector-image
. -
Output: JSON including
metadata.uuid
, for example"metadata": { "uuid": "c63ef950-7ba5-4450-bb10-65fdf209c639", "name": "Nutaminx-connector-image"
This UUID will be used to attach the boot disk -
- Get the subnet UUID.
curl -u "admin:<password>" -k \ -H "Content-Type: application/json" \ -X POST https://<cluster-ip>:9440/api/nutanix/v3/subnets/list \ -d '{"kind":"subnet","filter":"name==New-VLAN265"}'
-
Purpose: Retrieve the UUID of the subnet
New-VLAN265
. -
Output: JSON including
metadata.uuid
, for example"metadata": { "uuid": "06b5de80-6864-4871-b7b8-9e36849fb5a9", "name": "New-VLAN265" }
This UUID is used to attach the NIC to the VM. -
- Get the image UUID:
- Create the VM using the image UUID and the subnet UUID:
curl -u "admin:<password>" -k -H "Content-Type: application/json" \ -X POST https://<cluster-ip>:9440/api/nutanix/v3/vms \ -d '{ "spec": { "name": "Nutanix-rest-connector-vm", "resources": { "num_vcpus_per_socket": 4, "num_sockets": 1, "memory_size_mib": 8192, "disk_list": [ { "device_properties": { "disk_address": { "device_index": 0, "adapter_type": "IDE" } }, "data_source_reference": { "kind": "image", "uuid": "c63ef950-7ba5-4450-bb10-65fdf209c639" } } ], "nic_list": [ { "subnet_reference": { "kind": "subnet", "uuid": "06b5de80-6864-4871-b7b8-9e36849fb5a9" } } ] } }, "metadata": { "kind": "vm" } }'
Definition of the key fields
FieldDescriptionname
Name of the VM (Nutanix-rest-connector-vm
)num_vcpus_per_socket
Number of vCPUs in each socketnum_sockets
Number of CPU socketsmemory_size_mib
Memory in MiB (8192 = 8GB)disk_list.device_properties.disk_address.adapter_type
Bus type for the disk (IDE
)disk_list.data_source_reference.uuid
UUID of the image to clone fromnic_list.subnet_reference.uuid
UUID of the subnet for the VM NICmetadata.kind
Must be"vm"
for VM creation - Verify the VM creation after the command is finished:
-
Prism UI: Check the VMs page for
Nutanix-rest-connector-vm
-
ACLI:
acli vm.get Nutanix-rest-connector-vm
-
REST API:
curl -u "admin:<password>" -k \ -H "Content-Type: application/json" \ https://<cluster-ip>:9440/api/nutanix/v3/vms/<VM-UUID>
-
- Power on the VM:
curl -u "admin:<password>" -k \ -H "Content-Type: application/json" \ -X POST https://<cluster-ip>:9440/api/nutanix/v3/vms/<VM-UUID>/set_power_state \ -d '{"transition":"ON"}'