Closed zyronix closed 6 years ago
Pushed a commit to foreman_hyperv, since that's where the case-insensitivity ends up being a problem.
Please try that change out and see if it solves your issue in a suitable way.
I'm trying to keep from putting Foreman specific workarounds in the Fog provider, instead just sticking to thin wrappers around the PowerShell commandlets as best as I can.
Awesome, test and works. Within 6 minutes a working fix, kudos 👍. Foreman now indeed sees the mac as lowercase (notable in the interface).
The only thing which I am now sure about, might this be a problem for other supported DHCP servers? Like Windows DHCP? I don't have an environment to test that case.
I only have access to Infoblox DHCP for testing, and MAC addresses are treated in a case-insensitive manner by it. So I honestly have no idea if other DHCP servers would also fail on this.
Either way, really nice to hear that the solution works for you. Thanks for helping find these issues. :heart:
Hi there,
Been running into a bug with Hyper-V, dhcp-isc and Foreman 1.16. (All running latest version on Debian 9 or Windows Server 2016). Creating a host from the foreman interface works just as intended, the VM is created and the boots correctly and I am able to start the Debian preseed for the host. However, during the final step of the unattended installation, a finish script will run: calling the foreman api and telling it that the build has finished. During this step, foreman finilises the machine. One of the step that it does is delete the DCHP lease and recreate it removing the requirement for provising. This is where the bug occurs.
Hyper-V output the MAC in uppercase, while ISC-DHCP records the in lowercase. So whenever you require Foreman for the lowcase MAC address, the tell you that the mac address does not exist:
And if we request it with lower case:
But what happens when you sent a delete for this record that 'does not excist'?
Looking at the log file of the foreman proxy, you will see just a simple http 200 response for this call, but no communication will be done to the DHCP server. This is because Foreman 'thinks' that the record isn't there and thus not delete it. The next call after that is recreating the DHCP lease, but this time ISC-DHCP will tell you: 'no gonna happen, this lease already exist'. Resulting in the API returning an error and making the provision fail.
The problem here is that during the creation of the VM, dynamic mac address is disabled and a static mac address is assigned. Hyper-V determines the new mac address and then fog-hyperv requests the mac address using the 'Get-VMNetworkAdapter' cmdlet. This cmdlet always returns the mac in upercase:
Now, I will also reports this bug at the foreman project, because a mac address is NOT case sensitive, thus the API should not handle it with case sensitivy. However, you could also help with this; If this plugin would convert the mac-address to lowercase; there wouldn't be a problem. Some dirty hack I did to make this work is the following code in the network_adapter request:
Maybe you have a beter (cleaner) solution for this?