Add debug message about file hash calculation

When debugging image uploads, it can seem like shade has hung when it's
in fact calculating file hashes. Emit a debug message to indicate this
has been done.

Change-Id: Ib0fde6ad96de6b6ba31e5c0b1b2f1bb54aad6f1e
This commit is contained in:
Monty Taylor 2016-03-02 09:55:40 -06:00
parent c12d5020b3
commit 0f23cb8fa2

View File

@ -3686,6 +3686,8 @@ class OpenStackCloud(object):
def _get_file_hashes(self, filename):
if filename not in self._file_hash_cache:
self.log.debug(
'Calculating hashes for {filename}'.format(filename=filename))
md5 = hashlib.md5()
sha256 = hashlib.sha256()
with open(filename, 'rb') as file_obj:
@ -3694,6 +3696,11 @@ class OpenStackCloud(object):
sha256.update(chunk)
self._file_hash_cache[filename] = dict(
md5=md5.hexdigest(), sha256=sha256.hexdigest())
self.log.debug(
"Image file {filename} md5:{md5} sha256:{sha256}".format(
filename=filename,
md5=self._file_hash_cache[filename]['md5'],
sha256=self._file_hash_cache[filename]['sha256']))
return (self._file_hash_cache[filename]['md5'],
self._file_hash_cache[filename]['sha256'])