libvirt 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ require "test_helper"
2
+
3
+ Protest.describe("Graphics device spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Device::Graphics
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the type" do
10
+ @instance = @klass.new("<graphics type='sdl'/>")
11
+ assert_equal :sdl, @instance.type
12
+ end
13
+
14
+ should "parse the display" do
15
+ @instance = @klass.new("<graphics display='foo'/>")
16
+ assert_equal 'foo', @instance.display
17
+ end
18
+
19
+ should "raise an exception if unsupported tags exist" do
20
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
21
+ @klass.new("<graphics><foo/></graphics>")
22
+ }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require "test_helper"
2
+
3
+ Protest.describe("Input device spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Device::Input
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the type" do
10
+ @instance = @klass.new("<input type='mouse'>")
11
+ assert_equal :mouse, @instance.type
12
+ end
13
+
14
+ should "parse the bus" do
15
+ @instance = @klass.new("<input bus='usb'>")
16
+ assert_equal :usb, @instance.bus
17
+ end
18
+
19
+ should "raise an exception if unsupported tags exist" do
20
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
21
+ @klass.new("<input><foo/></input>")
22
+ }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require "test_helper"
2
+
3
+ Protest.describe("Interface device spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Device::Interface
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the type" do
10
+ @instance = @klass.new("<interface type='user'></interface>")
11
+ assert_equal :user, @instance.type
12
+ end
13
+
14
+ should "parse the MAC address" do
15
+ @instance = @klass.new("<interface><mac address='foo'/></interface>")
16
+ assert_equal 'foo', @instance.mac_address
17
+ end
18
+
19
+ should "parse the model type" do
20
+ @instance = @klass.new("<interface><model type='foo'/></interface>")
21
+ assert_equal 'foo', @instance.model_type
22
+ end
23
+
24
+ should "parse the source from a network" do
25
+ @instance = @klass.new("<interface><source network='foo'/></interface>")
26
+ assert_equal 'foo', @instance.source_network
27
+ end
28
+
29
+ should "raise an exception if unsupported tags exist" do
30
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
31
+ @klass.new("<interface><foo/></interface>")
32
+ }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ require "test_helper"
2
+
3
+ Protest.describe("Sound device spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Device::Sound
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the model" do
10
+ @instance = @klass.new("<sound model='ac97'/>")
11
+ assert_equal :ac97, @instance.model
12
+ end
13
+
14
+ should "raise an exception if unsupported tags exist" do
15
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
16
+ @klass.new("<sound><foo/></sound>")
17
+ }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ require "test_helper"
2
+
3
+ Protest.describe("Video model device spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Device::VideoModel
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the type" do
10
+ @instance = @klass.new("<model type='vga'/>")
11
+ assert_equal :vga, @instance.type
12
+ end
13
+
14
+ should "parse the vram" do
15
+ @instance = @klass.new("<model vram='12'/>")
16
+ assert_equal '12', @instance.vram
17
+ end
18
+
19
+ should "parse the type" do
20
+ @instance = @klass.new("<model heads='2'/>")
21
+ assert_equal '2', @instance.heads
22
+ end
23
+
24
+ should "parse the acceleration" do
25
+ @instance = @klass.new("<model><acceleration accel3d='yes' accel2d='no'/></model>")
26
+ assert @instance.accel3d
27
+ assert !@instance.accel2d
28
+ end
29
+
30
+ should "raise an exception if unsupported tags exist" do
31
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
32
+ @klass.new("<model><foo/></model>")
33
+ }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ Protest.describe("Domain clock spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Domain::Clock
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the offset" do
10
+ @instance = @klass.new("<clock offset='foo'/>")
11
+ assert_equal :foo, @instance.offset
12
+ end
13
+
14
+ should "raise an exception if unsupported tags exist" do
15
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
16
+ @klass.new("<clock offset='foo'><foo/></clock>")
17
+ }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ Protest.describe("Domain OS booting spec") do
4
+ setup do
5
+ @klass = Libvirt::Spec::Domain::OSBooting
6
+ end
7
+
8
+ context "initialization and parsing XML" do
9
+ should "parse the type" do
10
+ @instance = @klass.new("<os><type>hvm</type></os>")
11
+ assert_equal :hvm, @instance.type
12
+ end
13
+
14
+ should "parse the architecture" do
15
+ @instance = @klass.new("<os><type arch='i386'>hvm</type></os>")
16
+ assert_equal :i386, @instance.arch
17
+ end
18
+
19
+ should "parse the boot device order" do
20
+ @instance = @klass.new(<<-XML)
21
+ <os>
22
+ <boot dev='fd'/>
23
+ <boot dev='cdrom'/>
24
+ <boot dev='hd'/>
25
+ </os>
26
+ XML
27
+
28
+ assert_equal [:fd, :cdrom, :hd], @instance.boot
29
+ end
30
+ end
31
+ end
@@ -7,11 +7,133 @@ Protest.describe("Domain spec") do
7
7
 
