Skip to content
Snippets Groups Projects
Verified Commit 2707fabd authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Support nextserver names if DHCP supports them

parent 5d5315c9
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,10 @@ module ForemanWds
def boot_server
return super if host.nil? || !host.wds? || host.wds_facet.nil?
return host.wds_server.next_server_ip if host.build? # TODO: Support choosing local boot method
if host.build? # TODO: Support choosing local boot method
return host.wds_server.next_server_ip unless subnet.dhcp.has_capability?(:DHCP, :dhcp_filename_hostname)
return host.wds_server.next_server_name
end
super
end
......
......@@ -110,8 +110,12 @@ class WdsServer < ApplicationRecord
end
end
def next_server_name
URI(url).host
end
def next_server_ip
res = Resolv::DNS.open { |dns| dns.getaddresses(URI(url).host) }.select { |addr| addr.is_a? Resolv::IPv4 }.first
res = Resolv::DNS.open { |dns| dns.getaddresses(next_server_name) }.select { |addr| addr.is_a? Resolv::IPv4 }.first
return res.to_s if res
IPSocket.getaddress URI(url).host
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment