Project

General

Profile

« Previous | Next » 

Revision d1c1f81d

Added by Frank Wall over 10 years ago

fixes #3941 - Support for Junos ZTP

View differences:

lib/proxy/dhcp/server/isc.rb
statements << "option host-name = \\\"#{record.name}\\\";" if record.name
statements += solaris_options_statements(options)
statements += ztp_options_statements(options)
omcmd "set statements = \"#{statements.join(" ")}\"" unless statements.empty?
omcmd "create"
......
end
options
end
# Quirk: Junos ZTP requires special DHCP options
def ztp_options_statements(options)
statements = []
if options[:filename] && options[:filename].match(/^ztp.cfg.*/i)
logger.debug "setting ZTP options"
opt150 = ip2hex validate_ip(options[:nextServer])
statements << "option option-150 = #{opt150};"
statements << "option FM_ZTP.config-file-name = \\\"#{options[:filename]}\\\";"
end
statements
end
end
end
lib/proxy/tftp.rb
end
end
class Ztp < Tftp
def pxeconfig_dir
"#{path}/ztp.cfg"
end
def pxe_default
pxeconfig_dir
end
def pxeconfig_file mac
"#{pxeconfig_dir}/"+mac.gsub(/:/,"").upcase
end
end
class << self
def fetch_boot_file dst, src
filename = src.split("/")[-1]
test/server_isc_test.rb
post '/dhcp/192.168.122.10', data
assert last_response.ok?, 'Last response was not ok'
end
def test_ztp_quirks
dhcp = Proxy::DHCP::Server::ISC.new(:name => '192.168.122.1', :config => './test/dhcp.conf', :leases => './test/dhcp.leases')
assert_equal [], dhcp.send(:ztp_options_statements, {})
assert_equal [], dhcp.send(:ztp_options_statements, {:filename => 'foo.cfg'})
assert_equal ['option option-150 = c0:a8:7a:01;', 'option FM_ZTP.config-file-name = \\"ztp.cfg\\";'],
dhcp.send(:ztp_options_statements, {:filename => 'ztp.cfg', :nextServer => '192.168.122.1'})
end
end

Also available in: Unified diff