module ILO_SDK::AccountServiceHelper

Contains helper methods for Account Service actions

Public Instance Methods

change_password(username, password) click to toggle source

Change the password for a user @param [String, Symbol] username @param [String, Symbol] password @raise [RuntimeError] if the request failed @return true

# File lib/ilo-sdk/helpers/account_service_helper.rb, line 53
def change_password(username, password)
  new_action = { 'Password' => password }
  userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
  response = rest_patch(userhref, body: new_action)
  response_handler(response)
  true
end
create_user(username, password) click to toggle source

Create a user @param [String, Symbol] username @param [String, Symbol] password @raise [RuntimeError] if the request failed @return true

# File lib/ilo-sdk/helpers/account_service_helper.rb, line 41
def create_user(username, password)
  new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } }
  response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action)
  response_handler(response)
  true
end
delete_user(username) click to toggle source

Delete a specific user @param [String, Symbol] username @raise [RuntimeError] if the request failed @return true

# File lib/ilo-sdk/helpers/account_service_helper.rb, line 65
def delete_user(username)
  userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
  response = rest_delete(userhref)
  response_handler(response)
  true
end
get_users() click to toggle source

Get the users @raise [RuntimeError] if the request failed @return [String users

# File lib/ilo-sdk/helpers/account_service_helper.rb, line 31
def get_users
  response = rest_get('/redfish/v1/AccountService/Accounts/')
  response_handler(response)['Items'].collect { |user| user['UserName'] }
end
userhref(uri, username) click to toggle source

Get the HREF for a user with a specific username @param [String, Symbol] uri @param [String, Symbol] username @raise [RuntimeError] if the request failed @return [String] userhref

# File lib/ilo-sdk/helpers/account_service_helper.rb, line 20
def userhref(uri, username)
  response = rest_get(uri)
  items = response_handler(response)['Items']
  items.each do |it|
    return it['links']['self']['href'] if it['UserName'] == username
  end
end