Class: VagrantPlugins::Linode::Helpers::ApiClient
- Inherits:
-
Object
- Object
- VagrantPlugins::Linode::Helpers::ApiClient
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-linode/helpers/client.rb
Overview
end
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(machine) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #wait_for_event(env, id) ⇒ Object
Constructor Details
#initialize(machine) ⇒ ApiClient
Returns a new instance of ApiClient.
36 37 38 39 40 41 42 |
# File 'lib/vagrant-linode/helpers/client.rb', line 36 def initialize(machine) @logger = Log4r::Logger.new('vagrant::linode::apiclient') @config = machine.provider_config @client = ::LinodeAPI::Retryable.new(apikey: @config.api_key, endpoint: @config.api_url || nil, user_agent_prefix: "vagrant-linode/#{VagrantPlugins::Linode::VERSION}") end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
44 45 46 |
# File 'lib/vagrant-linode/helpers/client.rb', line 44 def client @client end |
Instance Method Details
#wait_for_event(env, id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vagrant-linode/helpers/client.rb', line 46 def wait_for_event(env, id) retryable(tries: 120, sleep: 10) do # stop waiting if interrupted next if env[:interrupted] # check action status result = @client.linode.job.list(jobid: id, linodeid: env[:machine].id) yield result if block_given? fail 'not ready' if result['host_finish_dt'] > '' end end |