]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/207
3 # Test ssh image creation
5 # Copyright (C) 2018 Red Hat, Inc.
7 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 iotests
.verify_image_format(supported_fmts
=['raw'])
28 iotests
.verify_protocol(supported
=['ssh'])
30 def filter_hash(qmsg
):
31 def _filter(key
, value
):
32 if key
== 'hash' and re
.match('[0-9a-f]+', value
):
35 return iotests
.filter_qmp(qmsg
, _filter
)
37 def blockdev_create(vm
, options
):
38 result
= vm
.qmp_log('blockdev-create', job_id
='job0', options
=options
,
39 filters
=[iotests
.filter_qmp_testfiles
, filter_hash
])
41 if 'return' in result
:
42 assert result
['return'] == {}
46 with iotests
.FilePath('t.img') as disk_path
, \
49 remote_path
= iotests
.remote_filename(disk_path
)
52 # Successful image creation (defaults)
54 iotests
.log("=== Successful image creation (defaults) ===")
58 blockdev_create(vm
, { 'driver': 'ssh',
69 iotests
.img_info_log(remote_path
, filter_path
=disk_path
)
71 iotests
.img_info_log(disk_path
)
74 # Test host-key-check options
76 iotests
.log("=== Test host-key-check options ===")
80 blockdev_create(vm
, { 'driver': 'ssh',
94 iotests
.img_info_log(remote_path
, filter_path
=disk_path
)
97 blockdev_create(vm
, { 'driver': 'ssh',
105 'mode': 'known_hosts'
111 iotests
.img_info_log(remote_path
, filter_path
=disk_path
)
113 md5_key
= subprocess
.check_output(
114 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
115 'cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1',
116 shell
=True).rstrip().decode('ascii')
119 blockdev_create(vm
, { 'driver': 'ssh',
133 blockdev_create(vm
, { 'driver': 'ssh',
149 iotests
.img_info_log(remote_path
, filter_path
=disk_path
)
151 sha1_key
= subprocess
.check_output(
152 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
153 'cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1',
154 shell
=True).rstrip().decode('ascii')
157 blockdev_create(vm
, { 'driver': 'ssh',
171 blockdev_create(vm
, { 'driver': 'ssh',
187 iotests
.img_info_log(remote_path
, filter_path
=disk_path
)
190 # Invalid path and user
192 iotests
.log("=== Invalid path and user ===")
196 blockdev_create(vm
, { 'driver': 'ssh',
198 'path': '/this/is/not/an/existing/path',
208 blockdev_create(vm
, { 'driver': 'ssh',
211 'user': 'invalid user',