OLD | NEW |
1 import os, logging | 1 import os, logging |
2 from autotest_lib.client.common_lib import error | 2 from autotest_lib.client.common_lib import error |
3 from autotest_lib.client.bin import utils | 3 from autotest_lib.client.bin import utils |
4 import kvm_utils | 4 from autotest_lib.client.virt import virt_utils |
5 | 5 |
6 | 6 |
7 def run_image_copy(test, params, env): | 7 def run_image_copy(test, params, env): |
8 """ | 8 """ |
9 Copy guest images from nfs server. | 9 Copy guest images from nfs server. |
10 1) Mount the NFS share directory | 10 1) Mount the NFS share directory |
11 2) Check the existence of source image | 11 2) Check the existence of source image |
12 3) If it exists, copy the image from NFS | 12 3) If it exists, copy the image from NFS |
13 | 13 |
14 @param test: kvm test object | 14 @param test: kvm test object |
(...skipping 11 matching lines...) Expand all Loading... |
26 raise error.TestError('Failed to create NFS share dir %s' % | 26 raise error.TestError('Failed to create NFS share dir %s' % |
27 mount_dest_dir) | 27 mount_dest_dir) |
28 | 28 |
29 src = params.get('images_good') | 29 src = params.get('images_good') |
30 image = '%s.%s' % (os.path.split(params['image_name'])[1], | 30 image = '%s.%s' % (os.path.split(params['image_name'])[1], |
31 params['image_format']) | 31 params['image_format']) |
32 src_path = os.path.join(mount_dest_dir, image) | 32 src_path = os.path.join(mount_dest_dir, image) |
33 dst_path = '%s.%s' % (params['image_name'], params['image_format']) | 33 dst_path = '%s.%s' % (params['image_name'], params['image_format']) |
34 cmd = 'cp %s %s' % (src_path, dst_path) | 34 cmd = 'cp %s %s' % (src_path, dst_path) |
35 | 35 |
36 if not kvm_utils.mount(src, mount_dest_dir, 'nfs', 'ro'): | 36 if not virt_utils.mount(src, mount_dest_dir, 'nfs', 'ro'): |
37 raise error.TestError('Could not mount NFS share %s to %s' % | 37 raise error.TestError('Could not mount NFS share %s to %s' % |
38 (src, mount_dest_dir)) | 38 (src, mount_dest_dir)) |
39 | 39 |
40 # Check the existence of source image | 40 # Check the existence of source image |
41 if not os.path.exists(src_path): | 41 if not os.path.exists(src_path): |
42 raise error.TestError('Could not find %s in NFS share' % src_path) | 42 raise error.TestError('Could not find %s in NFS share' % src_path) |
43 | 43 |
44 logging.debug('Copying image %s...', image) | 44 logging.debug('Copying image %s...', image) |
45 utils.system(cmd) | 45 utils.system(cmd) |
OLD | NEW |