Sha256: 675a7c58c699145e5037643d92732d6542038bca453e9e36ef0667d86fc81858
Contents?: true
Size: 1.48 KB
Versions: 9
Compression:
Stored size: 1.48 KB
Contents
require 'timeout' require_relative 'busyable' module VagrantPlugins module Skytap module API module RunstateOperations include Busyable def run! set_runstate :running end def suspend! set_runstate :suspended end def stop! set_runstate :stopped end def poweroff! set_runstate :halted, completed_runstate: :stopped end def set_runstate(new_runstate, opts = {}) completed_runstate = opts.delete(:completed_runstate) || new_runstate params = {runstate: new_runstate}.tap do |ret| ret[:multiselect] = opts[:vm_ids] if opts[:vm_ids] end update_with_retry(params) wait_for_runstate(completed_runstate) unless runstate == completed_runstate end def wait_until_ready wait_for_runstate :ready end def wait_for_runstate(expected_runstate) expected_runstate = expected_runstate.to_s retry_while_resource_busy do unless reload.busy? break if runstate == expected_runstate || expected_runstate == 'ready' end end end def runstate get_api_attribute('runstate') end def busy? runstate == 'busy' end def stopped? runstate == 'stopped' end def running? runstate == 'running' end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems