Module: VagrantPlugins::Skytap::API::RunstateOperations

Includes:
Busyable
Included in:
Environment, Vm
Defined in:
lib/vagrant-skytap/api/runstate_operations.rb

Constant Summary

Constants included from Busyable

Busyable::WAIT_ITERATION_PERIOD, Busyable::WAIT_TIMEOUT

Instance Method Summary collapse

Methods included from Busyable

#retry_while_resource_busy, #update_with_retry

Instance Method Details

#busy?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 54

def busy?
  runstate == 'busy'
end

#poweroff!Object



22
23
24
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 22

def poweroff!
  set_runstate :halted, completed_runstate: :stopped
end

#run!Object



10
11
12
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 10

def run!
  set_runstate :running
end

#running?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 62

def running?
  runstate == 'running'
end

#runstateObject



50
51
52
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 50

def runstate
  get_api_attribute('runstate')
end

#set_runstate(new_runstate, opts = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 26

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

#stop!Object



18
19
20
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 18

def stop!
  set_runstate :stopped
end

#stopped?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 58

def stopped?
  runstate == 'stopped'
end

#suspend!Object



14
15
16
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 14

def suspend!
  set_runstate :suspended
end

#wait_for_runstate(expected_runstate) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 41

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

#wait_until_readyObject



37
38
39
# File 'lib/vagrant-skytap/api/runstate_operations.rb', line 37

def wait_until_ready
  wait_for_runstate :ready
end