Skip to content

Commit

Permalink
Add host-name DHCP option to fixedaddress records
Browse files Browse the repository at this point in the history
  • Loading branch information
mporrato authored and ekohl committed Sep 15, 2022
1 parent 4402d84 commit edb32df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/smart_proxy_dhcp_infoblox/fixed_address_crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def find_host_and_name_by_ip(ip_address)

def build_host(options)
host = ::Infoblox::Fixedaddress.new(:connection => @connection)
extra_options = [{ :name => 'host-name', :value => options[:hostname] }]
host.name = options[:hostname]
host.ipv4addr = options[:ip]
host.mac = options[:mac]
Expand All @@ -63,7 +64,7 @@ def build_host(options)
host.bootfile = options[:filename]
host.use_bootfile = true
host.network_view = network_view
host.options = Proxy::DHCP::Infoblox::Plugin.settings.options
host.options = Proxy::DHCP::Infoblox::Plugin.settings.options + extra_options
host
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/host_and_fixedaddress_crud_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,15 @@ def test_build_host
assert_equal @filename, built.bootfile
assert built.use_bootfile
assert_equal @network_view, built.network_view
assert built.instance_variable_get("@options").include?({:name => 'host-name', :value => @hostname})
end

def test_build_host_with_options
begin
Proxy::DHCP::Infoblox::Plugin.settings.options = [{"name" => "xyz"}]

host = @crud.build_host(:ip => @ip, :mac => @mac, :hostname => @hostname)
assert_equal [{"name" => "xyz"}], host.instance_variable_get("@options")
assert host.instance_variable_get("@options").include?({"name" => "xyz"})
ensure
Proxy::DHCP::Infoblox::Plugin.settings.options = []
end
Expand Down

0 comments on commit edb32df

Please sign in to comment.