Module: IDRAC::Boot
- Included in:
- Client
- Defined in:
- lib/idrac/boot.rb
Instance Method Summary collapse
-
#bios_error_prompt_disabled? ⇒ Boolean
Check if BIOS error prompt is disabled.
- #bios_hdd_placeholder_enabled? ⇒ Boolean
- #bios_os_power_control_enabled? ⇒ Boolean
-
#boot ⇒ Object
Shorter alias for convenience.
-
#boot_config ⇒ Object
Get boot configuration with snake_case fields.
-
#boot_options ⇒ Object
Get boot options collection - the actual boot devices present in the system This is different from boot_config which returns the boot configuration settings.
-
#boot_raw ⇒ Object
Get raw Redfish boot data (CamelCase).
- #boot_to_bios_setup(enabled: "Once", mode: nil) ⇒ Object
- #boot_to_cd(enabled: "Once", mode: nil) ⇒ Object
- #boot_to_disk(enabled: "Once", mode: nil) ⇒ Object
-
#boot_to_pxe(enabled: "Once", mode: nil) ⇒ Object
Convenience methods for common boot targets.
- #boot_to_usb(enabled: "Once", mode: nil) ⇒ Object
-
#clear_boot_override ⇒ Object
Clear boot override settings.
-
#configure_bios_settings(settings) ⇒ Object
Configure BIOS settings.
-
#create_scp_for_bios(settings) ⇒ Object
Create System Configuration Profile for BIOS settings.
-
#ensure_uefi_boot ⇒ Object
Ensure UEFI boot mode.
-
#get_bios_boot_options ⇒ Object
Legacy method names for backward compatibility.
- #get_boot_devices ⇒ Object
-
#get_idrac_version ⇒ Object
Get iDRAC version - needed for boot management differences.
-
#import_system_configuration(scp, target: "ALL", reboot: false) ⇒ Object
Import System Configuration Profile for advanced configurations.
-
#override_boot_source ⇒ Object
This sets boot to HD but before that it sets the one-time boot to CD Different approach for iDRAC 8 vs 9.
-
#scp_boot_mode_uefi(idrac_license_version: 9) ⇒ Object
# Servers can boot in BIOS mode or in UEFI (modern, extensible BIOS replacement) mode.
-
#set_bios(hash) ⇒ Object
What triggers a reboot? infohub.delltechnologies.com/en-US/l/server-configuration-profiles-reference-guide/host-reboot-2/.
-
#set_bios_ignore_errors(value = true) ⇒ Object
Configure BIOS to ignore boot errors.
-
#set_bios_os_power_control ⇒ Object
Configure BIOS to optimize for OS power management.
-
#set_boot_order(devices) ⇒ Object
Set the permanent boot order.
-
#set_boot_order_hd_first ⇒ Object
Set boot order (HD first).
-
#set_boot_override(target, enabled: "Once", mode: nil) ⇒ Object
Set boot override for next boot.
- #set_uefi_boot_cd_once_then_hd ⇒ Object
Instance Method Details
#bios_error_prompt_disabled? ⇒ Boolean
Check if BIOS error prompt is disabled
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/idrac/boot.rb', line 551 def bios_error_prompt_disabled? response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/Bios") if response.status == 200 begin data = JSON.parse(response.body) if data["Attributes"] && data["Attributes"].has_key?("ErrPrompt") current_value = data["Attributes"]["ErrPrompt"] debug "ErrPrompt current value: '#{current_value}' (checking if == 'Disabled')", 1, :cyan return current_value == "Disabled" else debug "ErrPrompt attribute not found in BIOS settings", 1, :yellow debug "Available BIOS attributes: #{data['Attributes']&.keys&.sort&.join(', ')}", 2, :yellow if data["Attributes"] return false end rescue JSON::ParserError debug "Failed to parse BIOS response", 0, :red return false end else debug "Failed to get BIOS information. Status code: #{response.status}", 0, :red return false end end |
#bios_hdd_placeholder_enabled? ⇒ Boolean
576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/idrac/boot.rb', line 576 def bios_hdd_placeholder_enabled? case self.license_version.to_i when 8 # scp = usable_scp(get_system_configuration_profile(target: "BIOS")) # scp["BIOS.Setup.1-1"]["HddPlaceholder"] == "Enabled" true else response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/Bios") json = JSON.parse(response.body) raise "Error reading HddPlaceholder setup" if json&.dig('Attributes','HddPlaceholder').blank? json["Attributes"]["HddPlaceholder"] == "Enabled" end end |
#bios_os_power_control_enabled? ⇒ Boolean
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/idrac/boot.rb', line 590 def bios_os_power_control_enabled? case self.license_version.to_i when 8 scp = usable_scp(get_system_configuration_profile(target: "BIOS")) scp["BIOS.Setup.1-1"]["ProcCStates"] == "Enabled" && scp["BIOS.Setup.1-1"]["SysProfile"] == "PerfPerWattOptimizedOs" && scp["BIOS.Setup.1-1"]["ProcPwrPerf"] == "OsDbpm" else response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/Bios") json = JSON.parse(response.body) raise "Error reading PowerControl setup" if json&.dig('Attributes').blank? json["Attributes"]["ProcCStates"] == "Enabled" && json["Attributes"]["SysProfile"] == "PerfPerWattOptimizedOs" && json["Attributes"]["ProcPwrPerf"] == "OsDbpm" end end |
#boot ⇒ Object
Shorter alias for convenience
100 101 102 |
# File 'lib/idrac/boot.rb', line 100 def boot boot_config end |
#boot_config ⇒ Object
Get boot configuration with snake_case fields
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/idrac/boot.rb', line 32 def boot_config response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1") if response.status == 200 begin data = JSON.parse(response.body) boot_data = data["Boot"] || {} # Get boot options for resolving references = {} begin = .each do |opt| [opt["id"]] = opt["display_name"] || opt["name"] end rescue # Ignore errors fetching boot options end # Build boot order with resolved names boot_order = (boot_data["BootOrder"] || []).map do |ref| { "reference" => ref, "name" => [ref] || ref } end # Return hash with snake_case fields { # Boot override settings (for one-time or continuous boot) "boot_source_override_enabled" => boot_data["BootSourceOverrideEnabled"], # Disabled/Once/Continuous "boot_source_override_target" => boot_data["BootSourceOverrideTarget"], # None/Pxe/Hdd/Cd/etc "boot_source_override_mode" => boot_data["BootSourceOverrideMode"], # UEFI/Legacy "allowed_override_targets" => boot_data["[email protected]"] || [], # Permanent boot order with resolved names "boot_order" => boot_order, # [{reference: "Boot0001", name: "Ubuntu"}] "boot_order_refs" => boot_data["BootOrder"] || [], # Raw references for set_boot_order # UEFI specific fields "uefi_target_boot_source_override" => boot_data["UefiTargetBootSourceOverride"], "stop_boot_on_fault" => boot_data["StopBootOnFault"], # References to other resources "boot_options_uri" => boot_data.dig("BootOptions", "@odata.id"), "certificates_uri" => boot_data.dig("Certificates", "@odata.id") }.compact rescue JSON::ParserError raise Error, "Failed to parse boot response: #{response.body}" end else raise Error, "Failed to get boot configuration. Status code: #{response.status}" end end |
#boot_options ⇒ Object
Get boot options collection - the actual boot devices present in the system This is different from boot_config which returns the boot configuration settings
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/idrac/boot.rb', line 106 def response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/BootOptions?$expand=*($levels=1)") if response.status == 200 begin data = JSON.parse(response.body) # Return the BootOption objects with snake_case data["Members"]&.map do |member| { "id" => member["Id"], # Boot0001 "boot_option_reference" => member["BootOptionReference"], # Boot0001 "display_name" => member["DisplayName"], # "Integrated RAID Controller 1: Ubuntu" "name" => member["DisplayName"] || member["Name"], # Alias for display_name "enabled" => member["BootOptionEnabled"], # true/false "uefi_device_path" => member["UefiDevicePath"], # UEFI device path "description" => member["Description"] }.compact end || [] rescue JSON::ParserError raise Error, "Failed to parse boot options response: #{response.body}" end else [] end end |
#boot_raw ⇒ Object
Get raw Redfish boot data (CamelCase)
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/idrac/boot.rb', line 88 def boot_raw response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1") if response.status == 200 data = JSON.parse(response.body) data["Boot"] || {} else raise Error, "Failed to get boot configuration. Status code: #{response.status}" end end |
#boot_to_bios_setup(enabled: "Once", mode: nil) ⇒ Object
247 248 249 |
# File 'lib/idrac/boot.rb', line 247 def boot_to_bios_setup(enabled: "Once", mode: nil) set_boot_override("BiosSetup", enabled: enabled, mode: mode) end |
#boot_to_cd(enabled: "Once", mode: nil) ⇒ Object
239 240 241 |
# File 'lib/idrac/boot.rb', line 239 def boot_to_cd(enabled: "Once", mode: nil) set_boot_override("Cd", enabled: enabled, mode: mode) end |
#boot_to_disk(enabled: "Once", mode: nil) ⇒ Object
235 236 237 |
# File 'lib/idrac/boot.rb', line 235 def boot_to_disk(enabled: "Once", mode: nil) set_boot_override("Hdd", enabled: enabled, mode: mode) end |
#boot_to_pxe(enabled: "Once", mode: nil) ⇒ Object
Convenience methods for common boot targets
231 232 233 |
# File 'lib/idrac/boot.rb', line 231 def boot_to_pxe(enabled: "Once", mode: nil) set_boot_override("Pxe", enabled: enabled, mode: mode) end |
#boot_to_usb(enabled: "Once", mode: nil) ⇒ Object
243 244 245 |
# File 'lib/idrac/boot.rb', line 243 def boot_to_usb(enabled: "Once", mode: nil) set_boot_override("Usb", enabled: enabled, mode: mode) end |
#clear_boot_override ⇒ Object
Clear boot override settings
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/idrac/boot.rb', line 181 def clear_boot_override debug "Clearing boot override...", 1, :yellow body = { "Boot" => { "BootSourceOverrideEnabled" => "Disabled" } } response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1", body: body.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "Boot override cleared successfully.", 1, :green return true else raise Error, "Failed to clear boot override: #{response.status} - #{response.body}" end end |
#configure_bios_settings(settings) ⇒ Object
Configure BIOS settings
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/idrac/boot.rb', line 496 def configure_bios_settings(settings) response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1/Bios/Settings", body: { "Attributes": settings }.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) puts "BIOS settings configured. A system reboot is required for changes to take effect.".green # Check if we need to wait for a job if response.headers["Location"] job_id = response.headers["Location"].split("/").last wait_for_job(job_id) end return true else = "Failed to configure BIOS settings. Status code: #{response.status}" begin error_data = JSON.parse(response.body) if error_data["error"] && error_data["error"]["@Message.ExtendedInfo"] error_info = error_data["error"]["@Message.ExtendedInfo"].first += ", Message: #{error_info['Message']}" end rescue # Ignore JSON parsing errors end raise Error, end end |
#create_scp_for_bios(settings) ⇒ Object
Create System Configuration Profile for BIOS settings
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/idrac/boot.rb', line 641 def create_scp_for_bios(settings) attributes = [] settings.each do |key, value| attributes << { "Name" => key.to_s, "Value" => value, "Set On Import" => "True" } end scp = { "SystemConfiguration" => { "Components" => [ { "FQDD" => "BIOS.Setup.1-1", "Attributes" => attributes } ] } } return scp end |
#ensure_uefi_boot ⇒ Object
Ensure UEFI boot mode
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/idrac/boot.rb', line 289 def ensure_uefi_boot response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/Bios") if response.status == 200 begin data = JSON.parse(response.body) if data["Attributes"]["BootMode"] == "Uefi" puts "System is already in UEFI boot mode".green return true else puts "System is not in UEFI boot mode. Setting to UEFI...".yellow # Create payload for UEFI boot mode payload = { "Attributes": { "BootMode": "Uefi" } } # If iDRAC 9, we need to enable HddPlaceholder if get_idrac_version == 9 payload[:Attributes][:HddPlaceholder] = "Enabled" end response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1/Bios/Settings", body: payload.to_json, headers: { 'Content-Type': 'application/json' } ) wait_for_job(response.headers["location"]) end rescue JSON::ParserError raise Error, "Failed to parse BIOS response: #{response.body}" end else raise Error, "Failed to get BIOS information. Status code: #{response.status}" end end |
#get_bios_boot_options ⇒ Object
Legacy method names for backward compatibility
134 135 136 |
# File 'lib/idrac/boot.rb', line 134 def get_bios_boot_sources end |
#get_boot_devices ⇒ Object
138 139 140 |
# File 'lib/idrac/boot.rb', line 138 def get_boot_devices end |
#get_idrac_version ⇒ Object
Get iDRAC version - needed for boot management differences
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/idrac/boot.rb', line 608 def get_idrac_version response = authenticated_request(:get, "/redfish/v1") if response.status == 200 begin data = JSON.parse(response.body) redfish = data["RedfishVersion"] server = response.headers["server"] case server.to_s.downcase when /appweb\/4.5.4/, /idrac\/8/ return 8 when /apache/, /idrac\/9/ return 9 else # Try to determine by RedfishVersion as fallback if redfish == "1.4.0" return 8 elsif redfish == "1.18.0" return 9 else raise Error, "Unknown iDRAC version: #{server} / #{redfish}" end end rescue JSON::ParserError raise Error, "Failed to parse iDRAC response: #{response.body}" end else raise Error, "Failed to get iDRAC information. Status code: #{response.status}" end end |
#import_system_configuration(scp, target: "ALL", reboot: false) ⇒ Object
Import System Configuration Profile for advanced configurations
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/idrac/boot.rb', line 667 def import_system_configuration(scp, target: "ALL", reboot: false) params = { "ImportBuffer" => JSON.generate(scp), "ShareParameters" => { "Target" => target } } # Configure shutdown behavior params["ShutdownType"] = "Forced" params["HostPowerState"] = reboot ? "On" : "Off" response = authenticated_request( :post, "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration", body: params.to_json, headers: { 'Content-Type': 'application/json' } ) task = wait_for_task(response.headers["location"]) debugger return task end |
#override_boot_source ⇒ Object
This sets boot to HD but before that it sets the one-time boot to CD Different approach for iDRAC 8 vs 9
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/idrac/boot.rb', line 473 def override_boot_source # For now try with all iDRAC versions if self.license_version.to_i == 9 set_boot_order_hd_first() set_one_time_virtual_media_boot() else scp = {"FQDD"=>"iDRAC.Embedded.1", "Attributes"=> [{"Name"=>"ServerBoot.1#BootOnce", "Value"=>"Enabled", "Set On Import"=>"True"}, {"Name"=>"ServerBoot.1#FirstBootDevice", "Value"=>"VCD-DVD", "Set On Import"=>"True"}]} # set_uefi_boot_cd_once_then_hd # scp = self.set_bios_boot_cd_first # get_bios_boot_options # Make sure we know if the OS is calling it Unknown or RAID # {"FQDD"=>"BIOS.Setup.1-1", "Attributes"=> # [{"Name"=>"ServerBoot.1#BootOnce", "Value"=>"Enabled", "Set On Import"=>"True"}, # {"Name"=>"ServerBoot.1#FirstBootDevice", "Value"=>"VCD-DVD", "Set On Import"=>"True"}, # {"Name"=>"BootSeqRetry", "Value"=>"Disabled", "Set On Import"=>"True"}, # {"Name"=>"UefiBootSeq", "Value"=>"Unknown.Unknown.1-1,NIC.PxeDevice.1-1,Floppy.iDRACVirtual.1-1,Optical.iDRACVirtual.1-1", # "Set On Import"=>"True"}]} # 3.3.0 :018 > scp1 = {"FQDD"=>"BIOS.Setup.1-1", "Attributes"=> [{"Name"=>"OneTimeUefiBootSeq", "Value"=>"VCD-DVD", "Set On Import"=>"True"}, {"Name"=>"BootSeqRetry", "Value"=>"Disabled", "Set On Import"=>"True"}, {"Name"=>"UefiBootSeq", "Value"=>"Unknown.Unknown.1-1,NIC.PxeDevice.1-1", "Set On Import"=>"True"}]} set_system_configuration_profile(scp) # This will cycle power and leave the device off. end end |
#scp_boot_mode_uefi(idrac_license_version: 9) ⇒ Object
# Servers can boot in BIOS mode or in UEFI (modern, extensible BIOS replacement) mode.
# We use UEFI mode.
# self.get(path: "Systems/System.Embedded.1/Bios/Settings?$select=BootMode")
res = self.get(path: "Systems/System.Embedded.1/Bios")
if res["body"]["Attributes"]["BootMode"] == "Uefi"
return { status: :success }
else
res = self.set_system_configuration_profile(scp_boot_mode_uefi, reboot: true)
# Then must power cycle the server
self.power_on!(wait: true)
self.power_off!(wait: true)
return res
end
346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/idrac/boot.rb', line 346 def scp_boot_mode_uefi(idrac_license_version: 9) opts = { "BootMode" => 'Uefi' } # If we're iDRAC 9, we need enable a placeholder, otherwise we can't order the # boot order until we've switched to UEFI mode. # Read [about it](https://dl.dell.com/manuals/all-products/esuprt_software/esuprt_it_ops_datcentr_mgmt/dell-management-solution-resources_white-papers12_en-us.pdf). # ...administrators may wish to reserve a boot entry for a fixed disk in the UEFI Boot Sequence before an OS is installed or before a physical or # virtual drive has been formatted. When a HardDisk Drive Placeholder is set to Enabled, the BIOS will create a boot option for the PERC RAID # (Integrated or in a PCIe slot) disk if a partition is found, even if there is no FAT filesystem present... this allows the Integrated RAID controller # to be moved in the UEFI Boot Sequence prior to the OS installation opts["HddPlaceholder"] = "Enabled" if idrac_license_version.to_i == 9 self.make_scp(fqdd: "BIOS.Setup.1-1", attributes: opts) end |
#set_bios(hash) ⇒ Object
What triggers a reboot? infohub.delltechnologies.com/en-US/l/server-configuration-profiles-reference-guide/host-reboot-2/
360 361 362 363 364 365 366 367 |
# File 'lib/idrac/boot.rb', line 360 def set_bios(hash) scp = self.make_scp(fqdd: "BIOS.Setup.1-1", attributes: hash) res = self.set_system_configuration_profile(scp) if res[:status] == :success self. end res end |
#set_bios_ignore_errors(value = true) ⇒ Object
Configure BIOS to ignore boot errors
544 545 546 547 548 |
# File 'lib/idrac/boot.rb', line 544 def set_bios_ignore_errors(value = true) configure_bios_settings({ "ErrPrompt": value ? "Disabled" : "Enabled" }) end |
#set_bios_os_power_control ⇒ Object
Configure BIOS to optimize for OS power management
532 533 534 535 536 537 538 539 540 541 |
# File 'lib/idrac/boot.rb', line 532 def set_bios_os_power_control settings = { "ProcCStates": "Enabled", # Processor C-States "SysProfile": "PerfPerWattOptimizedOs", "ProcPwrPerf": "OsDbpm", # OS Power Management "PcieAspmL1": "Enabled" # PCIe Active State Power Management } configure_bios_settings(settings) end |
#set_boot_order(devices) ⇒ Object
Set the permanent boot order
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/idrac/boot.rb', line 206 def set_boot_order(devices) debug "Setting boot order...", 1, :yellow body = { "Boot" => { "BootOrder" => devices } } response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1", body: body.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "Boot order set successfully.", 1, :green return true else raise Error, "Failed to set boot order: #{response.status} - #{response.body}" end end |
#set_boot_order_hd_first ⇒ Object
Set boot order (HD first)
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/idrac/boot.rb', line 370 def set_boot_order_hd_first # First ensure we're in UEFI mode ensure_uefi_boot # Get available boot options = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/BootOptions?$expand=*($levels=1)") if .status == 200 begin data = JSON.parse(.body) puts "Available boot options:" data["Members"].each { |m| puts "\t#{m['DisplayName']} -> #{m['Id']}" } # Find RAID controller or HD device = data["Members"].find { |m| m["DisplayName"] =~ /RAID Controller/ } # Sometimes it's named differently device ||= data["Members"].find { |m| m["DisplayName"] =~ /ubuntu/i } device ||= data["Members"].find { |m| m["DisplayName"] =~ /UEFI Hard Drive/i } device ||= data["Members"].find { |m| m["DisplayName"] =~ /Hard Drive/i } if device.nil? raise Error, "No bootable hard drive or RAID controller found in boot options" end boot_id = device["Id"] # Set boot order response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1", body: { "Boot": { "BootOrder": [boot_id] } }.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) puts "Boot order set to HD first".green return true else = "Failed to set boot order. Status code: #{response.status}" begin error_data = JSON.parse(response.body) if error_data["error"] && error_data["error"]["@Message.ExtendedInfo"] error_info = error_data["error"]["@Message.ExtendedInfo"].first += ", Message: #{error_info['Message']}" end rescue # Ignore JSON parsing errors end raise Error, end rescue JSON::ParserError raise Error, "Failed to parse boot options response: #{response.body}" end else raise Error, "Failed to get boot options. Status code: #{.status}" end end |
#set_boot_override(target, enabled: "Once", mode: nil) ⇒ Object
Set boot override for next boot
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/idrac/boot.rb', line 143 def set_boot_override(target, enabled: "Once", mode: nil) # Validate target against allowed values boot_data = boot valid_targets = boot_data["allowed_override_targets"] if valid_targets && !valid_targets.include?(target) debug "Invalid boot target '#{target}'. Allowed values: #{valid_targets.join(', ')}", 1, :red raise Error, "Invalid boot target: #{target}" end debug "Setting boot override to #{target} (#{enabled})...", 1, :yellow body = { "Boot" => { "BootSourceOverrideEnabled" => enabled, # Disabled/Once/Continuous "BootSourceOverrideTarget" => target # None/Pxe/Hdd/Cd/etc } } # Add boot mode if specified body["Boot"]["BootSourceOverrideMode"] = mode if mode response = authenticated_request( :patch, "/redfish/v1/Systems/System.Embedded.1", body: body.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "Boot override set successfully.", 1, :green return true else raise Error, "Failed to set boot override: #{response.status} - #{response.body}" end end |
#set_uefi_boot_cd_once_then_hd ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/idrac/boot.rb', line 431 def set_uefi_boot_cd_once_then_hd = [:boot_options] # Note may have to put device into # self.set_bios( { "BootMode" => 'Uefi' } ) # self.reboot! # And then reboot before you can make the following call: raid_name = .include?("RAID.Integrated.1-1") ? "RAID.Integrated.1-1" : "Unknown.Unknown.1-1" raise "No RAID HD in boot options" unless .include?(raid_name) bios = { "BootMode" => 'Uefi', "BootSeqRetry" => "Disabled", # "UefiTargetBootSourceOverride" => 'Cd', # "BootSourceOverrideTarget" => 'UefiTarget', # "OneTimeBootMode" => "OneTimeUefiBootSeq", # One time boot order # "OneTimeHddSeqDev" => "Optical.iDRACVirtual.1-1", # "OneTimeBiosBootSeqDev" => "Optical.iDRACVirtual.1-1", # "OneTimeUefiBootSeqDev" => "Optical.iDRACVirtual.1-1", # Enabled/Disabled Options # "SetBootOrderDis" => "Disk.USBBack.1-1", # Don't boot to USB if it is plugged in "SetBootOrderEn" => raid_name, # "SetBootOrderFqdd1" => raid_name, # "SetLegacyHddOrderFqdd1" => raid_name, # "SetBootOrderFqdd2" => "Optical.iDRACVirtual.1-1", # Permanent Boot Order "HddSeq" => raid_name, "BiosBootSeq" => raid_name, "UefiBootSeq" => raid_name # This is likely redundant... } # The usb device will have 'usb' in it: usb_name = .select { |b| b =~ /usb/i } bios["SetBootOrderDis"] = usb_name if usb_name.present? set_bios(bios) end |