blueprint nova-image-cache-management phase1
Phase 1 of the image-cache-management blueprint. Implement checksumming and verification of base images, as well as removal of base images which are not in use. Removal is enabled with a flag. Change-Id: Ib04a02075a103c2fef6716fd0ac87c41a3535d37
This commit is contained in:
parent
8e29ebf66c
commit
53a5f66576
@ -22,6 +22,7 @@
|
||||
import contextlib
|
||||
import datetime
|
||||
import functools
|
||||
import hashlib
|
||||
import inspect
|
||||
import json
|
||||
import lockfile
|
||||
@ -1194,6 +1195,13 @@ def read_cached_file(filename, cache_info, reload_func=None):
|
||||
return cache_info['data']
|
||||
|
||||
|
||||
def hash_file(file_like_object):
|
||||
"""Generate a hash for the contents of a file."""
|
||||
checksum = hashlib.sha1()
|
||||
any(map(checksum.update, iter(lambda: file_like_object.read(32768), '')))
|
||||
return checksum.hexdigest()
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def temporary_mutation(obj, **kwargs):
|
||||
"""Temporarily set the attr on a particular object to a given value then
|
||||
|
Loading…
x
Reference in New Issue
Block a user