docs: def verify_image_checksum(image_location, expected_checksum):
      """Verifies checksum (md5) of image file against the expected one.
  
      This method generates the checksum of the image file on the fly and
      verifies it against the expected checksum provided as argument.
  
      :param image_location: location of image file whose checksum is verified.
      :param expected_checksum: checksum to be checked against
      :raises: ImageRefValidationFailed, if invalid file path or
               verification fails.
      """
      try:
          with open(image_location, 'rb') as fd:
              actual_checksum = hash_file(fd)
      except IOError as e:
          raise exception.ImageRefValidationFailed(image_href=image_location,
                                                   reason=e)
  
      if actual_checksum != expected_checksum:
          msg = ('Error verifying image checksum. Image %(image)s failed to '
                 'verify against checksum %(checksum)s. Actual checksum is: '
                 '%(actual_checksum)s' %
                 {'image': image_location, 'checksum': expected_checksum,
                  'actual_checksum': actual_checksum})
          raise exception.ImageRefValidationFailed(image_href=image_location,
                                                   reason=msg)