diff options
| author | Scott Moser <smoser@brickies.net> | 2017-11-29 15:26:38 -0500 |
|---|---|---|
| committer | Scott Moser <smoser@brickies.net> | 2017-11-29 15:26:38 -0500 |
| commit | 88368f9851b29dddb5a12e4b21868cbdef906c5c (patch) | |
| tree | bc82164948ace765b43dd2edbc7054331de2c7ca /tests/cloud_tests/images | |
| parent | 4964fb38f11c15ed119ff4c7f4379ae3c8785a9a (diff) | |
| download | vyos-cloud-init-88368f9851b29dddb5a12e4b21868cbdef906c5c.tar.gz vyos-cloud-init-88368f9851b29dddb5a12e4b21868cbdef906c5c.zip | |
tests: NoCloudKVMImage do not modify the original local cache image.
The NoCloudKVMImage.execute() would modify the image in /srv/citest
that meant that after the first time you ran a test, the image was
dirty.
The change here is to make the image operate on a qcow backed image.
Also modify Snapshot to then copy the qcow rather
than creating another chained qcow. The reason being that the image
might go away or change after the snapshot has been returned.
Also
* drop use of 'override_templates' which was only relevant to LXD.
* NoCloudKVM.create_image() returned an instance before
now it has create_instance which creates an instance.
* NoCloudKVMInstance has a 'disk' attribute separate from 'name'
Diffstat (limited to 'tests/cloud_tests/images')
| -rw-r--r-- | tests/cloud_tests/images/nocloudkvm.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/cloud_tests/images/nocloudkvm.py b/tests/cloud_tests/images/nocloudkvm.py index 1e7962cb..8678b07f 100644 --- a/tests/cloud_tests/images/nocloudkvm.py +++ b/tests/cloud_tests/images/nocloudkvm.py @@ -4,6 +4,10 @@ from cloudinit import util as c_util +import os +import shutil +import tempfile + from tests.cloud_tests.images import base from tests.cloud_tests.snapshots import nocloudkvm as nocloud_kvm_snapshot @@ -13,7 +17,7 @@ class NoCloudKVMImage(base.Image): platform_name = "nocloud-kvm" - def __init__(self, platform, config, img_path): + def __init__(self, platform, config, orig_img_path): """Set up image. @param platform: platform object @@ -21,7 +25,13 @@ class NoCloudKVMImage(base.Image): @param img_path: path to the image """ self.modified = False - self._img_path = img_path + self._workd = tempfile.mkdtemp(prefix='NoCloudKVMImage') + self._orig_img_path = orig_img_path + self._img_path = os.path.join(self._workd, + os.path.basename(self._orig_img_path)) + + c_util.subp(['qemu-img', 'create', '-f', 'qcow2', + '-b', orig_img_path, self._img_path]) super(NoCloudKVMImage, self).__init__(platform, config) @@ -61,13 +71,9 @@ class NoCloudKVMImage(base.Image): if not self._img_path: raise RuntimeError() - instance = self.platform.create_image( - self.properties, self.config, self.features, - self._img_path, image_desc=str(self), use_desc='snapshot') - return nocloud_kvm_snapshot.NoCloudKVMSnapshot( self.platform, self.properties, self.config, - self.features, instance) + self.features, self._img_path) def destroy(self): """Unset path to signal image is no longer used. @@ -77,6 +83,8 @@ class NoCloudKVMImage(base.Image): framework decide whether to keep or destroy everything. """ self._img_path = None + shutil.rmtree(self._workd) + super(NoCloudKVMImage, self).destroy() # vi: ts=4 expandtab |
