Create VM in specific Container | Nutanix Community
Skip to main content

Hello,

I can't find how to specify on which container the disk should be created,

can you help me?
here is my json.

{"spec": {
"name": "TEST-API",
"resources": {
"power_state":"OFF",
"num_vcpus_per_socket": 1,
"num_sockets": 1,
"memory_size_mib": 8192,
"disk_list": [
{
"device_properties": {
"disk_address": {
"device_index": 0,
"adapter_type": "SCSI"
},
"device_type": "DISK"
},
"disk_size_mib": 8192
},
{
"device_properties": {
"disk_address": {
"device_index": 0,
"adapter_type": "IDE"
},
"device_type": "CDROM"
}
}
],
"nic_list":[
{
"nic_type": "NORMAL_NIC",
"is_connected": true,
"ip_endpoint_list": [
{
"ip_type": "DHCP"
}
],
"subnet_reference": {
"kind": "subnet",
"name": "VLAN-130",
"uuid": "002e2b71-a8ca-4360-86e1-0934aa9035f5"
}
}
],
"guest_tools": {
"nutanix_guest_tools": {
"state": "ENABLED",
"iso_mount_state": "MOUNTED"
}
}
},
"cluster_reference": {
"kind": "cluster",
"name": "AA01CLUAHV001",
"uuid": "0005a425-7396-e383-451d-246e960fb6d0"
}
},
"api_version": "3.1.0",
"metadata": {
"kind": "vm"
}
}

Thanks,

Cirvent

You have at least two places to look for the specs when it comes to APIs:

Nutanix Dev portal (as UPX pointed out earlier)  and

Prism REST API Explorer (only PC has option to browse API v3)

For example:

Nutanix Dev portal:

 

REST API Explorer:

 


Ok via API, now it’s clear.

You will find all the body content specs here: https://www.nutanix.dev/reference/prism_central/v3/api/vms/postvms/ or here https://www.nutanix.dev/reference/prism_element/v2/api/vms/post-vms-createvm/

Hope it helps


I have no problem in GUI, only via API , What should I add to the json file, to indicate the correct container?


Of course you can.

You can select the container to store the disk when you add the new disk to the vm via gui.

Or you can do the same via acli or via api

 

 


It is not possible to create the VM with its disk on the right container?


Hi UPX,
my problem is that when I create a VM the disk is stored in the wrong container.

Regards,

If there are no data on disk you can simply delete the original one and create the new one on desired container

Otherwise, If you have data on disk you can create the new one cloning the old but this time on the right container


Hi @UPX

My problem is that when I create a VM the disk is stored in the wrong container.


Hi Cirvent,

Not sure if i understand your question but you should be able to that easily using acli via ssh on a cvm

acli vm.disk_create <VM-Name> container=<Container-Name> create_size=<Disk-Size>

Hope it helps