module Rancher::Api::Helpers::Model
Constants
- TIMEOUT_LIMIT
Public Instance Methods
handle_response(response)
click to toggle source
# File lib/rancher/api/helpers/model.rb, line 29 def handle_response(response) case response when Her::Collection response when Her::Model raise RancherModelError, response.inspect if response.type.eql?('error') response else raise RancherModelError, response.inspect end end
reload()
click to toggle source
# File lib/rancher/api/helpers/model.rb, line 19 def reload assign_attributes(self.class.find(id).attributes) end
run(action, data: {})
click to toggle source
# File lib/rancher/api/helpers/model.rb, line 23 def run(action, data: {}) url = actions[action.to_s] raise RancherActionNotAvailableError, "Available actions: '#{actions.inspect}'" if url.blank? handle_response(self.class.post(url, data)) end
self_url()
click to toggle source
# File lib/rancher/api/helpers/model.rb, line 15 def self_url links['self'] end
wait_for_state(desired_state)
click to toggle source
# File lib/rancher/api/helpers/model.rb, line 41 def wait_for_state(desired_state) EM.run do EM.add_timer(TIMEOUT_LIMIT) do raise RancherWaitTimeOutError, "Timeout while waiting for transition to: #{desired_state}" end EM.tick_loop do reload current_state = state if current_state.eql?(desired_state.to_s) Logger.log.info "state changed from: #{current_state} => #{desired_state}" EM.stop else Logger.log.info "waiting for state change: #{current_state} => #{desired_state}" sleep(1) end end end end