Module: Supermicro::Bios
- Included in:
- Client
- Defined in:
- lib/supermicro/bios.rb
Instance Method Summary collapse
-
#bios_attributes ⇒ Object
Get BIOS attributes (public method for adapter compatibility).
-
#bios_error_prompt_disabled? ⇒ Boolean
Check if BIOS error prompt is disabled Supermicro equivalent: WaitFor_F1_IfError should be “Disabled”.
-
#bios_hdd_placeholder_enabled? ⇒ Boolean
Check if HDD placeholder is enabled Supermicro doesn’t have a direct equivalent to Dell’s HddPlaceholder This is a no-op that returns true for compatibility.
-
#bios_os_power_control_enabled? ⇒ Boolean
Check if OS power control is enabled Supermicro equivalent: Check power management settings PowerPerformanceTuning should be “OS Controls EPB” for OS control.
-
#ensure_sensible_bios!(options = {}) ⇒ Object
Ensure sensible BIOS settings (Supermicro version).
-
#ensure_uefi_boot ⇒ Object
Ensure UEFI boot mode.
- #pending_bios_settings ⇒ Object
- #reset_bios_defaults ⇒ Object
-
#set_bios_attribute(attribute_name, value) ⇒ Object
Set individual BIOS attribute.
-
#set_bios_error_prompt(disabled: true) ⇒ Object
Set BIOS error prompt behavior.
-
#set_bios_os_power_control(enabled: true) ⇒ Object
Set OS power control.
Instance Method Details
#bios_attributes ⇒ Object
Get BIOS attributes (public method for adapter compatibility)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/supermicro/bios.rb', line 8 def bios_attributes response = authenticated_request(:get, "/redfish/v1/Systems/1/Bios") if response.status == 200 begin data = JSON.parse(response.body) { "attributes" => data["Attributes"], "attribute_registry" => data["AttributeRegistry"] } rescue JSON::ParserError raise Error, "Failed to parse BIOS attributes response: #{response.body}" end else raise Error, "Failed to get BIOS attributes. Status code: #{response.status}" end end |
#bios_error_prompt_disabled? ⇒ Boolean
Check if BIOS error prompt is disabled Supermicro equivalent: WaitFor_F1_IfError should be “Disabled”
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/supermicro/bios.rb', line 38 def bios_error_prompt_disabled? attrs = get_bios_attributes if attrs.has_key?("WaitFor_F1_IfError") return attrs["WaitFor_F1_IfError"] == "Disabled" else debug "WaitFor_F1_IfError attribute not found in BIOS settings", 1, :yellow return false end end |
#bios_hdd_placeholder_enabled? ⇒ Boolean
Check if HDD placeholder is enabled Supermicro doesn’t have a direct equivalent to Dell’s HddPlaceholder This is a no-op that returns true for compatibility
52 53 54 55 56 |
# File 'lib/supermicro/bios.rb', line 52 def bios_hdd_placeholder_enabled? # Supermicro automatically handles boot device placeholders # No explicit setting needed true end |
#bios_os_power_control_enabled? ⇒ Boolean
Check if OS power control is enabled Supermicro equivalent: Check power management settings PowerPerformanceTuning should be “OS Controls EPB” for OS control
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/supermicro/bios.rb', line 61 def bios_os_power_control_enabled? attrs = get_bios_attributes # Check if OS is controlling power management if attrs.has_key?("PowerPerformanceTuning") return attrs["PowerPerformanceTuning"] == "OS Controls EPB" else # If the setting doesn't exist, assume it's not configured debug "PowerPerformanceTuning attribute not found in BIOS settings", 1, :yellow return false end end |
#ensure_sensible_bios!(options = {}) ⇒ Object
Ensure sensible BIOS settings (Supermicro version)
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/supermicro/bios.rb', line 166 def ensure_sensible_bios!( = {}) # Check current state if bios_error_prompt_disabled? && bios_os_power_control_enabled? debug "BIOS settings already configured correctly", 1, :green return { changes_made: false } end debug "Configuring BIOS settings...", 1, :yellow # Build the attributes to change attributes = {} # Check and prepare error prompt change if !bios_error_prompt_disabled? debug "Will disable BIOS error prompt (F1 wait)", 1, :yellow attributes["WaitFor_F1_IfError"] = "Disabled" end # Check and prepare OS power control change if !bios_os_power_control_enabled? debug "Will enable OS power control", 1, :yellow attributes["PowerPerformanceTuning"] = "OS Controls EPB" end # Ensure UEFI boot mode attributes["BootModeSelect"] = "UEFI" # Apply all changes at once payload = { "Attributes" => attributes } response = authenticated_request( :patch, "/redfish/v1/Systems/1/Bios/SD", body: payload.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "BIOS settings configured successfully", 1, :green # Check if a reboot job was created if response.headers['Location'] debug "BIOS change job created: #{response.headers['Location']}", 1, :yellow end return { changes_made: true } else debug "Failed to apply BIOS settings. Status: #{response.status}", 0, :red debug "Response: #{response.body}", 2, :red return { changes_made: false, error: "Failed to apply BIOS settings" } end end |
#ensure_uefi_boot ⇒ Object
Ensure UEFI boot mode
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/supermicro/bios.rb', line 127 def ensure_uefi_boot attrs = get_bios_attributes # Check current boot mode current_mode = attrs["BootModeSelect"] if current_mode == "UEFI" debug "System is already in UEFI boot mode", 1, :green return true else debug "System is not in UEFI boot mode (current: #{current_mode}). Setting to UEFI...", 1, :yellow # Set UEFI boot mode payload = { "Attributes" => { "BootModeSelect" => "UEFI" } } response = authenticated_request( :patch, "/redfish/v1/Systems/1/Bios/SD", body: payload.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "UEFI boot mode configured successfully", 1, :green debug "Note: A reboot is required for the change to take effect", 1, :yellow return true else debug "Failed to set UEFI boot mode. Status: #{response.status}", 0, :red debug "Response: #{response.body}", 2, :red return false end end end |
#pending_bios_settings ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/supermicro/bios.rb', line 244 def pending_bios_settings response = authenticated_request(:get, "/redfish/v1/Systems/1/Bios/SD") if response.status == 200 begin data = JSON.parse(response.body) data["Attributes"] || {} rescue JSON::ParserError raise Error, "Failed to parse pending BIOS settings response: #{response.body}" end else {} end end |
#reset_bios_defaults ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/supermicro/bios.rb', line 259 def reset_bios_defaults debug "Resetting BIOS to defaults...", 1, :yellow response = authenticated_request( :post, "/redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios", body: {}.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "BIOS reset to defaults successfully. Changes will be applied on next reboot.", 1, :green return true else raise Error, "Failed to reset BIOS: #{response.status} - #{response.body}" end end |
#set_bios_attribute(attribute_name, value) ⇒ Object
Set individual BIOS attribute
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/supermicro/bios.rb', line 220 def set_bios_attribute(attribute_name, value) debug "Setting BIOS attribute #{attribute_name} to #{value}...", 1, :yellow body = { "Attributes" => { attribute_name => value } } response = authenticated_request( :patch, "/redfish/v1/Systems/1/Bios/SD", body: body.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "BIOS attribute set successfully. Changes will be applied on next reboot.", 1, :green return true else raise Error, "Failed to set BIOS attribute: #{response.status} - #{response.body}" end end |
#set_bios_error_prompt(disabled: true) ⇒ Object
Set BIOS error prompt behavior
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/supermicro/bios.rb', line 75 def set_bios_error_prompt(disabled: true) value = disabled ? "Disabled" : "Enabled" payload = { "Attributes" => { "WaitFor_F1_IfError" => value } } response = authenticated_request( :patch, "/redfish/v1/Systems/1/Bios/SD", body: payload.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "BIOS error prompt #{disabled ? 'disabled' : 'enabled'} successfully", 1, :green true else debug "Failed to set BIOS error prompt. Status: #{response.status}", 0, :red false end end |
#set_bios_os_power_control(enabled: true) ⇒ Object
Set OS power control
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/supermicro/bios.rb', line 101 def set_bios_os_power_control(enabled: true) value = enabled ? "OS Controls EPB" : "BIOS Controls EPB" payload = { "Attributes" => { "PowerPerformanceTuning" => value } } response = authenticated_request( :patch, "/redfish/v1/Systems/1/Bios/SD", body: payload.to_json, headers: { 'Content-Type': 'application/json' } ) if response.status.between?(200, 299) debug "OS power control #{enabled ? 'enabled' : 'disabled'} successfully", 1, :green true else debug "Failed to set OS power control. Status: #{response.status}", 0, :red false end end |