Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36325 - Support key-algorithm in omshell #871

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/settings.d/dhcp_isc.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Specifies TSIG key name and secret
#:key_name: secret_key_name
#:key_secret: secret_key
# This needs to match the server configuration
#:key_algorithm: HMAC-MD5

#:omapi_port: 7911

Expand Down
4 changes: 3 additions & 1 deletion modules/dhcp_common/isc/omapi_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ class IscOmapiProvider < ::Proxy::DHCP::Server
include Proxy::Util
attr_reader :omapi_port, :key_name, :key_secret

def initialize(server, omapi_port, subnets = nil, key_name = nil, key_secret = nil, service = nil, free_ips_service = nil)
def initialize(server, omapi_port, subnets = nil, key_name = nil, key_secret = nil, service = nil, free_ips_service = nil, key_algorithm = nil)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really refactor this to keyword arguments, but I wanted to stay compatible.

super(server, subnets, service, free_ips_service)
# TODO: verify key name and secret
@key_name = key_name
@key_secret = key_secret
@key_algorithm = key_algorithm
@omapi_port = omapi_port
end

Expand Down Expand Up @@ -67,6 +68,7 @@ def om
end

def om_connect
omcmd("key-algorithm #{@key_algorithm}") if @key_algorithm
omcmd("key #{@key_name} \"#{@key_secret}\"", true) if @key_name && @key_secret
omcmd "server #{name}"
omcmd "port #{@omapi_port}"
Expand Down
2 changes: 1 addition & 1 deletion modules/dhcp_isc/configuration_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load_dependency_injection_wirings(container, settings)
container.dependency :dhcp_provider, (lambda do
Proxy::DHCP::CommonISC::IscOmapiProvider.new(
settings[:server], settings[:omapi_port], settings[:subnets], settings[:key_name], settings[:key_secret],
container.get_dependency(:subnet_service), container.get_dependency(:free_ips))
container.get_dependency(:subnet_service), container.get_dependency(:free_ips), settings[:key_algorithm])
end)
end

Expand Down