Solved

Creating a VM with a vdisk in a specified storage container.

  • 3 March 2020
  • 3 replies
  • 3025 views

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.

icon

Best answer by HITESH0801 5 March 2020, 08:41

View original

This topic has been closed for comments

3 replies

Userlevel 4
Badge +5

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": [

    {

      "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/

Userlevel 3
Badge +4

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. 

Cheers guys, that solved the problem.