Comment 14 for bug 1933966

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Glance itself is returning an MD5 hash so that would need to change before simplestreams:
https://docs.openstack.org/glance/latest/user/glanceapi.html

The code using the glance api is in the validate_image() function from simplestreams:

    https://git.launchpad.net/simplestreams/tree/simplestreams/mirrors/glance.py#n515

    def validate_image(self, image_id, checksum, size, delete=True):
        """Validate an image's checksum and size after upload.

        Check for expected checksum and size.
        Throw an IOError if they do not match.

        :param image_id: str Glance Image ID
        :param checksum: str Expected MD5 sum of the image
        :param size: int Expected size in bytes of the image
        :returns: None
        """
        if not isinstance(size, util.INTEGER_TYPES):
            raise TypeError("size '%s' is not an integer" % str(size))
        found = self.gclient.images.get(image_id)
        if found.size == size and found.checksum == checksum:
            return
        msg = (
            ("Invalid glance image: %s. " % image_id) +
            ("Expected size=%s md5=%s. Found size=%s md5=%s." %
             (size, checksum, found.size, found.checksum)))
        if delete:
            LOG.warning("Deleting image %s: %s", image_id, msg)
            self.gclient.images.delete(image_id)
        raise IOError(msg)