8
8
  context "initialization" do
9
9
  setup do
10
- @instance= @klass.new
10
+ @instance = @klass.new
11
+ end
12
+
13
+ should "initialize an OS booting object" do
14
+ assert @instance.os.is_a?(Libvirt::Spec::Domain::OSBooting)
11
15
  end
12
16
 
13
17
  should "not have any devices" do
14
18
  assert @instance.devices.empty?
15
19
  end
20
+
21
+ should "initialize a memtune object" do
22
+ assert @instance.memtune.is_a?(Libvirt::Spec::Domain::Memtune)
23
+ end
24
+ end
25
+
26
+ context "initialization with spec parsing" do
27
+ should "raise an exception if an invalid tag is found" do
28
+ assert_raises(Libvirt::Exception::UnparseableSpec) {
29
+ @klass.new("<domain><foo></foo></domain>")
30
+ }
31
+ end
32
+
33
+ should "parse the hypervisor" do
34
+ @instance = @klass.new("<domain type='vbox'></domain>")
35
+ assert_equal :vbox, @instance.hypervisor
36
+ end
37
+
38
+ should "parse the name" do
39
+ @instance = @klass.new(<<-XML)
40
+ <domain type='vbox'>
41
+ <name>test_vm_A</name>
42
+ </domain>
43
+ XML
44
+
45
+ assert_equal "test_vm_A", @instance.name
46
+ end
47
+
48
+ should "parse the UUID" do
49
+ @instance = @klass.new(<<-XML)
50
+ <domain>
51
+ <uuid>foo</uuid>
52
+ </domain>
53
+ XML
54
+
55
+ assert_equal "foo", @instance.uuid
56
+ end
57
+
58
+ should "parse the memory" do
59
+ @instance = @klass.new(<<-XML)
60
+ <domain>
61
+ <memory>123456</memory>
62
+ </domain>
63
+ XML
64
+
65
+ assert_equal "123456", @instance.memory
66
+ end
67
+
68
+ should "parse the UUID" do
69
+ @instance = @klass.new(<<-XML)
70
+ <domain>
71
+ <currentMemory>1234</currentMemory>
72
+ </domain>
73
+ XML
74
+
75
+ assert_equal "1234", @instance.current_memory
76
+ end
77
+
78
+ should "parse the VCPU count" do
79
+ @instance = @klass.new(<<-XML)
80
+ <domain>
81
+ <vcpu>4</vcpu>
82
+ </domain>
83
+ XML
84
+
85
+ assert_equal "4", @instance.vcpu
86
+ end
87
+
88
+ should "parse on_poweroff" do
89
+ @instance = @klass.new(<<-XML)
90
+ <domain>
91
+ <on_poweroff>foo</on_poweroff>
92
+ </domain>
93
+ XML
94
+
95
+ assert_equal :foo, @instance.on_poweroff
96
+ end
97
+
98
+ should "parse on_reboot" do
99
+ @instance = @klass.new(<<-XML)
100
+ <domain>
101
+ <on_reboot>foo</on_reboot>
102
+ </domain>
103
+ XML
104
+
105
+ assert_equal :foo, @instance.on_reboot
106
+ end
107
+
108
+ should "parse on_crash" do
109
+ @instance = @klass.new(<<-XML)
110
+ <domain>
111
+ <on_crash>foo</on_crash>
112
+ </domain>
113
+ XML
114
+
115
+ assert_equal :foo, @instance.on_crash
116
+ end
117
+
118
+ should "parse the clock" do
119
+ @instance = @klass.new("<domain><clock offset='foo'/></domain>")
120
+ assert_equal :foo, @instance.clock.offset
121
+ end
122
+
123
+ should "parse the OS booting information" do
124
+ @instance = @klass.new("<domain><os><type>hvm</type></domain>")
125
+ assert_equal :hvm, @instance.os.type
126
+ end
127
+
128
+ should "parse the devices" do
129
+ @instance = @klass.new("<domain><devices><disk type='file'></disk></devices></domain>")
130
+ assert_equal 1, @instance.devices.length
131
+ assert_equal :file, @instance.devices.first.type
132
+ end
133
+
134
+ should "parse the features" do
135
+ @instance = @klass.new("<domain><features><pae/><acpi/></features></domain>")
136
+ assert_equal [:pae, :acpi], @instance.features
137
+ end
16
138
  end
