Bug #15368
closedrefresh_facts on a renamed discovered host creating second discovered host record
Description
Description of problem:
Trying to refresh facts on an existing discovered host creates a new discovered host. The new host has the same information but a name based on mac address.
How reproducible:
100%
Steps to Reproduce:
1. Discover a host
2. Update the name on the discovered host to something other than mac address based name
3. refresh_facts
4. Refresh discovered hosts page or data.
I was doing this through the api calls to discovered hosts, but was also able to reproduce on the console:
::Host::Discover.count
dh = ::Host::Discovered.find(<id>)
dh.name = 'copyme'
dh.save
dh.refresh_facts
::Host::Discover.count
Actual results:
A new discovered host with a name based on mac address was found. At this point repeating the process will not create a copy since one already exists.
Expected results:
The facts on the host would be refreshed without creating a new host.
Additional info:
It looked like refresh_facts calling Host::Discovered.import_host would find_by_name and come up empty and create a new host.