Class: Collins::Client
- Inherits:
-
Object
- Object
- Collins::Client
- Defined in:
- lib/collins/client.rb
Overview
Primary interface for interacting with collins
Constant Summary
Constants included from Util::Logging
Util::Logging::DEFAULT_LOG_FORMAT
Instance Attribute Summary collapse
- #headers ⇒ Object readonly
- #host ⇒ Object readonly
- #locations ⇒ Object readonly
- #logger ⇒ Object readonly
- #password ⇒ Object readonly
-
#strict ⇒ Boolean
readonly
Strict mode throws exceptions when unexpected responses occur.
- #timeout_i ⇒ Object readonly
- #username ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Create a collins client instance.
-
#manage_process(name = nil) ⇒ Collins::ManagedState::Mixin
Interact with a collins managed process.
- #strict?(default = false) ⇒ Boolean
-
#to_s ⇒ String
Collins::Client(host = hostname).
-
#with_asset(asset) ⇒ Collins::AssetClient
Use the specified asset for subsequent method calls.
Methods included from Util
#deep_copy_hash, #get_asset_or_tag, included, #require_non_empty, #require_that, #stringify_hash, #symbolize_hash
Methods included from Util::Logging
Methods included from Api
#clear_headers, #set_header, #trace, #use_api_version
Methods included from Api::Util
Methods included from Api::Tag
#get_all_tags, #get_tag_values
Methods included from Api::Management
#ipmi_allocate, #ipmi_create, #ipmi_update, #power!, #power_status, #provision, #provisioning_profiles
Methods included from Api::Logging
#all_logs, #get_log, #log!, #logs, #search_logs
Methods included from Api::Ipmi
Methods included from Api::IpAddress
#addresses_for_asset, #asset_at_address, #assets_in_pool, #ipaddress_allocate!, #ipaddress_delete!, #ipaddress_pools, #ipaddress_update!
Methods included from Api::Attributes
#delete_attribute!, #set_attribute!, #set_multi_attribute!, #set_status!
Methods included from Api::AssetType
#asset_type_create!, #asset_type_delete!, #asset_type_get, #asset_type_get_all, asset_type_test, asset_type_test=, #asset_type_update!
Methods included from Api::AssetState
#state_create!, #state_delete!, #state_get, #state_get_all, state_test, state_test=, #state_update!
Methods included from Api::Asset
#count, #create!, #delete!, #exists?, #find, #find_similar, #get, #search
Methods included from Api::Admin
Constructor Details
#initialize(options = {}) ⇒ Client
Create a collins client instance
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/collins/client.rb', line 44 def initialize = {} config = symbolize_hash @locations = {} @headers = {} @host = fix_hostname(config.fetch(:host, "")) @logger = get_logger config.merge(:progname => 'Collins_Client') @timeout_i = config.fetch(:timeout, 10).to_i @username = config.fetch(:username, "") @password = config.fetch(:password, "") @strict = config.fetch(:strict, false) @managed_process = config.fetch(:managed_process, nil) require_non_empty(@host, "Collins::Client host must be specified") require_non_empty(@username, "Collins::Client username must be specified") require_non_empty(@password, "Collins::Client password must be specified") end |
Instance Attribute Details
#headers ⇒ Object (readonly)
15 16 17 |
# File 'lib/collins/client.rb', line 15 def headers @headers end |
#host ⇒ Object (readonly)
17 18 19 |
# File 'lib/collins/client.rb', line 17 def host @host end |
#locations ⇒ Object (readonly)
19 20 21 |
# File 'lib/collins/client.rb', line 19 def locations @locations end |
#logger ⇒ Object (readonly)
21 22 23 |
# File 'lib/collins/client.rb', line 21 def logger @logger end |
#password ⇒ Object (readonly)
25 26 27 |
# File 'lib/collins/client.rb', line 25 def password @password end |
#strict ⇒ Boolean (readonly)
Returns strict mode throws exceptions when unexpected responses occur.
27 28 29 |
# File 'lib/collins/client.rb', line 27 def strict @strict end |
#timeout_i ⇒ Object (readonly)
23 24 25 |
# File 'lib/collins/client.rb', line 23 def timeout_i @timeout_i end |
#username ⇒ Object (readonly)
29 30 31 |
# File 'lib/collins/client.rb', line 29 def username @username end |
Instance Method Details
#manage_process(name = nil) ⇒ Collins::ManagedState::Mixin
Interact with a collins managed process
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/collins/client.rb', line 64 def manage_process name = nil name = @managed_process if name.nil? if name then begin Collins.const_get(name).new(self).run rescue Exception => e raise CollinsError.new(e.) end else raise CollinsError.new("No managed process specified") end end |
#strict?(default = false) ⇒ Boolean
83 84 85 |
# File 'lib/collins/client.rb', line 83 def strict? default = false @strict || default end |
#to_s ⇒ String
Returns Collins::Client(host = hostname).
78 79 80 |
# File 'lib/collins/client.rb', line 78 def to_s "Collins::Client(host = #{@host})" end |
#with_asset(asset) ⇒ Collins::AssetClient
Use the specified asset for subsequent method calls
90 91 92 |
# File 'lib/collins/client.rb', line 90 def with_asset asset Collins::AssetClient.new(asset, self, @logger) end |