summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-02-22 21:43:31 +0000
committerGerrit Code Review <review@openstack.org>2012-02-22 21:43:31 +0000
commit1ef939bf40e18a73cfce2d8bc039211ae044c379 (patch)
tree859e18c4b08d3c8e2c4e8a7c82440707b48ba04a /nova/virt
parent7427454d71006f4b14683e630c8e6c834f7cb950 (diff)
parent0a8546c7d142acd2a1e68de7a36b71a3680ab0e1 (diff)
Merge "Improve unit test coverage per bug/934566."
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/libvirt/imagecache.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py
index 6226e8d4e..bd4da528f 100644
--- a/nova/virt/libvirt/imagecache.py
+++ b/nova/virt/libvirt/imagecache.py
@@ -107,6 +107,10 @@ class ImageCacheManager(object):
self.image_popularity = {}
self.instance_names = {}
+ self.removable_base_files = []
+ self.active_base_files = []
+ self.corrupt_base_files = []
+
def _store_image(self, base_dir, ent, original=False):
"""Store a base image for later examination."""
entpath = os.path.join(base_dir, ent)
@@ -290,7 +294,6 @@ class ImageCacheManager(object):
def _handle_base_image(self, img, base_file):
"""Handle the checks for a single base image."""
- # TODO(mikal): Write a unit test for this method
image_bad = False
image_in_use = False
@@ -301,7 +304,11 @@ class ImageCacheManager(object):
if base_file in self.unexplained_images:
self.unexplained_images.remove(base_file)
- self._verify_checksum(img, base_file)
+
+ if (base_file and os.path.exists(base_file)
+ and os.path.isfile(base_file)):
+ # _verify_checksum returns True if the checksum is ok.
+ image_bad = not self._verify_checksum(img, base_file)
instances = []
if str(img['id']) in self.used_images:
@@ -332,8 +339,7 @@ class ImageCacheManager(object):
else:
LOG.debug(_('%(container_format)s-%(id)s (%(base_file)s): '
- 'in: on other nodes (%(remote)d on other '
- 'nodes)'),
+ 'in use on (%(remote)d on other nodes)'),
{'container_format': img['container_format'],
'id': img['id'],
'base_file': base_file,