def copy_volume_to_image(self, context, volume_id, image_meta):
    "Uploads the specified volume to Glance.\n\n        image_meta is a dictionary containing the following keys:\n        'id', 'container_format', 'disk_format'\n\n        "
    payload = {'volume_id': volume_id, 'image_id': image_meta['id']}
    image_service = None
    try:
        volume = self.db.volume_get(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(_LE('Upload volume to image encountered an error (image-id: %(image_id)s).'), {'image_id': image_meta['id']}, resource=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)
            if isinstance(error, exception.ImageLimitExceeded):
                self.message_api.create(context, defined_messages.IMAGE_FROM_VOLUME_OVER_QUOTA, context.project_id, resource_type=resource_types.VOLUME, resource_uuid=volume_id)
    finally:
        self.db.volume_update_status_based_on_attachment(context, volume_id)
    LOG.info(_LI('Copy volume to image completed successfully.'), resource=volume)
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):
    "Uploads the specified volume to Glance.\n\n        image_meta is a dictionary containing the following keys:\n        'id', 'container_format', 'disk_format'\n\n        "
    payload = {'volume_id': volume_id, 'image_id': image_meta['id']}
    image_service = None
    try:
        volume = self.db.volume_get(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(_LE('Upload volume to image encountered an error (image-id: %(image_id)s).'), {'image_id': image_meta['id']}, resource=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)
            if isinstance(error, exception.ImageLimitExceeded):
                self.message_api.create(context, defined_messages.IMAGE_FROM_VOLUME_OVER_QUOTA, context.project_id, resource_type=resource_types.VOLUME, resource_uuid=volume_id)
    finally:
        self.db.volume_update_status_based_on_attachment(context, volume_id)
    LOG.info(_LI('Copy volume to image completed successfully.'), resource=volume)