Improve log message when image verification failed

Openstack driver compares the checksum of the software image created
using glance client with the checksum provided in the VNFD. This
patch improves the log message when such comparison is failed. Now it
logs the checksum provided in the VNFD as well as checksum calculated
by glance.

Change-Id: Ibf5ba175fc3976ba2ea0e29d29d07d899ffaa2d2
This commit is contained in:
Prashant Bhole 2020-05-27 02:39:38 +00:00
parent 42a9456cbd
commit 1d1b2a7e9e
1 changed files with 13 additions and 6 deletions

View File

@ -647,8 +647,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
if is_url:
glance_client.import_image(image, image_path)
self._image_create_wait(image.id, vnf_sw_image.hash,
glance_client, 'active', vnflcm.ImageCreateWaitFailed)
self._image_create_wait(image.id, vnf_sw_image, glance_client,
'active', vnflcm.ImageCreateWaitFailed)
vnf_resource = objects.VnfResource(context=context,
vnf_instance_id=vnf_instance.id,
@ -680,7 +680,7 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
return vnf_resources
def _image_create_wait(self, image_uuid, hash_value, glance_client,
def _image_create_wait(self, image_uuid, vnf_software_image, glance_client,
expected_status, exception_class):
retries = self.IMAGE_RETRIES
@ -692,9 +692,16 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
# NOTE(tpatil): If image is uploaded using import_image
# ,sdk doesn't validate checksum. So, verify checksum/hash
# for both scenarios upload from file and URL here.
if hash_value != image.hash_value:
msg = 'Image %s checksum verification failed'
raise Exception(msg % image_uuid)
if vnf_software_image.hash != image.hash_value:
msg = ("Image %(image_uuid)s checksum verification failed."
" Glance calculated checksum is %(hash_algo)s:"
"%(hash_value)s. Checksum in VNFD is "
"%(image_hash_algo)s:%(image_hash_value)s.")
raise Exception(msg % {"image_uuid": image_uuid,
"hash_algo": image.hash_algo,
"hash_value": image.hash_value,
"image_hash_algo": vnf_software_image.algorithm,
"image_hash_value": vnf_software_image.hash})
LOG.debug('Image status: %(image_uuid)s %(status)s',
{'image_uuid': image_uuid, 'status': status})