kitchen-qemu 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/qemu.rb +25 -14
- data/lib/kitchen/driver/qemu_version.rb +1 -1
- data/lib/kitchen/driver/qmpclient.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae36680bcd2808d461d0d57e9be6d0c55a919c43
|
4
|
+
data.tar.gz: 05b1439ddc31ba48f31b607e2bb96607c428d5ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4013ca5ceba2813668ea367f656baa9bb6d9d7886d885c93ddf4112a32863f3796a43e0d1425735d43406203900e34c9b1b88c1f2d832f01f42b90273dd6b32
|
7
|
+
data.tar.gz: 029c25cec633dcd7ba9d2a7fc3ca4b5ec9a6a8be80c82691ec43bfb40a1e76fa245a2d93a60ca2e898c5af687d967f342992549dc858563ec81c627d76e9d9c3
|
data/lib/kitchen/driver/qemu.rb
CHANGED
@@ -41,7 +41,7 @@ module Kitchen
|
|
41
41
|
default_config :memory, '512'
|
42
42
|
default_config :nic_model, 'virtio'
|
43
43
|
|
44
|
-
required_config :image do |
|
44
|
+
required_config :image do |_attr, value, _subject|
|
45
45
|
raise UserError, 'Must specify image file' unless value
|
46
46
|
end
|
47
47
|
|
@@ -57,7 +57,7 @@ module Kitchen
|
|
57
57
|
def finalize_config!(instance)
|
58
58
|
super
|
59
59
|
if not config[:binary]
|
60
|
-
config[:binary] = @@
|
60
|
+
config[:binary] = @@ARCHBINARY[config[:arch]] or
|
61
61
|
raise UserError, "Unknown architecture '#{config[:arch]}'"
|
62
62
|
end
|
63
63
|
config[:vga] = 'qxl' if config[:spice] && !config[:vga]
|
@@ -69,7 +69,7 @@ module Kitchen
|
|
69
69
|
# @param state [Hash] mutable instance and driver state
|
70
70
|
# @raise [ActionFailed] if the action could not be completed
|
71
71
|
def create(state)
|
72
|
-
monitor =
|
72
|
+
monitor = monitor_qmp_path
|
73
73
|
if File.exist?(monitor)
|
74
74
|
begin
|
75
75
|
mon = UNIXSocket.new(monitor)
|
@@ -95,8 +95,10 @@ module Kitchen
|
|
95
95
|
cmd = [
|
96
96
|
config[:binary], '-daemonize',
|
97
97
|
'-display', config[:display].to_s,
|
98
|
-
'-chardev', "socket,id=
|
99
|
-
'-mon', 'chardev=
|
98
|
+
'-chardev', "socket,id=mon-qmp,path=#{monitor},server,nowait",
|
99
|
+
'-mon', 'chardev=mon-qmp,mode=control,default',
|
100
|
+
'-chardev', "socket,id=mon-rdl,path=#{monitor_readline_path},server,nowait",
|
101
|
+
'-mon', 'chardev=mon-rdl,mode=readline',
|
100
102
|
'-m', config[:memory].to_s,
|
101
103
|
'-net', "nic,model=#{config[:nic_model]}",
|
102
104
|
'-net', "user,net=192.168.1.0/24,hostname=#{hostname},hostfwd=tcp::#{state[:port]}-:22",
|
@@ -150,9 +152,9 @@ module Kitchen
|
|
150
152
|
info 'Waiting for SSH..'
|
151
153
|
conn = instance.transport.connection(state)
|
152
154
|
conn.wait_until_ready
|
153
|
-
conn.execute("sudo sh -c 'echo 127.0.0.1 #{names} >> /etc/hosts' 2>/dev/null")
|
155
|
+
conn.execute("sudo sh -c 'echo 127.0.0.1 #{names} >> /etc/hosts; hostnamectl set-hostname #{hostname} || hostname #{hostname} || true' 2>/dev/null")
|
154
156
|
conn.execute('install -dm700 "$HOME/.ssh"')
|
155
|
-
conn.execute("echo '#{@@
|
157
|
+
conn.execute("echo '#{@@PUBKEY}' > \"$HOME/.ssh/authorized_keys\"")
|
156
158
|
conn.close
|
157
159
|
state[:ssh_key] = privkey_path
|
158
160
|
end
|
@@ -162,7 +164,7 @@ module Kitchen
|
|
162
164
|
# @param state [Hash] mutable instance state
|
163
165
|
# @raise [ActionFailed] if the action could not be completed
|
164
166
|
def destroy(state)
|
165
|
-
monitor =
|
167
|
+
monitor = monitor_qmp_path
|
166
168
|
return unless File.exist?(monitor)
|
167
169
|
|
168
170
|
instance.transport.connection(state).close
|
@@ -185,7 +187,7 @@ module Kitchen
|
|
185
187
|
|
186
188
|
private
|
187
189
|
|
188
|
-
@@
|
190
|
+
@@PRIVKEY = %{-----BEGIN RSA PRIVATE KEY-----
|
189
191
|
MIIEowIBAAKCAQEAyG6ASL3bWS67rsA5LDvKnfdCBagK61B5LIr+NvdjK3oRKhCq
|
190
192
|
qRs7aNSPOqMu2NbKot4/BtD0hWipF7CAsMqK+241coMUwxRTlqvoe/L7xZ24Ktaj
|
191
193
|
rm1kk/xNUGP5vWyK8sYfYnDUuLSypRaZ/ZfWuKZgQLDdOw2FWqHFVLoJDsXgsa/y
|
@@ -214,9 +216,9 @@ tY4IM9IaSC2LuPFVc0Kx6TwObdeQScOokIxL3HfayfLKieTLC+w2
|
|
214
216
|
-----END RSA PRIVATE KEY-----
|
215
217
|
}.freeze
|
216
218
|
|
217
|
-
@@
|
219
|
+
@@PUBKEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIboBIvdtZLruuwDksO8qd90IFqArrUHksiv4292MrehEqEKqpGzto1I86oy7Y1sqi3j8G0PSFaKkXsICwyor7bjVygxTDFFOWq+h78vvFnbgq1qOubWST/E1QY/m9bIryxh9icNS4tLKlFpn9l9a4pmBAsN07DYVaocVUugkOxeCxr/KLUXdvmXj4Xfq837ultL1ggyaN2YqeDwn+GxM8RNm51rIRa4DL6Y1rPgztm3FL+A9MglzEjELbs8s6EDVewAG6do1HwS3LqCGxlfZgRieelzIHkyaqLRU4mzqbkhmfaR/U/fHQppRDYWb3CoCSBilJxxYfjLK1VDyXOWkH kitchen-qemu'.freeze
|
218
220
|
|
219
|
-
@@
|
221
|
+
@@ARCHBINARY = {
|
220
222
|
'i386' => 'qemu-system-i386',
|
221
223
|
'amd64' => 'qemu-system-x86_64',
|
222
224
|
'x86' => 'qemu-system-i386',
|
@@ -229,19 +231,28 @@ tY4IM9IaSC2LuPFVc0Kx6TwObdeQScOokIxL3HfayfLKieTLC+w2
|
|
229
231
|
File.join(config[:kitchen_root], '.kitchen', 'kitchen-qemu.key')
|
230
232
|
end
|
231
233
|
|
232
|
-
def
|
234
|
+
def monitor_qmp_path
|
235
|
+
File.join(config[:kitchen_root], '.kitchen', "#{instance.name}.qmp")
|
236
|
+
end
|
237
|
+
|
238
|
+
def monitor_readline_path
|
233
239
|
File.join(config[:kitchen_root], '.kitchen', "#{instance.name}.mon")
|
234
240
|
end
|
235
241
|
|
236
242
|
def create_privkey
|
237
243
|
path = privkey_path
|
238
244
|
return true if File.file?(path)
|
239
|
-
File.open(path, File::CREAT|File::TRUNC|File::RDWR, 0600) { |f| f.write(@@
|
245
|
+
File.open(path, File::CREAT|File::TRUNC|File::RDWR, 0600) { |f| f.write(@@PRIVKEY) }
|
240
246
|
end
|
241
247
|
|
242
248
|
def cleanup!
|
243
249
|
begin
|
244
|
-
File.delete(
|
250
|
+
File.delete(monitor_qmp_path)
|
251
|
+
rescue Errno::ENOENT
|
252
|
+
# do nothing
|
253
|
+
end
|
254
|
+
begin
|
255
|
+
File.delete(monitor_readline_path)
|
245
256
|
rescue Errno::ENOENT
|
246
257
|
# do nothing
|
247
258
|
end
|
@@ -46,13 +46,13 @@ module Kitchen
|
|
46
46
|
def wait_for_eof(timeout = @timeout)
|
47
47
|
while IO.select(@ioa, nil, nil, timeout)
|
48
48
|
begin
|
49
|
-
@io.read_nonblock(4096)
|
49
|
+
loop { @io.read_nonblock(4096) }
|
50
50
|
rescue EOFError
|
51
51
|
return
|
52
52
|
rescue Errno::ECONNRESET
|
53
53
|
return
|
54
54
|
rescue IO::WaitReadable
|
55
|
-
# do
|
55
|
+
# do nothing
|
56
56
|
end
|
57
57
|
end
|
58
58
|
raise Timeout
|
@@ -84,7 +84,7 @@ module Kitchen
|
|
84
84
|
begin
|
85
85
|
@buf.push(@io.read_nonblock(4096))
|
86
86
|
rescue IO::WaitReadable
|
87
|
-
# do
|
87
|
+
# do nothing
|
88
88
|
else
|
89
89
|
break
|
90
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-qemu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Renner Berthing
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|