Module: IDRAC::Utility
Instance Method Summary collapse
-
#reset! ⇒ Object
Reset the iDRAC controller (graceful restart).
Methods included from Debuggable
Instance Method Details
#reset! ⇒ Object
Reset the iDRAC controller (graceful restart)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 |
# File 'lib/idrac/utility.rb', line 6 def reset! debug "Resetting iDRAC controller...", 1 response = authenticated_request( :post, "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset", body: { "ResetType" => "GracefulRestart" }.to_json, headers: { 'Content-Type' => 'application/json' } ) if response.status.between?(200, 299) debug "Reset command accepted, waiting for iDRAC to restart...", 1, :green tries = 0 while true begin debug "Checking if iDRAC is back online...", 1 response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1") if response.status.between?(200, 299) debug "iDRAC is back online!", 1, :green break end sleep 30 rescue => e tries += 1 if tries > 5 debug "Failed to reconnect to iDRAC after 5 attempts", 1, :red return false end debug "No response from server... retry #{tries}/5", 1, :red sleep 2 ** tries end end else begin error_data = JSON.parse(response.body) if error_data["error"] && error_data["error"]["@Message.ExtendedInfo"] = error_data["error"]["@Message.ExtendedInfo"].first["Message"] debug "*" * 80, 1, :red debug , 1, :red debug "*" * 80, 1, :red else debug "Failed to reset iDRAC. Status code: #{response.status}", 1, :red end rescue => e debug "Failed to reset iDRAC. Status code: #{response.status}", 1, :red debug "Error response: #{response.body}", 2, :red end return false end true end |