Class: VagrantPlugins::SimpleCloud::Helpers::SimpleClient
- Inherits:
-
DropletKit::Client
- Object
- DropletKit::Client
- VagrantPlugins::SimpleCloud::Helpers::SimpleClient
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-simplecloud/helpers/client.rb
Instance Method Summary collapse
Instance Method Details
#post(path, params = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-simplecloud/helpers/client.rb', line 23 def post(path, params = {}) uri = URI.parse("#{[:url]}#{path}") https = Net::HTTP.new(uri.host,uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.path) req['Content-Type'] = [:headers][:content_type] req['Authorization'] = [:headers][:authorization] req.set_form_data(params) res = https.request(req) unless /^2\d\d$/ =~ res.code.to_s raise "Server response error #{res.code} #{path} #{params} #{res.} #{res.body}" end JSON.parse(res.body) end |
#wait_for_event(env, id) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vagrant-simplecloud/helpers/client.rb', line 38 def wait_for_event(env, id) retryable(:tries => 120, :sleep => 10) do # stop waiting if interrupted next if env[:interrupted] # check action status result = self.actions.find(id: id) yield result if block_given? raise 'not ready' if result.status != 'completed' end end |