Create Detailed VM

June 17, 2020

by Chris Rasmussen

Intended Audience Level: Beginner/Intro

Code Sample Type: Snippet

Nutanix Technologies: Prism Central

Minimum Product Version: 5.15

Script/Code Language: JSON Payload

REST API Sample? Yes

REST API Version: v3

JSON payload to create a VM that includes details for vCPU, cores per vCPU, RAM and storage. It also specifies the VM should have a network adapter NIC connected to specific AHV network identified by {{subnet_name}} and {{subnet_uuid}}.

Code Sample Details

This section may be empty if additional code sample details are not available.

JSON payload to create a VM that includes details for vCPU, cores per vCPU, RAM and storage. It also specifies the VM should have a network adapter NIC connected to specific AHV network identified by {{subnet_name}} and {{subnet_uuid}}.

Request Parameters

The below parameters should be used with the sample payload.

Please note you will need to alter {{placeholder}} values to match your environment, e.g. subnet name and UUID, cluster name and UUID.

Request URL:

https://[prism_central_ip_address]:9440/api/nutanix/v3/vms

Request method:

POST

Payload

{
	"spec":{
		"name":"vm_from_v3_api",
		"resources":{
			"power_state":"ON",
			"num_vcpus_per_socket":1,
			"num_sockets":1,
			"memory_size_mib":1024,
			"disk_list":[{
				"disk_size_mib":1024,
				"device_properties":{
					"device_type":"DISK"
				}
			},
			{
				"device_properties":{
					"device_type":"CDROM"
				}
			}],
			"nic_list":[{
				"nic_type":"NORMAL_NIC",
				"is_connected":true,
				"ip_endpoint_list":[{
					"ip_type":"DHCP"
				}],
				"subnet_reference":{
					"kind":"subnet",
					"name":"{{subnet_name}}",
					"uuid":"{{subnet_uuid}}"
				}
			}],
			"guest_tools":{
				"nutanix_guest_tools":{
					"state":"ENABLED",
					"iso_mount_state":"MOUNTED"
				}
			}
			
		},
		"cluster_reference":{
			"kind":"cluster",
			"name":"{{cluster_name}}",
			"uuid":"{{cluster_uuid}}"
		}
	},
	"api_version":"3.1.0",
	"metadata":{
		"kind":"vm"
	}
}