Foreman 1.21.3 Discovery plugin 14.0.1
I’m trying, via the REST API, to build a discovered host with 2 IPs assigned to it. One that comes from the normal FDI DHCP process, and one that’s obtained after the fact, hopefully assigned during the provision process.
The problem I’m running into is when I try to put the IP on the interface I want (lets say p3p1) I get an error 2019-08-29T22:11:08 [W|app|473028af] Not queueing Host::Managed: [“Identifier has already been taken”, “Interfaces some interfaces are invalid”]
If I leave the identifier off, I get the IP discovered from the DHCP server just fine, and the box builds, it just creates a new interface with the IP instead of assigning the IP to the interface I want.
Is it possible to, via the API, create a host and specify the non-primary IP on a specific interface? The payload I’m using is:
{
"discovered_host": {
"name": "SomeTestBox",
"mac": "xx:xx:8f:75:ea:xx",
"ip": "10.4.16.49",
"hostgroup_id": 24,
"subnet_id": 3,
"build": 1,
"managed": "1",
"interfaces_attributes": {
"0": {
"managed": "1",
"subnet_id": "10",
"primary": "0",
"virtual": "0",
"_destroy": "0",
"mac": "3c:fd:fe:db:83:f0",
"identifier": "p3p1"
}
}
}
}
It looks like the PUT to the api/v2/discovered_hosts endpoint ends up being much the same as the post to the api/v2/hosts endpoint. I’ve created a host in the UI and it really looks the same, the only difference is that all 5 IPs are identified in the interfaces_attributes (eth1, eth2, ipmi, p3p1, p3p2)
The interface doesn’t have an IP on discovery, because nothing on that network is listening for DHCP, so it was very handy that I can just request this by including the subnet id and having it managed, or using the freeip endpoint. I’ve tried both with and without the IP, with and without the mac (that just errors saying you have to have a mac)
also, it’s adorable that when you get a 500 on the build endpoints, it gives you the message: RuntimeError: resource have no errors