class Vixen::Model::VM

Public Instance Methods

all_snapshots() click to toggle source
# File lib/vixen/model/vm.rb, line 26
def all_snapshots
  roots = root_snapshots
  childs = roots.map {|s| s.all_children }
  (roots + childs).flatten
end
create_snapshot(name, description="", &block) click to toggle source
# File lib/vixen/model/vm.rb, line 32
def create_snapshot(name, description="", &block)
  Vixen::Model::Snapshot.new(Vixen::Bridge.create_snapshot handle, name, description, &block)
end
current_power_states() click to toggle source
# File lib/vixen/model/vm.rb, line 117
def current_power_states
  states = []
  bitwise_state = Vixen::Bridge.current_power_state handle
  [ :powering_off, :powered_off, :powering_on, :powered_on, :suspending,
    :suspended, :tools_running, :resetting, :blocked_on_msg, :paused,
    :resuming
  ].each do |state|
    states << state if ((bitwise_state & Vixen::Constants::VixPowerState[state]) == Vixen::Constants::VixPowerState[state])
  end
  states
end
current_snapshot() click to toggle source
# File lib/vixen/model/vm.rb, line 18
def current_snapshot
  Vixen::Model::Snapshot.new(Vixen::Bridge.current_snapshot(handle))
end
guest_os() click to toggle source
# File lib/vixen/model/vm.rb, line 14
def guest_os
  get_string_property Vixen::Constants::VixPropertyId[:vm_guestos]
end
name() click to toggle source
# File lib/vixen/model/vm.rb, line 6
def name
  get_string_property Vixen::Constants::VixPropertyId[:vm_name]
end
path() click to toggle source
# File lib/vixen/model/vm.rb, line 10
def path
  get_string_property Vixen::Constants::VixPropertyId[:vmx_pathname]
end
power_off(opts={}, &block) click to toggle source
# File lib/vixen/model/vm.rb, line 59
def power_off(opts={}, &block)
  hard_power_off = opts[:hard] || :if_necessary
  case hard_power_off
  when :if_necessary
    Vixen::Bridge.power_off_using_guest(handle, &block) || Vixen::Bridge.power_off(handle, &block)
  when :always
    Vixen::Bridge.power_off(handle, &block)
  else
    Vixen::Bridge.power_off_using_guest(handle, &block)
  end
  self
end
power_on(&block) click to toggle source
# File lib/vixen/model/vm.rb, line 44
def power_on(&block)
  return self if powered_on? or powering_on? or resuming? or resetting?
  Vixen::Bridge.power_on handle, &block
  self
end
powered_off?() click to toggle source
# File lib/vixen/model/vm.rb, line 89
def powered_off?
  current_power_states.include? :powered_off
end
powered_on?() click to toggle source
# File lib/vixen/model/vm.rb, line 97
def powered_on?
  current_power_states.include? :powered_on
end
powering_off?() click to toggle source
# File lib/vixen/model/vm.rb, line 85
def powering_off?
  current_power_states.include? :powering_off
end
powering_on?() click to toggle source
# File lib/vixen/model/vm.rb, line 93
def powering_on?
  current_power_states.include? :powering_on
end
remove_snapshot(snapshot, &block) click to toggle source
# File lib/vixen/model/vm.rb, line 40
def remove_snapshot(snapshot, &block)
  Vixen::Bridge.remove_snaphost self, snapshot, &block
end
reset(opts={}, &block) click to toggle source
# File lib/vixen/model/vm.rb, line 72
def reset(opts={}, &block)
  hard_reset = opts[:hard] || :if_necessary
  case hard_reset
  when :if_necessary
    Vixen::Bridge.reset_using_guest(handle, &block) || Vixen::Bridge.reset(handle, &block)
  when :always
    Vixen::Bridge.reset(handle, &block)
  else
    Vixen::Bridge.reset_using_guest(handle, &block)
  end
  self
end
resetting?() click to toggle source
# File lib/vixen/model/vm.rb, line 113
def resetting?
  current_power_states.include? :resetting
end
resume(&block) click to toggle source
# File lib/vixen/model/vm.rb, line 50
def resume(&block)
  power_on &block
end
resuming?() click to toggle source
# File lib/vixen/model/vm.rb, line 101
def resuming?
  current_power_states.include? :resuming
end
revert_to_snapshot(snapshot, &block) click to toggle source
# File lib/vixen/model/vm.rb, line 36
def revert_to_snapshot(snapshot, &block)
  Vixen::Bridge.revert_to_snapshot self, snapshot, &block
end
root_snapshots() click to toggle source
# File lib/vixen/model/vm.rb, line 22
def root_snapshots
  Vixen::Bridge.get_root_snapshots handle
end
suspend(&block) click to toggle source
# File lib/vixen/model/vm.rb, line 54
def suspend(&block)
  Vixen::Bridge.suspend handle, &block
  self
end
suspended?() click to toggle source
# File lib/vixen/model/vm.rb, line 109
def suspended?
  current_power_states.include? :suspended
end
suspending?() click to toggle source
# File lib/vixen/model/vm.rb, line 105
def suspending?
  current_power_states.include? :suspending
end