Method: IDRAC::SystemConfig#set_system_configuration_profile

Defined in:
lib/idrac/system_config.rb

#set_system_configuration_profile(scp, target: "ALL", reboot: false, retry_count: 0) ⇒ Object

Apply a system configuration profile to the iDRAC



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/idrac/system_config.rb', line 239

def set_system_configuration_profile(scp, target: "ALL", reboot: false, retry_count: 0)
  # Ensure scp has the proper structure with SystemConfiguration wrapper
  scp_to_apply = if scp.is_a?(Hash) && scp["SystemConfiguration"]
    scp
  else
    # Ensure scp is an array of components
    components = scp.is_a?(Array) ? scp : [scp]
    { "SystemConfiguration" => { "Components" => components } }
  end

  # Create the import parameters
  params = { 
    "ImportBuffer" => JSON.pretty_generate(scp_to_apply),
    "ShareParameters" => {"Target" => target},
    "ShutdownType" => "Forced",
    "HostPowerState" => reboot ? "On" : "Off"
  }
  
  debug "Importing System Configuration...", 1, :blue
  debug "Configuration: #{JSON.pretty_generate(scp_to_apply)}", 3
  
  # Make the API request
  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"}
  )
  
  # Check for immediate errors
  if response.headers["content-length"].to_i > 0
    debug response.inspect, 1, :red
    return { status: :failed, error: "Failed importing SCP: #{response.body}" }
  end
  
  return handle_location(response.headers["location"])
end