ruby-libvirt 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +16 -0
- data/README +4 -16
- data/README.rdoc +1 -0
- data/Rakefile +65 -24
- data/ext/libvirt/_libvirt.c +245 -16
- data/ext/libvirt/common.c +3 -1
- data/ext/libvirt/connect.c +195 -38
- data/ext/libvirt/domain.c +871 -282
- data/ext/libvirt/domain.h +0 -3
- data/ext/libvirt/extconf.rb +81 -5
- data/ext/libvirt/interface.c +3 -3
- data/ext/libvirt/network.c +1 -1
- data/ext/libvirt/nodedevice.c +3 -1
- data/ext/libvirt/nwfilter.c +1 -1
- data/ext/libvirt/secret.c +3 -3
- data/ext/libvirt/storage.c +60 -11
- data/ext/libvirt/stream.c +394 -0
- data/ext/libvirt/stream.h +7 -0
- data/tests/test_conn.rb +470 -0
- data/tests/test_domain.rb +224 -258
- data/tests/test_interface.rb +7 -73
- data/tests/test_network.rb +15 -100
- data/tests/test_nodedevice.rb +0 -31
- data/tests/test_nwfilter.rb +6 -61
- data/tests/test_open.rb +43 -49
- data/tests/test_secret.rb +9 -65
- data/tests/test_storage.rb +35 -134
- data/tests/test_utils.rb +120 -13
- metadata +26 -26
data/tests/test_utils.rb
CHANGED
@@ -2,6 +2,119 @@ $FAIL = 0
|
|
2
2
|
$SUCCESS = 0
|
3
3
|
$SKIPPED = 0
|
4
4
|
|
5
|
+
$GUEST_DISK = '/var/lib/libvirt/images/ruby-libvirt-tester.qcow2'
|
6
|
+
$GUEST_UUID = "93a5c045-6457-2c09-e56f-927cdf34e17a"
|
7
|
+
|
8
|
+
# XML data for later tests
|
9
|
+
$new_dom_xml = <<EOF
|
10
|
+
<domain type='kvm'>
|
11
|
+
<name>ruby-libvirt-tester</name>
|
12
|
+
<uuid>#{$GUEST_UUID}</uuid>
|
13
|
+
<memory>1048576</memory>
|
14
|
+
<currentMemory>1048576</currentMemory>
|
15
|
+
<vcpu>2</vcpu>
|
16
|
+
<os>
|
17
|
+
<type arch='x86_64'>hvm</type>
|
18
|
+
<boot dev='hd'/>
|
19
|
+
</os>
|
20
|
+
<features>
|
21
|
+
<acpi/>
|
22
|
+
<apic/>
|
23
|
+
<pae/>
|
24
|
+
</features>
|
25
|
+
<clock offset='utc'/>
|
26
|
+
<on_poweroff>destroy</on_poweroff>
|
27
|
+
<on_reboot>restart</on_reboot>
|
28
|
+
<on_crash>restart</on_crash>
|
29
|
+
<devices>
|
30
|
+
<disk type='file' device='disk'>
|
31
|
+
<driver name='qemu' type='qcow2'/>
|
32
|
+
<source file='#{$GUEST_DISK}'/>
|
33
|
+
<target dev='vda' bus='virtio'/>
|
34
|
+
</disk>
|
35
|
+
<interface type='bridge'>
|
36
|
+
<mac address='52:54:00:60:3c:95'/>
|
37
|
+
<source bridge='virbr0'/>
|
38
|
+
<model type='virtio'/>
|
39
|
+
<target dev='rl556'/>
|
40
|
+
</interface>
|
41
|
+
<serial type='pty'>
|
42
|
+
<target port='0'/>
|
43
|
+
</serial>
|
44
|
+
<console type='pty'>
|
45
|
+
<target port='0'/>
|
46
|
+
</console>
|
47
|
+
<input type='mouse' bus='ps2'/>
|
48
|
+
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
|
49
|
+
<video>
|
50
|
+
<model type='cirrus' vram='9216' heads='1'/>
|
51
|
+
</video>
|
52
|
+
</devices>
|
53
|
+
</domain>
|
54
|
+
EOF
|
55
|
+
|
56
|
+
# qemu command-line that roughly corresponds to the above XML
|
57
|
+
$qemu_cmd_line = "/usr/bin/qemu-kvm -S -M pc-0.13 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name ruby-libvirt-tester -uuid #{$GUEST_UUID} -nodefconfig -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/ruby-libvirt-tester.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5"
|
58
|
+
|
59
|
+
$new_interface_xml = <<EOF
|
60
|
+
<interface type="bridge" name="ruby-libvirt-tester">
|
61
|
+
<start mode="onboot"/>
|
62
|
+
<bridge delay="0">
|
63
|
+
</bridge>
|
64
|
+
</interface>
|
65
|
+
EOF
|
66
|
+
|
67
|
+
$NETWORK_UUID = "04068860-d9a2-47c5-bc9d-9e047ae901da"
|
68
|
+
$new_net_xml = <<EOF
|
69
|
+
<network>
|
70
|
+
<name>ruby-libvirt-tester</name>
|
71
|
+
<uuid>#{$NETWORK_UUID}</uuid>
|
72
|
+
<forward mode='nat'/>
|
73
|
+
<bridge name='rubybr0' stp='on' delay='0' />
|
74
|
+
<ip address='192.168.134.1' netmask='255.255.255.0'>
|
75
|
+
<dhcp>
|
76
|
+
<range start='192.168.134.2' end='192.168.134.254' />
|
77
|
+
</dhcp>
|
78
|
+
</ip>
|
79
|
+
</network>
|
80
|
+
EOF
|
81
|
+
|
82
|
+
$NWFILTER_UUID = "bd339530-134c-6d07-441a-17fb90dad807"
|
83
|
+
$new_nwfilter_xml = <<EOF
|
84
|
+
<filter name='ruby-libvirt-tester' chain='ipv4'>
|
85
|
+
<uuid>#{$NWFILTER_UUID}</uuid>
|
86
|
+
<rule action='accept' direction='out' priority='100'>
|
87
|
+
<ip srcipaddr='0.0.0.0' dstipaddr='255.255.255.255' protocol='tcp' srcportstart='63000' dstportstart='62000'/>
|
88
|
+
</rule>
|
89
|
+
<rule action='accept' direction='in' priority='100'>
|
90
|
+
<ip protocol='tcp' srcportstart='63000' dstportstart='62000'/>
|
91
|
+
</rule>
|
92
|
+
</filter>
|
93
|
+
EOF
|
94
|
+
|
95
|
+
$SECRET_UUID = "bd339530-134c-6d07-4410-17fb90dad805"
|
96
|
+
$new_secret_xml = <<EOF
|
97
|
+
<secret ephemeral='no' private='no'>
|
98
|
+
<description>test secret</description>
|
99
|
+
<uuid>#{$SECRET_UUID}</uuid>
|
100
|
+
<usage type='volume'>
|
101
|
+
<volume>/var/lib/libvirt/images/mail.img</volume>
|
102
|
+
</usage>
|
103
|
+
</secret>
|
104
|
+
EOF
|
105
|
+
|
106
|
+
$POOL_UUID = "33a5c045-645a-2c00-e56b-927cdf34e17a"
|
107
|
+
$POOL_PATH = "/var/lib/libvirt/images/ruby-libvirt-tester"
|
108
|
+
$new_storage_pool_xml = <<EOF
|
109
|
+
<pool type="dir">
|
110
|
+
<name>ruby-libvirt-tester</name>
|
111
|
+
<uuid>#{$POOL_UUID}</uuid>
|
112
|
+
<target>
|
113
|
+
<path>#{$POOL_PATH}</path>
|
114
|
+
</target>
|
115
|
+
</pool>
|
116
|
+
EOF
|
117
|
+
|
5
118
|
def expect_success(object, msg, func, *args)
|
6
119
|
begin
|
7
120
|
x = object.send(func, *args)
|
@@ -12,15 +125,12 @@ def expect_success(object, msg, func, *args)
|
|
12
125
|
raise "Failed"
|
13
126
|
end
|
14
127
|
end
|
15
|
-
|
16
|
-
$SUCCESS = $SUCCESS + 1
|
128
|
+
puts_ok "#{func} #{msg} succeeded"
|
17
129
|
x
|
18
130
|
rescue NoMethodError
|
19
|
-
|
20
|
-
$SKIPPED = $SKIPPED + 1
|
131
|
+
puts_skipped "#{func} does not exist"
|
21
132
|
rescue => e
|
22
|
-
|
23
|
-
$FAIL = $FAIL + 1
|
133
|
+
puts_fail "#{func} #{msg} expected to succeed, threw #{e.class.to_s}: #{e.to_s}"
|
24
134
|
end
|
25
135
|
end
|
26
136
|
|
@@ -28,16 +138,13 @@ def expect_fail(object, errtype, errmsg, func, *args)
|
|
28
138
|
begin
|
29
139
|
object.send(func, *args)
|
30
140
|
rescue NoMethodError
|
31
|
-
|
141
|
+
puts_skipped "#{func} does not exist"
|
32
142
|
rescue errtype => e
|
33
|
-
|
34
|
-
$SUCCESS = $SUCCESS + 1
|
143
|
+
puts_ok "#{func} #{errmsg} threw #{errtype.to_s}"
|
35
144
|
rescue => e
|
36
|
-
|
37
|
-
$FAIL = $FAIL + 1
|
145
|
+
puts_fail "#{func} #{errmsg} expected to throw #{errtype.to_s}, but instead threw #{e.class.to_s}: #{e.to_s}"
|
38
146
|
else
|
39
|
-
|
40
|
-
$FAIL = $FAIL + 1
|
147
|
+
puts_fail "#{func} #{errmsg} expected to throw #{errtype.to_s}, but threw nothing"
|
41
148
|
end
|
42
149
|
end
|
43
150
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Lutterkort, Chris Lalancette
|
@@ -15,13 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-29 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description:
|
23
|
-
Provides bindings for libvirt.
|
24
|
-
|
22
|
+
description: Ruby bindings for libvirt.
|
25
23
|
email: libvir-list@redhat.com
|
26
24
|
executables: []
|
27
25
|
|
@@ -36,36 +34,38 @@ files:
|
|
36
34
|
- NEWS
|
37
35
|
- README.rdoc
|
38
36
|
- lib/libvirt.rb
|
39
|
-
- ext/libvirt/common.c
|
40
|
-
- ext/libvirt/common.h
|
41
|
-
- ext/libvirt/nwfilter.c
|
42
|
-
- ext/libvirt/network.c
|
43
|
-
- ext/libvirt/nwfilter.h
|
44
|
-
- ext/libvirt/connect.h
|
45
|
-
- ext/libvirt/nodedevice.c
|
46
|
-
- ext/libvirt/storage.c
|
47
|
-
- ext/libvirt/_libvirt.c
|
48
|
-
- ext/libvirt/network.h
|
49
|
-
- ext/libvirt/nodedevice.h
|
50
|
-
- ext/libvirt/connect.c
|
51
|
-
- ext/libvirt/storage.h
|
52
37
|
- ext/libvirt/domain.h
|
53
|
-
- ext/libvirt/secret.c
|
54
38
|
- ext/libvirt/domain.c
|
55
|
-
- ext/libvirt/
|
39
|
+
- ext/libvirt/network.h
|
40
|
+
- ext/libvirt/secret.c
|
56
41
|
- ext/libvirt/secret.h
|
42
|
+
- ext/libvirt/stream.h
|
43
|
+
- ext/libvirt/storage.h
|
44
|
+
- ext/libvirt/storage.c
|
45
|
+
- ext/libvirt/_libvirt.c
|
57
46
|
- ext/libvirt/interface.h
|
47
|
+
- ext/libvirt/network.c
|
48
|
+
- ext/libvirt/nwfilter.c
|
49
|
+
- ext/libvirt/connect.h
|
50
|
+
- ext/libvirt/common.h
|
51
|
+
- ext/libvirt/connect.c
|
52
|
+
- ext/libvirt/common.c
|
53
|
+
- ext/libvirt/interface.c
|
54
|
+
- ext/libvirt/nodedevice.h
|
55
|
+
- ext/libvirt/nodedevice.c
|
56
|
+
- ext/libvirt/stream.c
|
57
|
+
- ext/libvirt/nwfilter.h
|
58
58
|
- ext/libvirt/extconf.rb
|
59
59
|
- tests/test_interface.rb
|
60
|
-
- tests/test_utils.rb
|
61
60
|
- tests/test_network.rb
|
61
|
+
- tests/test_nwfilter.rb
|
62
|
+
- tests/test_utils.rb
|
62
63
|
- tests/test_domain.rb
|
64
|
+
- tests/test_storage.rb
|
63
65
|
- tests/test_open.rb
|
64
66
|
- tests/test_secret.rb
|
65
|
-
- tests/test_nodedevice.rb
|
66
|
-
- tests/test_storage.rb
|
67
67
|
- tests/test_conn.rb
|
68
|
-
- tests/
|
68
|
+
- tests/test_nodedevice.rb
|
69
69
|
has_rdoc: true
|
70
70
|
homepage: http://libvirt.org/ruby/
|
71
71
|
licenses: []
|