Fixes #36548 - Avoid parsing interfaces with shared MACs
In Azure it is possible to see the same interface share the same MAC address. Foreman wants to identify an interface by its MAC address, and doesn't handle it.
This patch makes parse_interfaces? take duplicate MAC addresses into account and ignores them. While it's not pretty, it at least allows other facts to be imported.
At the moment it's completely untested, but allows me to share the concept easier then describing it.
Issues: #36548
@nofaralfasi would you mind reviewing this?
The tests are failing because in test/static_fixtures/facts/facts_with_certname.json there's a host where the bridge has the same MAC as the interface as well as various VLANs. I think this is fairly common so I'm not sure what to do with this now.
While going over the original bug I realized that the issue wasn't the duplicate MAC but the duplicate interface names. I'll rewrite the PR.
I've done some further analysis and I believe my initial impression that the duplicate mac was the problem was correct. Just where it went wrong.
I now thing this is the problem: https://github.com/theforeman/foreman/blob/6aac916fb183f47596e8d543756faac27750a21e/app/models/host/base.rb#L195-L200
We can see in the actual code there's matching by mac address: https://github.com/theforeman/foreman/blob/6aac916fb183f47596e8d543756faac27750a21e/app/models/host/base.rb#L455-L481
That is not correct.
I pushed some commits that separate it out. @nofaralfasi had a question about the chef fact parser and that's now a separate commit. There's also one that improves docs because I had to understand what was going on.