17
139
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mitchell Hashimoto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-16 00:00:00 -08:00
17
+ date: 2010-12-07 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -77,7 +77,7 @@ dependencies:
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: *id004
80
- description: A ruby client library providing the raw interface to libvirt via FFI.
80
+ description: A ruby client library providing an interface to libvirt via FFI.
81
81
  email:
82
82
  - mitchell.hashimoto@gmail.com
83
83
  executables: []
@@ -132,8 +132,17 @@ files:
132
132
  - lib/libvirt/spec/device.rb
133
133
  - lib/libvirt/spec/device/disk.rb
134
134
  - lib/libvirt/spec/device/emulator.rb
135
+ - lib/libvirt/spec/device/graphics.rb
136
+ - lib/libvirt/spec/device/input.rb
137
+ - lib/libvirt/spec/device/interface.rb
138
+ - lib/libvirt/spec/device/sound.rb
139
+ - lib/libvirt/spec/device/video.rb
140
+ - lib/libvirt/spec/device/video_model.rb
135
141
  - lib/libvirt/spec/domain.rb
142
+ - lib/libvirt/spec/domain/clock.rb
143
+ - lib/libvirt/spec/domain/memtune.rb
136
144
  - lib/libvirt/spec/domain/os_booting.rb
145
+ - lib/libvirt/spec/util.rb
137
146
  - lib/libvirt/storage_pool.rb
138
147
  - lib/libvirt/storage_volume.rb
139
148
  - lib/libvirt/version.rb
@@ -153,8 +162,16 @@ files:
153
162
  - test/libvirt/network_test.rb
154
163
  - test/libvirt/node_device_test.rb
155
164
  - test/libvirt/node_test.rb
165
+ - test/libvirt/spec/device_test.rb
156
166
  - test/libvirt/spec/devices/disk_test.rb
157
167
  - test/libvirt/spec/devices/emulator_test.rb
168
+ - test/libvirt/spec/devices/graphics_test.rb
169
+ - test/libvirt/spec/devices/input_test.rb
170
+ - test/libvirt/spec/devices/interface_test.rb
171
+ - test/libvirt/spec/devices/sound_test.rb
172
+ - test/libvirt/spec/devices/video_model_test.rb
173
+ - test/libvirt/spec/domain/clock_test.rb
174
+ - test/libvirt/spec/domain/os_booting_test.rb
158
175
  - test/libvirt/spec/domain_test.rb
159
176
  - test/libvirt/storage_pool_test.rb
160
177
  - test/libvirt/storage_volume_test.rb
@@ -174,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
191
  requirements:
175
192
  - - ">="
176
193
  - !ruby/object:Gem::Version
177
- hash: -4129372226300388210
194
+ hash: 2073983143037302112
178
195
  segments:
179
196
  - 0
180
197
  version: "0"
@@ -183,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
200
  requirements:
184
201
  - - ">="
185
202
  - !ruby/object:Gem::Version
186
- hash: -4129372226300388210
203
+ hash: 2073983143037302112
187
204
  segments:
188
205
  - 0
189
206
  version: "0"
@@ -193,7 +210,7 @@ rubyforge_project: libvirt
193
210
  rubygems_version: 1.3.7
194
211
  signing_key:
195
212
  specification_version: 3
196
- summary: A ruby client library providing the raw interface to libvirt via FFI.
213
+ summary: A ruby client library providing an interface to libvirt via FFI.
197
214
  test_files:
198
215
  - test/libvirt/collection/abstract_collection_test.rb
199
216
  - test/libvirt/collection/domain_collection_test.rb
@@ -210,8 +227,16 @@ test_files:
210
227
  - test/libvirt/network_test.rb
211
228
  - test/libvirt/node_device_test.rb
212
229
  - test/libvirt/node_test.rb
230
+ - test/libvirt/spec/device_test.rb
213
231
  - test/libvirt/spec/devices/disk_test.rb
214
232
  - test/libvirt/spec/devices/emulator_test.rb
233
+ - test/libvirt/spec/devices/graphics_test.rb
234
+ - test/libvirt/spec/devices/input_test.rb
235
+ - test/libvirt/spec/devices/interface_test.rb
236
+ - test/libvirt/spec/devices/sound_test.rb
237
+ - test/libvirt/spec/devices/video_model_test.rb
238
+ - test/libvirt/spec/domain/clock_test.rb
239
+ - test/libvirt/spec/domain/os_booting_test.rb
215
240
  - test/libvirt/spec/domain_test.rb
216
241
  - test/libvirt/storage_pool_test.rb
217
242
  - test/libvirt/storage_volume_test.rb