Module: ILO_SDK::ManagerAccountHelper

Included in:
Client
Defined in:
lib/ilo-sdk/helpers/manager_account_helper.rb

Overview

Contains helper methods for Manager Account actions

Instance Method Summary collapse

Instance Method Details

#get_account_privileges(username) ⇒ Hash

Get the Privileges for a user

Parameters:

  • username (String, Symbol)

Returns:

  • (Hash)

    privileges

Raises:

  • (RuntimeError)

    if the request failed


19
20
21
22
23
24
25
26
27
# File 'lib/ilo-sdk/helpers/manager_account_helper.rb', line 19

def (username)
  response = rest_get('/redfish/v1/AccountService/Accounts/')
  accounts = response_handler(response)['Items']
  accounts.each do ||
    if ['Oem']['Hp']['LoginName'] == username
      return ['Oem']['Hp']['Privileges']
    end
  end
end

#set_account_privileges(username, privileges) ⇒ Object

Set the privileges for a user

Parameters:

  • username (TrueClass, FalseClass)
  • privileges (Hash)

Options Hash (privileges):

  • :LoginPriv (TrueClass, FalseClass)
  • :RemoteConsolePriv (TrueClass, FalseClass)
  • :UserConfigPriv (TrueClass, FalseClass)
  • :VirtualMediaPriv (TrueClass, FalseClass)
  • :VirtualPowerAndResetPriv (TrueClass, FalseClass)
  • :iLOConfigPriv (TrueClass, FalseClass)

Returns:

  • true

Raises:

  • (RuntimeError)

    if the request failed


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ilo-sdk/helpers/manager_account_helper.rb', line 40

def (username, privileges)
  response = rest_get('/redfish/v1/AccountService/Accounts/')
  accounts = response_handler(response)['Items']
  id = '0'
  accounts.each do ||
    if ['Oem']['Hp']['LoginName'] == username
      id = ['Id']
      break
    end
  end
  new_action = {
    'Oem' => {
      'Hp' => {
        'Privileges' => privileges
      }
    }
  }
  response = rest_patch("/redfish/v1/AccountService/Accounts/#{id}/", body: new_action)
  response_handler(response)
  true
end