I am trying to create a host via API by posting json definition. I grabbed the json from the production.log when I manually created the host the first time. However, with the json, I post it to /api/host endpoint with credentials, while it creates the host, the size of the disk defaults to whatever hostgroup compute profile it’s using, and it also does not use the datastore I instructed it to use in the json. Is this a bug?
The json I’m using:
{
"host": {
"name": "test-server",
"organization_id": "2",
"location_id": "1",
"hostgroup_id": "3",
"puppetclass_ids": [
""
],
"managed": "true",
"type": "Host::Managed",
"interfaces_attributes": {
"0": {
"_destroy": "0",
"type": "Nic::Managed",
"mac": "",
"identifier": "eth0",
"name": "test-server",
"domain_id": "1",
"subnet_id": "1",
"ip": "10.1.130.249",
"ip6": "",
"managed": "1",
"primary": "1",
"provision": "1",
"execution": "1",
"virtual": "0",
"tag": "",
"attached_to": "",
"compute_attributes": {
"type": "VirtualVmxnet3",
"network": "dvportgroup-124032"
}
}
},
"compute_attributes": {
"cpus": "4",
"corespersocket": "1",
"memory_mb": "8192",
"firmware": "bios",
"cluster": "Cluster1",
"resource_pool": "Test",
"path": "/Datacenters/Test",
"guest_id": "centos7_64Guest",
"hardware_version": "Default",
"memoryHotAddEnabled": "1",
"cpuHotAddEnabled": "1",
"add_cdrom": "0",
"start": "1",
"annotation": "",
"scsi_controllers": "{\"scsiControllers\":[{\"type\":\"ParaVirtualSCSIController\",\"key\":1000}],\"volumes\":[{\"thin\":true,\"name\":\"Hard disk\",\"mode\":\"persistent\",\"controllerKey\":1000,\"size\":83886080,\"sizeGb\":200,\"datastore\":\"Datastore05\"}]}",
"image_id": "500f75d0-502c-1b9a-e098-a0e48e75376c"
},
"architecture_id": "1",
"operatingsystem_id": "3",
"provision_method": "image",
"build": "1",
"medium_id": "",
"ptable_id": "",
"pxe_loader": "",
"disk": "",
"root_pass": "[FILTERED]",
"is_owned_by": "5-Users",
"enabled": "1",
"comment": "",
"overwrite": "false"
}
}