Actions
Bug #31296
openDocument host import from compute resource via API
Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Description
I figured that it's possible to use POST to /api/hosts
endpoint to import hosts from a compute resource.
{"host": {"compute_resource_id": 1, "uuid": "e6cd2ca9-312b-4b35-809c-84ac72c5f182", "hostgroup_id": 3, "location_id": 2, "organization_id": 1}}
The UUID can be taken from e.g. /api/compute_resources/:id/available_virtual_machines
, so all the bits are in place.
What's lacking is at least the documentation for the uuid
parameter in the hosts
endpoint. Ideally there could be a more self-descriptive endpoint similar to PUT /api/compute_resources/:id/associate
for the import function, which aliases the /api/hosts
if that's even possible.
Where I want to go with this is an ansible module for importing hosts for foreman-ansible-modules.
Somewhat similar to this https://projects.theforeman.org/issues/27090
Actions