From 1d1b2a7e9ec106c4c108b674b6d8e4085548626f Mon Sep 17 00:00:00 2001 From: Prashant Bhole Date: Wed, 27 May 2020 02:39:38 +0000 Subject: [PATCH] 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 --- .../vnfm/infra_drivers/openstack/openstack.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tacker/vnfm/infra_drivers/openstack/openstack.py b/tacker/vnfm/infra_drivers/openstack/openstack.py index 0d7ca22a1..21dc4a984 100644 --- a/tacker/vnfm/infra_drivers/openstack/openstack.py +++ b/tacker/vnfm/infra_drivers/openstack/openstack.py @@ -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})