JSON payload to create a detailed AHV VM that is then configured with Cloud-Init. All important VM parameters are specified, including base64-encoded Cloud-Init YAML spec.
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
Prerequisites
The AHV image matching “{{cloud_init_image_uuid_pc}}” must have the Cloud-Init package installed before the Lin ux VM can be created from it.
Recommended Reading
Before using this code sample, it is strongly recommended to read the article titled “Nutanix API v3 – Creating a Linux VM with Cloud-Init“. It contains some detail about Cloud-Init and why it may be used.
Payload
{
"spec":{
"name":"{{vm_name}}",
"resources":{
"power_state":"ON",
"num_vcpus_per_socket":1,
"num_sockets":1,
"memory_size_mib":1024,
"disk_list":[{
"device_properties":{
"device_type":"DISK",
"disk_address": {
"device_index": 0,
"adapter_type": "SCSI"
}
},
"data_source_reference": {
"kind": "image",
"uuid": "{{cloud_init_image_uuid_pc}}"
}
},
{
"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"
}
},
"guest_customization": {
"cloud_init": {
"user_data": "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IG51dGFuaXgKICAgIHNzaC1hdXRob3JpemVkLWtleXM6CiAgICAgIC0gc3NoLXJzYSBLRVkKICAgIHN1ZG86IFsnQUxMPShBTEwpIE5PUEFTU1dEOkFMTCddCiAgICBncm91cHM6IHN1ZG8KICAgIHNoZWxsOiAvYmluL2Jhc2gKCnBhY2thZ2VzOgogIC0gaHR0cGQ="
},
"is_overridable": false
}
},
"cluster_reference":{
"kind":"cluster",
"name":"{{cluster_name}}",
"uuid":"{{cluster_uuid}}"
}
},
"api_version":"3.1.0",
"metadata":{
"kind":"vm"
}
}