ilo-sdk 1.0.2 → 1.1.0

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: f946ce92905f62313a97dad4c6e1b2af423e6b76
4
- data.tar.gz: 759478851f155d9600c0758ebd01754f292d1f2c
3
+ metadata.gz: 39068db4621e387c98482d7dc545fd8cb7ccf503
4
+ data.tar.gz: a05c6dec3838c31dfd7a706940c9adfa4e9f9c65
5
5
  SHA512:
6
- metadata.gz: 3fb34bebfd27fee718dcecc8fb53a2130b243aae7df2e349c8b5ce738b66f8832b588f072af15cd4d8b7d987c827d9951552e38f68246208f99ae0038321b312
7
- data.tar.gz: 227ba06dbc423e26104c39b413e88c18aa5a183c237b133a1140d25521b56d81fb90c19a2800b59b42787215d298efa44f48835d7d437a12bc2886020194872b
6
+ metadata.gz: 8d3e5c1ddc3d61d76d30dd920abc50c9c4f587e1b30c0671a6d3c68f84c5b5ac4dfb94aebbeb9d9f0f7a3e4961ac0efece73a369a13952b0a7df2baa2e66681b
7
+ data.tar.gz: 358cb51d0ab7746d292e6cf40dc4c66381440838effffa6817da7b0ef5a4fe4698c506c88747cb00ea7507b5537890ed0a5577af6b43e7cbc8b52e17842ff47b
data/README.md CHANGED
@@ -254,6 +254,27 @@ duration = 10 # hours
254
254
  logs = client.get_log(severity_level, duration, log_type)
255
255
  ```
256
256
 
257
+ ### Manager Account
258
+ ```ruby
259
+ # Get the Account Privileges for a specific user:
260
+ username = 'Administrator'
261
+ client.get_account_privileges(username)
262
+
263
+ # Set the Login Privilege to true for a specific user:
264
+ client.set_account_privileges(username, LoginPriv: true)
265
+
266
+ # Set all of the Account Privileges for a specific user:
267
+ privileges = {
268
+ 'LoginPriv' => true,
269
+ 'RemoteConsolePriv' => true,
270
+ 'UserConfigPriv' => true,
271
+ 'VirtualMediaPriv' => true,
272
+ 'VirtualPowerAndResetPriv' => true,
273
+ 'iLOConfigPriv' => true
274
+ }
275
+ client.set_account_privileges(username, privileges)
276
+ ```
277
+
257
278
  #### Manager Network Protocol
258
279
  ```ruby
259
280
  # Get the minutes until session timeout:
@@ -55,6 +55,7 @@ module ILO_SDK
55
55
  include PowerHelper
56
56
  include AccountServiceHelper
57
57
  include LogEntryHelper
58
+ include ManagerAccountHelper
58
59
  include SecureBootHelper
59
60
  include BiosHelper
60
61
  include BootSettingsHelper
@@ -32,7 +32,7 @@ module ILO_SDK
32
32
 
33
33
  # Get the UEFI shell start up
34
34
  # @raise [RuntimeError] if the request failed
35
- # @return [String] uefi_shell_startup
35
+ # @return [Hash] uefi_shell_startup
36
36
  def get_uefi_shell_startup
37
37
  response = rest_get('/redfish/v1/Systems/1/bios/Settings/')
38
38
  bios = response_handler(response)
@@ -0,0 +1,62 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ # specific language governing permissions and limitations under the License.
11
+
12
+ module ILO_SDK
13
+ # Contains helper methods for Manager Account actions
14
+ module ManagerAccountHelper
15
+ # Get the Privileges for a user
16
+ # @param [String, Symbol] username
17
+ # @raise [RuntimeError] if the request failed
18
+ # @return [Hash] privileges
19
+ def get_account_privileges(username)
20
+ response = rest_get('/redfish/v1/AccountService/Accounts/')
21
+ accounts = response_handler(response)['Items']
22
+ accounts.each do |account|
23
+ if account['Oem']['Hp']['LoginName'] == username
24
+ return account['Oem']['Hp']['Privileges']
25
+ end
26
+ end
27
+ end
28
+
29
+ # Set the privileges for a user
30
+ # @param [TrueClass, FalseClass] username
31
+ # @param [Hash] privileges
32
+ # @option privileges [TrueClass, FalseClass] :LoginPriv
33
+ # @option privileges [TrueClass, FalseClass] :RemoteConsolePriv
34
+ # @option privileges [TrueClass, FalseClass] :UserConfigPriv
35
+ # @option privileges [TrueClass, FalseClass] :VirtualMediaPriv
36
+ # @option privileges [TrueClass, FalseClass] :VirtualPowerAndResetPriv
37
+ # @option privileges [TrueClass, FalseClass] :iLOConfigPriv
38
+ # @raise [RuntimeError] if the request failed
39
+ # @return true
40
+ def set_account_privileges(username, privileges)
41
+ response = rest_get('/redfish/v1/AccountService/Accounts/')
42
+ accounts = response_handler(response)['Items']
43
+ id = '0'
44
+ accounts.each do |account|
45
+ if account['Oem']['Hp']['LoginName'] == username
46
+ id = account['Id']
47
+ break
48
+ end
49
+ end
50
+ new_action = {
51
+ 'Oem' => {
52
+ 'Hp' => {
53
+ 'Privileges' => privileges
54
+ }
55
+ }
56
+ }
57
+ response = rest_patch("/redfish/v1/AccountService/Accounts/#{id}/", body: new_action)
58
+ response_handler(response)
59
+ true
60
+ end
61
+ end
62
+ end
@@ -11,5 +11,5 @@
11
11
 
12
12
  # Gem version defined here
13
13
  module ILO_SDK
14
- VERSION = '1.0.2'.freeze
14
+ VERSION = '1.1.0'.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.0.2
4
+ version: 1.1.0
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-07-29 00:00:00.000000000 Z
14
+ date: 2016-08-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: pry
@@ -128,6 +128,7 @@ files:
128
128
  - lib/ilo-sdk/helpers/firmware_update.rb
129
129
  - lib/ilo-sdk/helpers/https_cert_helper.rb
130
130
  - lib/ilo-sdk/helpers/log_entry_helper.rb
131
+ - lib/ilo-sdk/helpers/manager_account_helper.rb
131
132
  - lib/ilo-sdk/helpers/manager_network_protocol_helper.rb
132
133
  - lib/ilo-sdk/helpers/power_helper.rb
133
134
  - lib/ilo-sdk/helpers/secure_boot_helper.rb