Creating a VM with a vdisk in a specified storage container. | Nutanix Community
Skip to main content

Hi,

I am trying to create a VM using the v3 API and have a question about creating the vdisks. I can specify the disk details (size, type, etc.) in the create VM call, but don't seem to be able to specify the storage container to use. Is this correct? 

The only work around that I've found is to use the v1 API to create the vdisk, grab its UUID, and use that in the v3 call to create the VM. I can't see a call to create a vdisk in either v2 or v3.

Darren.

Hey Darren,

You’re right it’s not really clear from the formatting provided in the API explorer. 
Look for examples of using 
"vm_disk_create":{  
            "storage_container_uuid":"<uuid>",
            "size":<size_in_bytes>
… instead of specifying vmdisk UUID.

Keep in mind, for data protection snapshots to work it’s required that all of a VM’s vdisks reside in the same container (excluding attached ISOs in the CDROM drive), so you could run into issues backing up the VM if you create vdisks in different containers. 


Hello @DarrenP 

There is a provision in v2 API to update a Virtual machine with a vdisk, and specify the vdisk size and container UUID. 

So you can simply create a virtual machine and then call this API endpoint to update the VM. 
 


The full API call is 

{

  "uuid": "string",

  "vm_disks": d

    {

      "disk_address": {

        "device_bus": "SCSI",

        "device_index": 123,

        "device_uuid": "string",

        "disk_label": "string",

        "is_cdrom": true,

        "ndfs_filepath": "string",

        "vmdisk_uuid": "string",

        "volume_group_uuid": "string"

      },

      "flash_mode_enabled": true,

      "is_cdrom": true,

      "is_empty": true,

      "is_scsi_pass_through": true,

      "is_thin_provisioned": true,

      "vm_disk_clone": {

        "disk_address": {

          "device_bus": "SCSI",

          "device_index": 123,

          "device_uuid": "string",

          "disk_label": "string",

          "is_cdrom": true,

          "ndfs_filepath": "string",

          "vmdisk_uuid": "string",

          "volume_group_uuid": "string"

        },

        "minimum_size": 123,

        "snapshot_group_uuid": "string",

        "storage_container_uuid": "string"

      },

      "vm_disk_create": {. <---------------VM Disk create 

        "size": 123,  <-------------Size

        "storage_container_uuid": "string" <-------Container 

      }

    }

  ]

}



You can use this documentation for more info 

https://www.nutanix.dev/reference/prism_element/v2/api/vms/post-vms-uuid-disks-attach-attachvmdisk/


Cheers guys, that solved the problem.