Solved

Cannot create and attach a vdisk to VM via REST API

  • 1 May 2020
  • 2 replies
  • 1143 views

Hi,

I am trying to attach a vdisk to a VM. So far I have found that the only way to create and attach a new vdisk to VM is via this API 

POST /vms/{uuid}/disks/attach

I am trying using this curl expression:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
  "uuid": "IDEMPOTENT_UUID",
  "vm_disks": [
    {
      "is_cdrom": false,
      "is_empty": false,
      "is_scsi_pass_through": false,
      "is_thin_provisioned": false,
      "vm_disk_create": {
        "size": 1,
        "storage_container_uuid": "CONTAINER_UUID"
      }
    }
  ]
}' 'https://10.10.10.10:9440/api/nutanix/v2.0/vms/VM_UUID/disks/attach' \
--insecure --basic --user obfuscated_username:obfuscated_password

The task fails and error is: “InvalidArgument: Invalid disk size 0”.

What am I missing here?

Thanks for your time,

Ivars

icon

Best answer by Ivars Strazdins 2 May 2020, 13:28

Turns out unit size here is bytes, so minimum value for parameter “size” must be above 2^20, that is, bigger than 1 Gb. API call works then and disk is created and attached.

View original

This topic has been closed for comments

2 replies

Turns out unit size here is bytes, so minimum value for parameter “size” must be above 2^20, that is, bigger than 1 Gb. API call works then and disk is created and attached.

Userlevel 7
Badge +35

Thanks for the followup and sharing with the community @Ivars Strazdins   this makes everyone better!