'Modify the given image with the new data.'

def update(self, context, image_id, image_meta, data=None, purge_props=True):

    if ((CONF.glance_api_version > 1) and purge_props):
        props_to_update = image_meta.get('properties', {}).keys()
    image_meta = self._translate_to_glance(image_meta)
    if (CONF.glance_api_version == 1):
        image_meta['purge_props'] = purge_props
    image_meta.pop('id', None)
    try:
        if (CONF.glance_api_version > 1):
            if data:
                self._client.call(context, 'upload', image_id, data)
            if image_meta:
                if purge_props:
                    cur_image_meta = self.show(context, image_id)
                    cur_props = cur_image_meta['properties'].keys()
                    remove_props = list((set(cur_props) - set(props_to_update)))
                    image_meta['remove_props'] = remove_props
                image_meta = self._client.call(context, 'update', image_id, **image_meta)
            else:
                image_meta = self._client.call(context, 'get', image_id)
        else:
            if data:
                image_meta['data'] = data
            image_meta = self._client.call(context, 'update', image_id, **image_meta)
    except Exception:
        _reraise_translated_image_exception(image_id)
    else:
        return self._translate_from_glance(context, image_meta)
