From 9d58954e40b8d07fbdf85babf9c1a1db3ca6b34d Mon Sep 17 00:00:00 2001 From: Matthew Oliver Date: Thu, 28 Mar 2019 13:21:23 +1100 Subject: [PATCH] Start using HTTPClient and efi firmware for IPv6 netboot --- chef/cookbooks/dhcp/attributes/default.rb | 3 +- .../provisioner/recipes/dhcp_update.rb | 16 +++---- .../provisioner/recipes/update_nodes.rb | 48 ++++++++++++++----- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/chef/cookbooks/dhcp/attributes/default.rb b/chef/cookbooks/dhcp/attributes/default.rb index b657f21933..6dcd2ae883 100644 --- a/chef/cookbooks/dhcp/attributes/default.rb +++ b/chef/cookbooks/dhcp/attributes/default.rb @@ -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}" ] diff --git a/chef/cookbooks/provisioner/recipes/dhcp_update.rb b/chef/cookbooks/provisioner/recipes/dhcp_update.rb index 5349c1cba1..3af92212de 100644 --- a/chef/cookbooks/provisioner/recipes/dhcp_update.rb +++ b/chef/cookbooks/provisioner/recipes/dhcp_update.rb @@ -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", @@ -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\"; }" ] diff --git a/chef/cookbooks/provisioner/recipes/update_nodes.rb b/chef/cookbooks/provisioner/recipes/update_nodes.rb index 500cda79d0..fdc61dbac5 100644 --- a/chef/cookbooks/provisioner/recipes/update_nodes.rb +++ b/chef/cookbooks/provisioner/recipes/update_nodes.rb @@ -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\"; @@ -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