'Updates Registry\'s information about an image'

def update_image(self, image_id, image_metadata, purge_props=False, from_state=None):

    if ('image' not in image_metadata):
        image_metadata = dict(image=image_metadata)
    encrypted_metadata = self.encrypt_metadata(image_metadata['image'])
    image_metadata['image'] = encrypted_metadata
    image_metadata['from_state'] = from_state
    body = jsonutils.dump_as_bytes(image_metadata)
    headers = {'Content-Type': 'application/json'}
    if purge_props:
        headers['X-Glance-Registry-Purge-Props'] = 'true'
    res = self.do_request('PUT', ('/images/%s' % image_id), body=body, headers=headers)
    data = jsonutils.loads(res.read())
    image = data['image']
    return self.decrypt_metadata(image)
