Class: Vixen::Model::VM
- Inherits:
-
Base
- Object
- Base
- Vixen::Model::VM
show all
- Defined in:
- lib/vixen/model/vm.rb
Instance Attribute Summary
Attributes inherited from Base
#handle
Instance Method Summary
collapse
Methods inherited from Base
finalize, #get_string_property, #initialize
Instance Method Details
#all_snapshots ⇒ Object
26
27
28
29
30
|
# 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) ⇒ Object
#current_power_states ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
|
# 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 ⇒ Object
#power_off(opts = {}, &block) ⇒ Object
#power_on(&block) ⇒ Object
44
45
46
47
48
|
# 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? ⇒ Boolean
89
90
91
|
# File 'lib/vixen/model/vm.rb', line 89
def powered_off?
current_power_states.include? :powered_off
end
|
#powered_on? ⇒ Boolean
97
98
99
|
# File 'lib/vixen/model/vm.rb', line 97
def powered_on?
current_power_states.include? :powered_on
end
|
#powering_off? ⇒ Boolean
85
86
87
|
# File 'lib/vixen/model/vm.rb', line 85
def powering_off?
current_power_states.include? :powering_off
end
|
#powering_on? ⇒ Boolean
93
94
95
|
# File 'lib/vixen/model/vm.rb', line 93
def powering_on?
current_power_states.include? :powering_on
end
|
#remove_snapshot(snapshot, &block) ⇒ Object
40
41
42
|
# File 'lib/vixen/model/vm.rb', line 40
def remove_snapshot(snapshot, &block)
Vixen::Bridge.remove_snaphost self, snapshot, &block
end
|
#reset(opts = {}, &block) ⇒ Object
#resetting? ⇒ Boolean
113
114
115
|
# File 'lib/vixen/model/vm.rb', line 113
def resetting?
current_power_states.include? :resetting
end
|
#resume(&block) ⇒ Object
50
51
52
|
# File 'lib/vixen/model/vm.rb', line 50
def resume(&block)
power_on &block
end
|
#resuming? ⇒ Boolean
101
102
103
|
# File 'lib/vixen/model/vm.rb', line 101
def resuming?
current_power_states.include? :resuming
end
|
#revert_to_snapshot(snapshot, &block) ⇒ Object
36
37
38
|
# File 'lib/vixen/model/vm.rb', line 36
def revert_to_snapshot(snapshot, &block)
Vixen::Bridge.revert_to_snapshot self, snapshot, &block
end
|
#suspend(&block) ⇒ Object
54
55
56
57
|
# File 'lib/vixen/model/vm.rb', line 54
def suspend(&block)
Vixen::Bridge.suspend handle, &block
self
end
|
#suspended? ⇒ Boolean
109
110
111
|
# File 'lib/vixen/model/vm.rb', line 109
def suspended?
current_power_states.include? :suspended
end
|
#suspending? ⇒ Boolean
105
106
107
|
# File 'lib/vixen/model/vm.rb', line 105
def suspending?
current_power_states.include? :suspending
end
|