def upload_image_data(self, context, img_id, data): """Upload an image.""" LOG.debug('Uploading an image to glance %s', img_id) try: return utils.upload_image_data(context, img_id, data) except Exception as e: raise exception.ZunException(six.text_type(e))
def upload_image_data(self, context, img_id, data): """Upload an image.""" LOG.debug('Uploading an image to glance %s', img_id) try: if isinstance(data, types.GeneratorType): # NOTE(kiennt): In Docker-py 3.1.0, get_image # returns generator - related bugs [1]. # These lines makes image_data readable. # [1] https://bugs.launchpad.net/zun/+bug/1753080 data = six.b('').join(data) data = six.BytesIO(data) return utils.upload_image_data(context, img_id, data) except Exception as e: raise exception.ZunException(six.text_type(e))