Long-standing discovery bug resolved: use IPAM for discovered hosts

Hello,

I found some time today (it’s Friday!) to fix the second most voted discovery issue:

In short, discovered host IP address was never changed to fall within the subnet range. All discovered hosts until this patch were always provisioned with the very same IP address as the hosts were discovered with. This now changes, Foreman correctly calls IPAM (if set) to acquire IPv4 (or IPv6 when set) address during provisioning.

The patch was hanging there for few years literally, I could not get to finishing it partially because I’ve decided to do improve IPv6 support in discovery and this blocked me since it was too much change. The new patch is more simple and it only adds what’s expected:

What works now (was not working):

  • Discover a IPv4 host and provision it in the same subnet - new IPv4 address is acquired via IPAM.
  • Discover a IPv4 host and provision it in a different subnet - new IPv4 and/or IPv6 address is acquired via IPAM.
  • Works both via autoprovisioning and quick provision form.
  • Does not work for Customize Host workflow (Edit Host form hack) - in this case error is thrown IP does not belong to subnet and user must click on Unused IP link to grab a new IP from IPAM.
1 Like

Excellent. I ran into this a few days ago, awesome to see it fixed! :slight_smile:

1 Like

If you can test this for me and report back in the PR - this needs better testing. Thanks.

I’ll see what I can do. I’m preparing for a live demo of Foreman to my colleagues tomorrow, so will revisit this after that if I get a chance.

1 Like