Class: ILO_SDK::Client
- Inherits:
-
Object
- Object
- ILO_SDK::Client
- Includes:
- AccountServiceHelper, BiosHelper, BootSettingsHelper, ChassisHelper, ComputerDetailsHelper, ComputerSystemHelper, DateTimeHelper, FirmwareUpdateHelper, HttpsCertHelper, LogEntryHelper, ManagerAccountHelper, ManagerNetworkProtocolHelper, PowerHelper, Rest, SNMPServiceHelper, SecureBootHelper, ServiceRootHelper, VirtualMediaHelper
- Defined in:
- lib/ilo-sdk/client.rb
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
-
#disable_proxy ⇒ Object
Returns the value of attribute disable_proxy.
-
#host ⇒ Object
Returns the value of attribute host.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#password ⇒ Object
Returns the value of attribute password.
-
#ssl_enabled ⇒ Object
Returns the value of attribute ssl_enabled.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Create a client object.
Methods included from HttpsCertHelper
#generate_csr, #get_certificate, #get_csr, #import_certificate
Methods included from ServiceRootHelper
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
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
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( = {}) = Hash[.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols @logger = [: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 = [:log_level] || :info @logger.level = @logger.class.const_get(@log_level.upcase) rescue @log_level @host = [: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 = [:ssl_enabled] unless [: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 = [: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 [:user] || ENV['ILO_USER'] @user = [:user] || ENV['ILO_USER'] || 'Administrator' @password = [:password] || ENV['ILO_PASSWORD'] raise InvalidClient, 'Must set the password option' unless @password end |
Instance Attribute Details
#disable_proxy ⇒ Object
Returns the value of attribute disable_proxy.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def disable_proxy @disable_proxy end |
#host ⇒ Object
Returns the value of attribute host.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def host @host end |
#log_level ⇒ Object
Returns the value of attribute log_level.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def password @password end |
#ssl_enabled ⇒ Object
Returns the value of attribute ssl_enabled.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def ssl_enabled @ssl_enabled end |
#user ⇒ Object
Returns the value of attribute user.
20 21 22 |
# File 'lib/ilo-sdk/client.rb', line 20 def user @user end |