'Creates glance image from volume.
Upload of only available volume is supported. The uploaded glance image
has a vmdk disk type of "streamOptimized" that can only be downloaded
using the HttpNfc API.
Steps followed are:
1. Get the name of the vmdk file which the volume points to right
now. Can be a chain of snapshots, so we need to know the last in the
chain.
2. Use Nfc APIs to upload the contents of the vmdk file to glance.'

def copy_volume_to_image(self, context, volume, image_service, image_meta):

    if self._in_use(volume):
        msg = _('Upload    to    glance    of    attached    volume    is    not    supported.')
        LOG.error(msg)
        raise exception.InvalidVolume(msg)
    LOG.debug('Copy    Volume:    %s    to    new    image.', volume['name'])
    VMwareVcVmdkDriver._validate_disk_format(image_meta['disk_format'])
    backing = self.volumeops.get_backing(volume['name'])
    if (not backing):
        LOG.info('Backing    not    found,    creating    for    volume:    %s', volume['name'])
        backing = self._create_backing(volume)
    vmdk_file_path = self.volumeops.get_vmdk_path(backing)
    timeout = self.configuration.vmware_image_transfer_timeout_secs
    host_ip = self.configuration.vmware_host_ip
    port = self.configuration.vmware_host_port
    image_transfer.upload_image(context, timeout, image_service, image_meta['id'], volume['project_id'], session=self.session, host=host_ip, port=port, vm=backing, vmdk_file_path=vmdk_file_path, vmdk_size=(volume['size'] * units.Gi), image_name=image_meta['name'], image_version=1)
    LOG.info('Done    copying    volume    %(vol)s    to    a    new    image    %(img)s', {'vol': volume['name'], 'img': image_meta['name']})
