From 33d7f56cc424071a90f78ebd21913ce2bc9e6c0d Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 21 Nov 2012 22:44:32 +0000 Subject: Move imagecache code from nova.virt.libvirt.utils The imagecache related code in libvirt.utils uses the base_dir_name config option. If we move the imagecache utils into imagecache, then we can move the base_dir_name option into that module since there are no other users of it. Having all the imagecache code in the imagecache module seems like a sensible thing to do anyway. blueprint: scope-config-opts Change-Id: I1e154aa4de1628d40964207bdcbe5b3b55076442 --- nova/tests/test_imagecache.py | 22 ++++++++++++---------- nova/tests/test_libvirt.py | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index 09570204f..2a927b362 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -65,7 +65,7 @@ class ImageCacheManagerTestCase(test.TestCase): csum_input = '{"sha1": "fdghkfhkgjjksfdgjksjkghsdf"}\n' fname = os.path.join(tmpdir, 'aaa') - info_fname = virtutils.get_info_filename(fname) + info_fname = imagecache.get_info_filename(fname) f = open(info_fname, 'w') f.write(csum_input) f.close() @@ -91,7 +91,8 @@ class ImageCacheManagerTestCase(test.TestCase): timestamped=False) self.assertEquals(csum_output, 'fdghkfhkgjjksfdgjksjkghsdf') self.assertFalse(os.path.exists(old_fname)) - self.assertTrue(os.path.exists(virtutils.get_info_filename(fname))) + info_fname = imagecache.get_info_filename(fname) + self.assertTrue(os.path.exists(info_fname)) def test_list_base_images(self): listing = ['00000001', @@ -352,7 +353,7 @@ class ImageCacheManagerTestCase(test.TestCase): 'operating system.') fname = os.path.join(tmpdir, 'aaa') - info_fname = virtutils.get_info_filename(fname) + info_fname = imagecache.get_info_filename(fname) with open(fname, 'w') as f: f.write(testdata) @@ -525,7 +526,7 @@ class ImageCacheManagerTestCase(test.TestCase): with self._make_base_file() as fname: image_cache_manager = imagecache.ImageCacheManager() image_cache_manager._remove_base_file(fname) - info_fname = virtutils.get_info_filename(fname) + info_fname = imagecache.get_info_filename(fname) # Files are initially too new to delete self.assertTrue(os.path.exists(fname)) @@ -543,7 +544,7 @@ class ImageCacheManagerTestCase(test.TestCase): image_cache_manager = imagecache.ImageCacheManager() image_cache_manager.originals = [fname] image_cache_manager._remove_base_file(fname) - info_fname = virtutils.get_info_filename(fname) + info_fname = imagecache.get_info_filename(fname) # Files are initially too new to delete self.assertTrue(os.path.exists(fname)) @@ -873,12 +874,13 @@ class ImageCacheManagerTestCase(test.TestCase): '%(image)s.info')) base_filename = os.path.join(CONF.instances_path, '_base', hashed) - self.assertFalse(virtutils.is_valid_info_file('banana')) - self.assertFalse(virtutils.is_valid_info_file( + is_valid_info_file = imagecache.is_valid_info_file + self.assertFalse(is_valid_info_file('banana')) + self.assertFalse(is_valid_info_file( os.path.join(CONF.instances_path, '_base', '00000001'))) - self.assertFalse(virtutils.is_valid_info_file(base_filename)) - self.assertFalse(virtutils.is_valid_info_file(base_filename + '.sha1')) - self.assertTrue(virtutils.is_valid_info_file(base_filename + '.info')) + self.assertFalse(is_valid_info_file(base_filename)) + self.assertFalse(is_valid_info_file(base_filename + '.sha1')) + self.assertTrue(is_valid_info_file(base_filename + '.info')) def test_configured_checksum_path(self): with utils.tempdir() as tmpdir: diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 768406e9c..c19f72dae 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -73,6 +73,7 @@ CONF = cfg.CONF CONF.import_opt('compute_manager', 'nova.config') CONF.import_opt('host', 'nova.config') CONF.import_opt('my_ip', 'nova.config') +CONF.import_opt('base_dir_name', 'nova.virt.libvirt.imagecache') LOG = logging.getLogger(__name__) _fake_network_info = fake_network.fake_get_instance_nw_info -- cgit