ilo-sdk 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e3d66a47d72463a4564931c4c6764ccdcc9799f
4
- data.tar.gz: 872a83c910c87089bc9ec82318f2ca9eb43a14c5
3
+ metadata.gz: a7d69fdc25188262aeac98e737390e8816483736
4
+ data.tar.gz: 6d4ee8248719197181c07065d57c5dfecd21beb5
5
5
  SHA512:
6
- metadata.gz: 1a184e445883fdaa526d4511d5a84bbccfbbbfcb56fc3fe530b161f73e2b72c9faeca92d69dcbef638db95fae104bdd68b8107e7430147bdde6fcc4b1f7a7ca0
7
- data.tar.gz: 97689bb3dfb16e23afff23f3e232b7ad4df00cee038d4f3f241beff3986d71f078aab9bb6a57728ef6ac3056a52f035f3730431b6bc7420332cad218eb59935f
6
+ metadata.gz: 20cecf33036d39ec7d1cb2c580c9925b08fc378b988cebb2b67b6388dcb795c3f76cf12c653d995062392ec48ef973a864a5e1216594dd2ec05fc5d0fcdfe44d
7
+ data.tar.gz: fd390be798147aac7992bb2b3a992aaca7f2febd49241d29a476134ea0282f63f51fc7f04d2edf5cd40dd34ce99034a95e190aa8852506b621009b213820ee08
@@ -1,4 +1,8 @@
1
1
  ### New (Unreleased)
2
+ - (none)
3
+
4
+ #### v1.2.2
5
+ - Fixed log_entry helper methods
2
6
 
3
7
  #### v1.2.1
4
8
  - Added rest command to cli
@@ -1,7 +1,7 @@
1
- # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
1
+ # (c) Copyright 2016 Hewlett Packard Enterprise Development LP
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
- # You may not use this file except in compliance with the License.
4
+ # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  #
7
7
  # Unless required by applicable law or agreed to in writing, software distributed
@@ -9,16 +9,31 @@
9
9
  # CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
10
  # specific language governing permissions and limitations under the License.
11
11
 
12
+ require 'time'
13
+
12
14
  module ILO_SDK
13
15
  # Contains helper methods for Log Entry actions
14
16
  module LogEntryHelper
17
+ # Get the URI for the specified log type
18
+ # @param [String, Symbol] log_type
19
+ # @raise [RuntimeError] if type is invalid
20
+ # @return [String] URI of log service
21
+ def uri_for_log_type(log_type, id = 1)
22
+ resource = case log_type.to_s.upcase
23
+ when 'IEL' then 'Managers'
24
+ when 'IML' then 'Systems'
25
+ else raise "Invalid log_type '#{log_type}'. Valid options are IEL and IML"
26
+ end
27
+ "/redfish/v1/#{resource}/#{id}/LogServices/#{log_type.upcase}/"
28
+ end
29
+
15
30
  # Clear the specified logs
16
31
  # @param [String, Symbol] log_type
17
32
  # @raise [RuntimeError] if the request failed
18
33
  # @return true
19
34
  def clear_logs(log_type)
20
35
  new_action = { 'Action' => 'ClearLog' }
21
- response = rest_post("/redfish/v1/Managers/1/LogServices/#{log_type}/", body: new_action)
36
+ response = rest_post(uri_for_log_type(log_type), body: new_action)
22
37
  response_handler(response)
23
38
  true
24
39
  end
@@ -28,28 +43,25 @@ module ILO_SDK
28
43
  # @raise [RuntimeError] if the request failed
29
44
  # @return [TrueClass, FalseClass] logs_empty
30
45
  def logs_empty?(log_type)
31
- response = rest_get("/redfish/v1/Managers/1/LogServices/#{log_type}/Entries/")
46
+ response = rest_get("#{uri_for_log_type(log_type)}Entries/")
32
47
  response_handler(response)['Items'].empty?
33
48
  end
34
49
 
35
50
  # Get the specified logs
36
- # @param [String, Symbol] severity_level
37
- # @param [String, Symbol] duration
38
- # @param [String, Symbol] log_type
51
+ # @param [String, Symbol, NilClass] severity_level Set to nil to get all logs
52
+ # @param [String, Symbol] duration Up to this many hours ago
53
+ # @param [String, Symbol] log_type IEL or IML
39
54
  # @raise [RuntimeError] if the request failed
40
- # @return logs
55
+ # @return [Array] log entries
41
56
  def get_logs(severity_level, duration, log_type)
42
- response = rest_get("/redfish/v1/Managers/1/LogServices/#{log_type}/Entries/")
57
+ response = rest_get("#{uri_for_log_type(log_type)}Entries/")
43
58
  entries = response_handler(response)['Items']
44
- logs = []
45
- entries.each do |e|
46
- if severity_level.nil?
47
- logs.push("#{e['Severity']} | #{e['Message']} | #{e['Created']}") if Time.parse(e['Created']) > (Time.now.utc - (duration * 3600))
48
- elsif e['Severity'] == severity_level && Time.parse(e['Created']) > (Time.now.utc - (duration * 3600))
49
- logs.push("#{e['Severity']} | #{e['Message']} | #{e['Created']}")
50
- end
59
+ start_time = Time.now.utc - (duration * 3600)
60
+ if severity_level.nil?
61
+ entries.select { |e| Time.parse(e['Created']) > start_time }
62
+ else
63
+ entries.select { |e| severity_level.to_s.casecmp(e['Severity']) == 0 && Time.parse(e['Created']) > start_time }
51
64
  end
52
- logs
53
65
  end
54
66
  end
55
67
  end
@@ -11,5 +11,5 @@
11
11
 
12
12
  # Gem version defined here
13
13
  module ILO_SDK
14
- VERSION = '1.2.1'.freeze
14
+ VERSION = '1.2.2'.freeze
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilo-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anirudh Gupta
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-08-31 00:00:00.000000000 Z
14
+ date: 2016-09-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor