Class: Tenderloin::VM
Instance Attribute Summary collapse
Class Method Summary
collapse
-
.find(uuid) ⇒ Object
Finds a virtual machine by a given UUID and either returns a Tenderloin::VM object or returns nil.
Instance Method Summary
collapse
Methods included from Util
#error_and_exit, included, #logger, #wrap_output
#action_klasses, #actions, #add_action, execute!, #execute!, #find_action, #invoke_around_callback, #invoke_callback
Constructor Details
#initialize(vm = nil) ⇒ VM
Returns a new instance of VM.
17
18
19
|
# File 'lib/tenderloin/vm.rb', line 17
def initialize(vm=nil)
@vm_id = vm
end
|
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
6
7
8
|
# File 'lib/tenderloin/vm.rb', line 6
def from
@from
end
|
#vm_id ⇒ Object
Returns the value of attribute vm_id.
5
6
7
|
# File 'lib/tenderloin/vm.rb', line 5
def vm_id
@vm_id
end
|
Class Method Details
.find(uuid) ⇒ Object
Finds a virtual machine by a given UUID and either returns a Tenderloin::VM object or returns nil.
11
12
13
14
|
# File 'lib/tenderloin/vm.rb', line 11
def find(uuid)
new(uuid) if File.exists? File.join(Tenderloin::Env.vms_path, uuid, uuid + ".vmx")
end
|
Instance Method Details
#destroy ⇒ Object
45
46
47
|
# File 'lib/tenderloin/vm.rb', line 45
def destroy
execute!(Actions::VM::Destroy)
end
|
#fusion_vm ⇒ Object
31
32
33
|
# File 'lib/tenderloin/vm.rb', line 31
def fusion_vm
@fusion_vm ||= FusionVM.new(vmx_path) if vmx_path
end
|
#package(out_path, include_files = []) ⇒ Object
21
22
23
24
25
|
# File 'lib/tenderloin/vm.rb', line 21
def package(out_path, include_files=[])
add_action(Actions::VM::Export)
add_action(Actions::VM::Package, out_path, include_files)
execute!
end
|
#powered_off? ⇒ Boolean
61
|
# File 'lib/tenderloin/vm.rb', line 61
def powered_off?; @vm.powered_off? end
|
#resume ⇒ Object
53
54
55
|
# File 'lib/tenderloin/vm.rb', line 53
def resume
execute!(Actions::VM::Resume)
end
|
#running? ⇒ Boolean
41
42
43
|
# File 'lib/tenderloin/vm.rb', line 41
def running?
fusion_vm.running?
end
|
#saved? ⇒ Boolean
57
58
59
|
# File 'lib/tenderloin/vm.rb', line 57
def saved?
@vm.saved?
end
|
#start ⇒ Object
35
36
37
38
39
|
# File 'lib/tenderloin/vm.rb', line 35
def start
return if running?
execute!(Actions::VM::Start)
end
|
#suspend ⇒ Object
49
50
51
|
# File 'lib/tenderloin/vm.rb', line 49
def suspend
execute!(Actions::VM::Suspend)
end
|
#vmx_path ⇒ Object
27
28
29
|
# File 'lib/tenderloin/vm.rb', line 27
def vmx_path
File.join(Tenderloin::Env.vms_path, @vm_id, @vm_id + ".vmx")
end
|