Skip to content

Commit

Permalink
Start using HTTPClient and efi firmware for IPv6 netboot
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewoliver committed Mar 28, 2019
1 parent b5904df commit 9d58954
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
3 changes: 2 additions & 1 deletion chef/cookbooks/dhcp/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"option dhcp-client-debug code 226 = unsigned integer 16",
"option dhcp-client-debug 0",
"option dhcp6.bootfile-url code 59 = string",
"option dhcp6.client-arch-type code 61 = array of unsigned integer 16"
"option dhcp6.client-arch-type code 61 = array of unsigned integer 16",
"option dhcp6.vendor-class code 16 = {integer 32, integer 16, string}"
]

16 changes: 8 additions & 8 deletions chef/cookbooks/provisioner/recipes/dhcp_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

admin_net = Barclamp::Inventory.get_network_definition(node, "admin")
lease_time = node[:provisioner][:dhcp]["lease-time"]
admin6_uri = "tftp://[#{admin_ip}]/discovery"
web_port = node[:provisioner][:web_port]
admin6_uri = "http://[#{admin_ip}]:#{web_port}/discovery"

ipv4_dhcp_opts = [
"allow unknown-clients",
Expand Down Expand Up @@ -41,22 +42,21 @@
"allow unknown-clients",
"default-lease-time #{lease_time}",
"max-lease-time #{lease_time}",
'if exists dhcp-parameter-request-list {
# Always send the PXELINUX options (specified in hexadecimal)
option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3);
}',
"option dhcp6.vendor-class 0 10 \"HTTPClient\"",
"if option dhcp6.client-arch-type = 00:06 {
option dhcp6.bootfile-url \"#{admin6_uri}/ia32/efi/bootia32.efi\";
} else if option dhcp6.client-arch-type = 00:07 {
option dhcp6.bootfile-url \"/#{admin6_uri}x86_64/efi/default/boot/bootx64.efi\";
option dhcp6.bootfile-url \"#{admin6_uri}x86_64/efi/default/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:09 {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/default/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:10 {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/default/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:0b {
option dhcp6.bootfile-url \"#{admin6_uri}/aarch64/efi/default/boot/bootaa64.efi\";
} else if option dhcp6.client-arch-type = 00:0e {
option dhcp6.bootfile-url \"#{admin6_uri}/discovery/ppc64le/bios/\";
option dhcp6.bootfile-url \"#{admin6_uri}/ppc64le/bios/\";
} else {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/bios/pxelinux.0\";
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/default/boot/bootx64.efi\";
}"
]

Expand Down
48 changes: 36 additions & 12 deletions chef/cookbooks/provisioner/recipes/update_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,33 @@ def find_node_boot_mac_addresses(node, admin_data_net)
####
# Everything below is for states that require PXE booting

append = []
mac_list.each_index do |i|
dhcp_host "#{mnode.name}-#{i}" do
hostname mnode.name
macaddress mac_list[i]
if admin_mac_addresses.include?(mac_list[i])
ipaddress admin_ip_address
options [
"if exists dhcp-parameter-request-list {
if admin_data_net.ip_version == "6"
admin6_uri = "http://[#{admin_ip}]:#{web_port}/discovery"
dchp_options = [
"option dhcp6.vendor-class 0 10 \"HTTPClient\"",
"if option dhcp6.client-arch-type = 00:06 {
option dhcp6.bootfile-url \"#{admin6_uri}/ia32/efi/bootia32.efi\";
} else if option dhcp6.client-arch-type = 00:07 {
option dhcp6.bootfile-url \"#{admin6_uri}x86_64/efi/#{boot_ip_hex}/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:09 {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/#{boot_ip_hex}/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:10 {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/#{boot_ip_hex}/boot/bootx64.efi\";
} else if option dhcp6.client-arch-type = 00:0b {
option dhcp6.bootfile-url \"#{admin6_uri}/aarch64/efi/#{boot_ip_hex}/boot/bootaa64.efi\";
} else if option dhcp6.client-arch-type = 00:0e {
option dhcp6.bootfile-url \"#{admin6_uri}/ppc64le/bios/\";
} else {
option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/#{boot_ip_hex}/boot/bootx64.efi\";
}"
]
else
dchp_options = [
"if exists dhcp-parameter-request-list {
# Always send the PXELINUX options (specified in hexadecimal)
option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3);
}",
"if option arch = 00:06 {
"if option arch = 00:06 {
filename = \"discovery/ia32/efi/#{boot_ip_hex}/boot/bootx64.efi\";
} else if option arch = 00:07 {
filename = \"discovery/x86_64/efi/#{boot_ip_hex}/boot/bootx64.efi\";
Expand All @@ -245,8 +259,18 @@ def find_node_boot_mac_addresses(node, admin_data_net)
} else {
filename = \"discovery/x86_64/bios/pxelinux.0\";
}",
"next-server #{admin_ip}"
]
"next-server #{admin_ip}"
]
end

append = []
mac_list.each_index do |i|
dhcp_host "#{mnode.name}-#{i}" do
hostname mnode.name
macaddress mac_list[i]
if admin_mac_addresses.include?(mac_list[i])
ipaddress admin_ip_address
options dchp_options
prefix admin_prefix
ip_version admin_data_net.ip_version
end
Expand Down

0 comments on commit 9d58954

Please sign in to comment.