diff options
author | Zuul <zuul@review.opendev.org> | 2021-05-07 00:33:20 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-05-07 00:33:20 +0000 |
commit | aaa3853ee2d6647f92ebb7fcbeb0dd5b8f2be2d3 (patch) | |
tree | 8bf620e199358f91004900ae893ee9efefddfae2 | |
parent | 343873840b9aff18ab795239b32aa63826101de5 (diff) | |
parent | c35c9f814132e9d010844f8668b12fb7a5e7879c (diff) | |
download | cinder-aaa3853ee2d6647f92ebb7fcbeb0dd5b8f2be2d3.tar.gz |
Merge "Label temporary files created by image_utils" into stable/train
-rw-r--r-- | cinder/image/image_utils.py | 7 | ||||
-rw-r--r-- | cinder/tests/unit/test_image_utils.py | 36 |
2 files changed, 28 insertions, 15 deletions
diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py index a73d0f206..317d5747b 100644 --- a/cinder/image/image_utils.py +++ b/cinder/image/image_utils.py @@ -576,7 +576,7 @@ def fetch_to_volume_format(context, image_service, # large and cause disk full errors which would confuse users. # Unfortunately it seems that you can't pipe to 'qemu-img convert' because # it seeks. Maybe we can think of something for a future version. - with temporary_file() as tmp: + with temporary_file(prefix='image_download_%s_' % image_id) as tmp: has_meta = False if not image_meta else True try: format_raw = True if image_meta['disk_format'] == 'raw' else False @@ -687,7 +687,7 @@ def upload_volume(context, image_service, image_meta, volume_path, tpool.Proxy(image_file)) return - with temporary_file() as tmp: + with temporary_file(prefix='vol_upload_') as tmp: LOG.debug("%s was %s, converting to %s", image_id, volume_format, image_meta['disk_format']) @@ -919,7 +919,8 @@ class TemporaryImages(object): @contextlib.contextmanager def fetch(cls, image_service, context, image_id, suffix=''): tmp_images = cls.for_image_service(image_service).temporary_images - with temporary_file(suffix=suffix) as tmp: + with temporary_file(prefix='image_fetch_%s_' % image_id, + suffix=suffix) as tmp: fetch_verify_image(context, image_service, image_id, tmp) user = context.user_id if not tmp_images.get(user): diff --git a/cinder/tests/unit/test_image_utils.py b/cinder/tests/unit/test_image_utils.py index f7040ee3a..c368639f5 100644 --- a/cinder/tests/unit/test_image_utils.py +++ b/cinder/tests/unit/test_image_utils.py @@ -1111,7 +1111,8 @@ class TestFetchToVolumeFormat(test.TestCase): volume_format, blocksize) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=True), mock.call(tmp, run_as_root=True)]) @@ -1163,7 +1164,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1219,7 +1221,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1271,7 +1274,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1375,7 +1379,8 @@ class TestFetchToVolumeFormat(test.TestCase): self.assertIsNone(output) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_called_once_with(tmp, force_share=False, run_as_root=run_as_root) @@ -1422,7 +1427,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_called_once_with(tmp, force_share=False, run_as_root=run_as_root) @@ -1467,7 +1473,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_called_once_with(tmp, force_share=False, run_as_root=run_as_root) @@ -1518,7 +1525,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1566,7 +1574,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1614,7 +1623,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) image_service.show.assert_called_once_with(ctxt, image_id) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1663,7 +1673,8 @@ class TestFetchToVolumeFormat(test.TestCase): run_as_root=run_as_root) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=run_as_root), mock.call(tmp, run_as_root=run_as_root)]) @@ -1821,7 +1832,8 @@ class TestFetchToVolumeFormat(test.TestCase): volume_format, blocksize) self.assertIsNone(output) - mock_temp.assert_called_once_with() + mock_temp.assert_called_once_with(prefix='image_download_%s_' % + image_id) mock_info.assert_has_calls([ mock.call(tmp, force_share=False, run_as_root=True), mock.call(tmp, run_as_root=True)]) |