Bug #12083
closedDomain matching isn't specific enough
Description
As per the discussion on the foreman list1 and on IRC, we are running into an issue where the domain matching is not specific enough to properly match a host. We had suggested
We had suggested replacing https://github.com/theforeman/foreman/blob/develop/app/models/nic/interface.rb#L101 with
self.domain = Domain.all.find { |d| d == name.split('.', 2).last }
but after discussions with Tomer, I realized that this wouldn't match anything correctly if there wasn't a . preceding the domain, and the domain name value that would be returned when querying by domain_id wouldn't have that.
As per that conversation I'm opening up this bug to get a fix that should hopefully provide proper (exact?) domain matching. If any further info is required let me know.
Note: Because of this bug we'll have to clean up our database too since we have a bunch of hosts that are now in disrepair because of it.
[1] https://groups.google.com/forum/#!msg/foreman-users/laa0UwXQo60/PBWVqN_zCQAJ