Module: ILO_SDK::LogEntryHelper
- Included in:
- Client
- Defined in:
- lib/ilo-sdk/helpers/log_entry_helper.rb
Overview
Contains helper methods for Log Entry actions
Instance Method Summary collapse
-
#clear_logs(log_type) ⇒ Object
Clear the specified logs.
-
#get_logs(severity_level, duration, log_type) ⇒ Array
Get the specified logs.
-
#logs_empty?(log_type) ⇒ TrueClass, FalseClass
Check to see if the specified logs are empty.
-
#uri_for_log_type(log_type, id = 1) ⇒ String
Get the URI for the specified log type.
Instance Method Details
#clear_logs(log_type) ⇒ Object
Clear the specified logs
34 35 36 37 38 39 |
# File 'lib/ilo-sdk/helpers/log_entry_helper.rb', line 34 def clear_logs(log_type) new_action = { 'Action' => 'ClearLog' } response = rest_post(uri_for_log_type(log_type), body: new_action) response_handler(response) true end |
#get_logs(severity_level, duration, log_type) ⇒ Array
Get the specified logs
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ilo-sdk/helpers/log_entry_helper.rb', line 56 def get_logs(severity_level, duration, log_type) response = rest_get("#{uri_for_log_type(log_type)}Entries/") entries = response_handler(response)['Items'] start_time = Time.now.utc - (duration * 3600) if severity_level.nil? entries.select { |e| Time.parse(e['Created']) > start_time } else entries.select { |e| severity_level.to_s.casecmp(e['Severity']) == 0 && Time.parse(e['Created']) > start_time } end end |
#logs_empty?(log_type) ⇒ TrueClass, FalseClass
Check to see if the specified logs are empty
45 46 47 48 |
# File 'lib/ilo-sdk/helpers/log_entry_helper.rb', line 45 def logs_empty?(log_type) response = rest_get("#{uri_for_log_type(log_type)}Entries/") response_handler(response)['Items'].empty? end |
#uri_for_log_type(log_type, id = 1) ⇒ String
Get the URI for the specified log type
21 22 23 24 25 26 27 28 |
# File 'lib/ilo-sdk/helpers/log_entry_helper.rb', line 21 def uri_for_log_type(log_type, id = 1) resource = case log_type.to_s.upcase when 'IEL' then 'Managers' when 'IML' then 'Systems' else raise "Invalid log_type '#{log_type}'. Valid options are IEL and IML" end "/redfish/v1/#{resource}/#{id}/LogServices/#{log_type.upcase}/" end |