From 41c2a8f8052889c76371224778f437b6af3a706e Mon Sep 17 00:00:00 2001 From: Markus Reisner Date: Wed, 22 Nov 2023 18:06:54 +0100 Subject: [PATCH] Refs #36834 - New PXE loader "Grub2 UEFI SecureBoot (target OS)" --- app/models/concerns/orchestration/dhcp.rb | 3 +-- app/models/concerns/orchestration/tftp.rb | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/concerns/orchestration/dhcp.rb b/app/models/concerns/orchestration/dhcp.rb index 5938e0394519..3f4dac566258 100644 --- a/app/models/concerns/orchestration/dhcp.rb +++ b/app/models/concerns/orchestration/dhcp.rb @@ -126,8 +126,7 @@ def dhcp_attrs(record_mac) dhcp_attr[:nextServer] = boot_server unless host.pxe_loader == 'None' filename = operatingsystem.boot_filename(host) if filename.include? "@@subdir@@" - mac = host.mac.downcase - filename = filename.gsub("@@subdir@@", mac.tr(':', '-').downcase) + filename = filename.gsub("@@subdir@@", record_mac.tr(':', '-').downcase) end dhcp_attr[:filename] = filename if filename.present? if jumpstart? diff --git a/app/models/concerns/orchestration/tftp.rb b/app/models/concerns/orchestration/tftp.rb index 4c1183b86433..41eea436046f 100644 --- a/app/models/concerns/orchestration/tftp.rb +++ b/app/models/concerns/orchestration/tftp.rb @@ -82,19 +82,16 @@ def default_pxe_render(kind) # Adds the host to the forward and reverse TFTP zones # +returns+ : Boolean true on success def setTFTP(kind) - if kind.to_s == "PXEGrub2TargetOS" - content = generate_pxe_template("PXEGrub2".to_sym) - else - content = generate_pxe_template(kind) - end + content = if isPXEGrub2TargetOS(kind) + generate_pxe_template("PXEGrub2".to_sym) + else + generate_pxe_template(kind) + end if content logger.info "Deploying TFTP #{kind} configuration for #{host.name}" each_unique_feasible_tftp_proxy do |proxy| mac_addresses_for_provisioning.each do |mac_addr| - targetos = nil - if kind.to_s == "PXEGrub2TargetOS" - targetos = host.operatingsystem.name.downcase - end + targetos = host.operatingsystem.name.downcase if isPXEGrub2TargetOS(kind) proxy.set(kind, mac_addr, {:pxeconfig => content, :targetos => targetos}) end end @@ -212,4 +209,8 @@ def each_unique_feasible_tftp_proxy end results.all? end + + def isPXEGrub2TargetOS(kind) + kind.to_s == "PXEGrub2TargetOS" + end end