VM Provision using API

Hi,

I am trying to provision VM through REST API using ‘api/provision_requests’ and I keep getting this error, although I have already specify the ‘placement_host_name’ in the json.

[EVM] VM [miq-win10-test-deleteme-] Step [CheckProvisioned] Status [Error Creating VM] Message [[MiqException::MiqProvisionError]: Destination placement_ds_name not provided]

Below is the json I sent via Postman:

{

  "version" : "1.1",

  "template_fields" : {

    "name" : "xxx-Template-xxx"    

  },

  "vm_fields" : {    

    "number_of_vms" : 1,    

    "number_of_cpus" : 1,    

    "vm_name" : "vm-deleteme-",

    "vm_memory" : 1024,

    "vlan" : "xxx_vlan",

    "vm_auto_start" : true,          

    "provision" : "VMware",

    "placement_auto" : false,    

    "host_name": "xx.company.com",

    "hostname": "xx.company.com",

    "number_of_sockets" : 1,

    "cores_per_socket" : 1,

    "placement_ds_name" : "ds_xx_SSD",

    "placement_host_name" : "xx.company.com"

  },

  "requester" : {

    "user_name" : "ks",

    "owner_first_name" : "ks",

    "owner_last_name" : "lim",

    "owner_email" : "ks@gmail.com",

    "auto_approve" : true

  },  

  "ems_custom_attributes" : {

  },

  "miq_custom_attributes" : {

  }

}

Any clue on what’s going wrong? Thanks!

Try using the VMDB object IDs for placement_host_name and placement_ds_name, so for example lookup the IDs using something like the following from the Rails console:

Storage.where(:name => 'ds_xx_SSD').first.id
Host.where(:name => 'xx.company.com').first.id

Hope this helps,
pemcg

Thanks for your reply. Yup, it works! I managed to get it work after entering the id instead of the name itself.