Fixes #39429 - Add KEA DHCP provider#949
Conversation
| network, prefix = cidr.split('/') | ||
| prefix = prefix.to_i | ||
|
|
||
| mask = (0xffffffff << (32 - prefix)) & 0xffffffff | ||
|
|
||
| [mask].pack('N').unpack('C4').join('.') |
There was a problem hiding this comment.
IPAddr has this built in:
| network, prefix = cidr.split('/') | |
| prefix = prefix.to_i | |
| mask = (0xffffffff << (32 - prefix)) & 0xffffffff | |
| [mask].pack('N').unpack('C4').join('.') | |
| cidr.netmask |
There was a problem hiding this comment.
Sadly, this is Ruby 3.1+ only :/
There was a problem hiding this comment.
Sadly the Ruby's API docs didn't mention that :(
|
Given this is an import of an previously external provider, I'd vote for "make CI green and merge it", with any further cleanup in a separate PR. |
1c98bff to
5e48025
Compare
| # NOTE: ISC DHCP reached end-of-life in October 2022. ISC recommends | ||
| # migrating to KEA DHCP. Use `dhcp_kea` for new deployments. |
There was a problem hiding this comment.
| # NOTE: ISC DHCP reached end-of-life in October 2022. ISC recommends | |
| # migrating to KEA DHCP. Use `dhcp_kea` for new deployments. |
| require 'dhcp_kea/plugin_configuration' | ||
| require 'dhcp_kea/dhcp_kea_plugin' |
There was a problem hiding this comment.
Is it a plugin? IMO it's not.
| require 'dhcp_kea/plugin_configuration' | |
| require 'dhcp_kea/dhcp_kea_plugin' | |
| require 'dhcp_kea/configuration' | |
| require 'dhcp_kea/dhcp_kea' |
There was a problem hiding this comment.
I kept dhcp_kea_plugin because we already have dhcp_kea as the entry point. Renaming the plugin file to dhcp_kea.rb would create confusion, so let's stay with this?
| #:dhcp_kea_verify_ssl: true | ||
|
|
||
| # Timeout for lease operations in seconds | ||
| #:dhcp_kea_lease_timeout: 60 |
There was a problem hiding this comment.
Discussion: 60 seconds is quite generous, and I don't know how it will work with all those queue steps and JS actions in the create host UI form.
IMO, we should lower this to <30 seconds.
There was a problem hiding this comment.
currently it is only passed into the KEA provider and stored as @lease_timeout, but it is not actually used in the lease/reservation operation calls yet.
soeither wire this into the KEA API client timeout handling, or remove the config option for now if we don’t think we need it here. that's my thought on this
| load_classes ::Proxy::DHCP::Kea::PluginConfiguration | ||
| load_programmable_settings ::Proxy::DHCP::Kea::PluginConfiguration | ||
| load_dependency_injection_wirings ::Proxy::DHCP::Kea::PluginConfiguration |
There was a problem hiding this comment.
Note that all of these are optional. If they're empty, you can leave them out. You can also use a block. For example:
smart-proxy/modules/httpboot/httpboot_plugin.rb
Lines 7 to 11 in 3e249dd
I'm fine either way, but I want to point out the option since it may be easier to understand to have fewer files.
The trade off is that it's harder to test. For load_classes that's not a concern since we don't test that anyway.
There was a problem hiding this comment.
Yeah that make sense, Thanks for pointing this out!
3555f47 to
5bd9443
Compare
|
One test changes and now it's failing completely, FYI this is in-progress right now. |
|
@evgeni @stejskalleos can you help how it keep failing here workflow? i'm not sure what i'm missing |
| 'test.example.com', | ||
| '172.16.0.50', | ||
| 'aa:bb:cc:dd:ee:ff', | ||
| Proxy::DHCP::Subnet.new('172.16.0.0/24', '255.255.255.0') |
There was a problem hiding this comment.
| Proxy::DHCP::Subnet.new('172.16.0.0/24', '255.255.255.0') | |
| Proxy::DHCP::Subnet.new('172.16.0.0', '255.255.255.0') |
Subnet.new wants an IP and a netmask, separately
| end | ||
|
|
||
| if record.is_a?(::Proxy::DHCP::Reservation) | ||
| service.delete_host(subnet.network, record) |
There was a problem hiding this comment.
delete_host only expects one parameter: a record. you're passing two, and thus it fails.
| if record.is_a?(::Proxy::DHCP::Reservation) | ||
| service.delete_host(subnet.network, record) | ||
| elsif record.is_a?(::Proxy::DHCP::Lease) | ||
| service.delete_lease(subnet.network, record) |
There was a problem hiding this comment.
delete_lease also expects just one parameter, seems there is no test for this case.
There was a problem hiding this comment.
also, for this to work, we should have issued lease4-del, not reservation-del as done by delete_reservation_by_ip, right?
|
Which version (commit) of https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/ was this based on? I have a hard time comparing the code and the issues :( |
Perhaps you can write 2 commits: 1 doing a verbatim import with proper ownership ( You can use |
Imported from smart-proxy-dhcp-kea-api. This is a verbatim import of the original KEA DHCP provider code.
Adapt the imported smart_proxy_dhcp_kea_api code for Smart Proxy core integration. - Rename classes to match Smart Proxy conventions - Update test structure and fix test issues - Add configuration template - Integrate with Smart Proxy module system
Ref: theforeman/foremanctl#531 (comment)
KEA DHCP integration for Smart Proxy as we're transitioning away from ISC DHCP (which reached EOL in 2022) to KEA now.
Adds Smart Proxy DHCP provider for ISC KEA DHCP server using the KEA Control Agent API, providing a migration path for users currently using the deprecated dhcp_isc provider.
Note: Based on the
smart_proxy_dhcp_kea_apigem by Sam McCarthy, to integrate into Smart Proxy core. https://gitlab.surrey.ac.uk/sm0049/smart-proxy-dhcp-kea-api/-/issues/3Fixes: https://redhat.atlassian.net/browse/SAT-27739