Class: ILO_SDK::Client

Overview

The client defines the connection to the iLO and handles communication with it

Constant Summary

Constants included from Rest

Rest::RESPONSE_CODE_ACCEPTED, Rest::RESPONSE_CODE_BAD_REQUEST, Rest::RESPONSE_CODE_CREATED, Rest::RESPONSE_CODE_NOT_FOUND, Rest::RESPONSE_CODE_NO_CONTENT, Rest::RESPONSE_CODE_OK, Rest::RESPONSE_CODE_UNAUTHORIZED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HttpsCertHelper

#generate_csr, #get_certificate, #get_csr, #import_certificate

Methods included from ServiceRootHelper

#get_registry, #get_schema

Methods included from ChassisHelper

#get_power_metrics, #get_thermal_metrics

Methods included from ComputerSystemHelper

#get_asset_tag, #get_indicator_led, #get_system_settings, #set_asset_tag, #set_indicator_led, #set_system_settings

Methods included from VirtualMediaHelper

#eject_virtual_media, #get_virtual_media, #insert_virtual_media, #virtual_media_inserted?

Methods included from FirmwareUpdateHelper

#get_fw_version, #set_fw_upgrade

Methods included from BootSettingsHelper

#get_boot_baseconfig, #get_boot_order, #get_temporary_boot_order, #revert_boot, #set_boot_order, #set_temporary_boot_order

Methods included from BiosHelper

#get_bios_baseconfig, #get_bios_dhcp, #get_bios_service, #get_bios_settings, #get_uefi_shell_startup, #get_url_boot_file, #revert_bios, #set_bios_dhcp, #set_bios_service, #set_bios_settings, #set_uefi_shell_startup, #set_url_boot_file

Methods included from SecureBootHelper

#get_uefi_secure_boot, #set_uefi_secure_boot

Methods included from ManagerAccountHelper

#get_account_privileges, #set_account_privileges

Methods included from LogEntryHelper

#clear_logs, #get_logs, #logs_empty?

Methods included from AccountServiceHelper

#change_password, #create_user, #delete_user, #get_users, #userhref

Methods included from PowerHelper

#get_power_state, #reset_ilo, #set_power_state

Methods included from SNMPServiceHelper

#get_snmp_alerts_enabled, #get_snmp_mode, #set_snmp

Methods included from ComputerDetailsHelper

#get_array_controller_details, #get_computer_details, #get_computer_network_details, #get_general_computer_details

Methods included from DateTimeHelper

#get_ntp, #get_ntp_servers, #get_time_zone, #set_ntp, #set_ntp_servers, #set_time_zone

Methods included from ManagerNetworkProtocolHelper

#get_timeout, #set_timeout

Methods included from Rest

#response_handler, #rest_api, #rest_delete, #rest_get, #rest_patch, #rest_post, #rest_put

Constructor Details

#initialize(options = {}) ⇒ Client

Create a client object

Parameters:

  • options (Hash) (defaults to: {})

    the options to configure the client

Options Hash (options):

  • :host (String) — default: ENV['ILO_HOST']

    URL, hostname, or IP address of the iLO

  • :user (String) — default: 'Administrator'

    Username to use for authentication with the iLO

  • :password (String)

    Password to use for authentication with the iLO

  • :logger (Logger) — default: Logger.new(STDOUT)

    Logger object to use. Must implement debug(String), info(String), warn(String), error(String), & level=

  • :log_level (Symbol) — default: :info

    Log level. Logger must define a constant with this name. ie Logger::INFO

  • :ssl_enabled (Boolean) — default: true

    Use ssl for requests?

  • :disable_proxy (Boolean) — default: false

    Disable usage of a proxy for requests?

Raises:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ilo-sdk/client.rb', line 32

def initialize(options = {})
  options = Hash[options.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols
  @logger = options[:logger] || Logger.new(STDOUT)
  [:debug, :info, :warn, :error, :level=].each { |m| raise "Logger must respond to #{m} method " unless @logger.respond_to?(m) }
  @log_level = options[:log_level] || :info
  @logger.level = @logger.class.const_get(@log_level.upcase) rescue @log_level
  @host = options[:host] || ENV['ILO_HOST']
  raise InvalidClient, 'Must set the host option' unless @host
  @host = 'https://' + @host unless @host.start_with?('http://', 'https://')
  @ssl_enabled = true # Default
  if ENV.key?('ILO_SSL_ENABLED')
    @ssl_enabled = case ENV['ILO_SSL_ENABLED']
                   when 'true', '1' then true
                   when 'false', '0' then false
                   else ENV['ILO_SSL_ENABLED']
                   end
  end
  @ssl_enabled = options[:ssl_enabled] unless options[:ssl_enabled].nil?
  unless [true, false].include?(@ssl_enabled)
    raise InvalidClient, "ssl_enabled option must be true or false. Got '#{@ssl_enabled}'"
  end
  unless @ssl_enabled
    @logger.warn "SSL is disabled for all requests to #{@host}! We recommend you import the necessary certificates instead. of disabling SSL"
  end
  @disable_proxy = options[:disable_proxy]
  raise InvalidClient, 'disable_proxy option must be true, false, or nil' unless [true, false, nil].include?(@disable_proxy)
  @logger.warn 'User option not set. Using default (Administrator)' unless options[:user] || ENV['ILO_USER']
  @user = options[:user] || ENV['ILO_USER'] || 'Administrator'
  @password = options[:password] || ENV['ILO_PASSWORD']
  raise InvalidClient, 'Must set the password option' unless @password
end

Instance Attribute Details

#disable_proxyObject

Returns the value of attribute disable_proxy.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def disable_proxy
  @disable_proxy
end

#hostObject

Returns the value of attribute host.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def host
  @host
end

#log_levelObject

Returns the value of attribute log_level.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def log_level
  @log_level
end

#loggerObject

Returns the value of attribute logger.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def password
  @password
end

#ssl_enabledObject

Returns the value of attribute ssl_enabled.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def ssl_enabled
  @ssl_enabled
end

#userObject

Returns the value of attribute user.



20
21
22
# File 'lib/ilo-sdk/client.rb', line 20

def user
  @user
end