'Uploads the specified volume to Glance.
image_meta is a dictionary containing the following keys:
\'id\', \'container_format\', \'disk_format\''

def copy_volume_to_image(self, context, volume_id, image_meta):

    payload = {'volume_id': volume_id, 'image_id': image_meta['id']}
    image_service = None
    try:
        volume = objects.Volume.get_by_id(context, volume_id)
        utils.require_driver_initialized(self.driver)
        (image_service, image_id) = glance.get_remote_image_service(context, image_meta['id'])
        if (self.driver.configuration.image_upload_use_cinder_backend and self._clone_image_volume_and_add_location(context, volume, image_service, image_meta)):
            LOG.debug('Registered    image    volume    location    to    glance    image-id:    %(image_id)s.', {'image_id': image_meta['id']}, resource=volume)
        else:
            self.driver.copy_volume_to_image(context, volume, image_service, image_meta)
            LOG.debug('Uploaded    volume    to    glance    image-id:    %(image_id)s.', {'image_id': image_meta['id']}, resource=volume)
    except Exception as error:
        LOG.error('Upload    volume    to    image    encountered    an    error    (image-id:    %(image_id)s).', {'image_id': image_meta['id']}, resource=volume)
        self.message_api.create(context, message_field.Action.COPY_VOLUME_TO_IMAGE, resource_uuid=volume_id, exception=error, detail=message_field.Detail.FAILED_TO_UPLOAD_VOLUME)
        if (image_service is not None):
            self._delete_image(context, image_meta['id'], image_service)
        with excutils.save_and_reraise_exception():
            payload['message'] = six.text_type(error)
    finally:
        self.db.volume_update_status_based_on_attachment(context, volume_id)
    LOG.info('Copy    volume    to    image    completed    successfully.', resource=volume)
