Class: Virtuoso::VirtualBox::VM
Overview
Instance Attribute Summary
Attributes inherited from API::VM
#connection, #disk_image, #domain, #memory, #name
Instance Method Summary
collapse
Methods inherited from API::VM
#initialize
Instance Method Details
#destroy ⇒ Object
56
57
58
59
60
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 56
def destroy
requires_existing_vm
@domain.undefine
@domain = nil
end
|
#reload ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 72
def reload
spec = domain.spec
disk = spec.devices.find { |d| d.is_a?(Libvirt::Spec::Device::Disk) }
self.disk_image = disk.source
self.name = spec.name
self.memory = spec.memory
end
|
#save ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 9
def save
d = Libvirt::Spec::Domain.new
d.hypervisor = :vbox
d.name = name
d.memory = memory
d.vcpu = 1
d.features = [:acpi, :pae]
d.clock.offset = :localtime
d.os.type = :hvm
d.os.arch = :i386
d.os.boot = [:cdrom, :hd]
disk = Libvirt::Spec::Device.get(:disk).new
disk.type = :file
disk.device = :disk
disk.source = disk_image
disk.target_dev = :hda
disk.target_bus = :ide
d.devices << disk
nat = Libvirt::Spec::Device.get(:interface).new
nat.type = :user
nat.mac_address = "08:00:27:8f:7a:9f"
nat.model_type = "82540EM"
d.devices << nat
video = Libvirt::Spec::Device.get(:video).new
model = Libvirt::Spec::Device::VideoModel.new
model.type = :vbox
model.vram = 12
model.heads = 1
model.accel3d = false
model.accel2d = false
video.models << model
d.devices << video
@domain = connection.domains.define(d)
reload
end
|
#start ⇒ Object
62
63
64
65
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 62
def start
requires_existing_vm
domain.start
end
|
#state ⇒ Object
5
6
7
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 5
def state
domain ? domain.state : :new
end
|
#stop ⇒ Object
67
68
69
70
|
# File 'lib/virtuoso/virtualbox/vm.rb', line 67
def stop
requires_existing_vm
domain.stop
end
|