ilo-sdk 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ilo-sdk/helpers/log_entry_helper.rb +29 -17
- data/lib/ilo-sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7d69fdc25188262aeac98e737390e8816483736
|
4
|
+
data.tar.gz: 6d4ee8248719197181c07065d57c5dfecd21beb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20cecf33036d39ec7d1cb2c580c9925b08fc378b988cebb2b67b6388dcb795c3f76cf12c653d995062392ec48ef973a864a5e1216594dd2ec05fc5d0fcdfe44d
|
7
|
+
data.tar.gz: fd390be798147aac7992bb2b3a992aaca7f2febd49241d29a476134ea0282f63f51fc7f04d2edf5cd40dd34ce99034a95e190aa8852506b621009b213820ee08
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# (
|
1
|
+
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
#
|
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(
|
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("
|
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
|
55
|
+
# @return [Array] log entries
|
41
56
|
def get_logs(severity_level, duration, log_type)
|
42
|
-
response = rest_get("
|
57
|
+
response = rest_get("#{uri_for_log_type(log_type)}Entries/")
|
43
58
|
entries = response_handler(response)['Items']
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
data/lib/ilo-sdk/version.rb
CHANGED
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.
|
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
|
14
|
+
date: 2016-09-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|