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

Create VM in specific Container

  • October 22, 2020
  • 8 replies
  • 723 views

Forum|alt.badge.img

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

Best answer by Alona

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:

 

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

8 replies

UPX
Forum|alt.badge.img+4
  • Outrider
  • 74 replies
  • October 23, 2020

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


Forum|alt.badge.img
  • Author
  • Adventurer
  • 3 replies
  • October 23, 2020

Hi @UPX

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


UPX
Forum|alt.badge.img+4
  • Outrider
  • 74 replies
  • October 23, 2020
cirvent wrote:

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


Forum|alt.badge.img
  • Author
  • Adventurer
  • 3 replies
  • October 23, 2020

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


UPX
Forum|alt.badge.img+4
  • Outrider
  • 74 replies
  • October 23, 2020

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

 

 


Forum|alt.badge.img
  • Author
  • Adventurer
  • 3 replies
  • October 23, 2020

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


UPX
Forum|alt.badge.img+4
  • Outrider
  • 74 replies
  • October 23, 2020

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


Alona
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 432 replies
  • Answer
  • November 5, 2020

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: