'Creates volume from image using HttpNfc VM import.
Uses Nfc API to download the VMDK file from Glance. Nfc creates the
backing VM that wraps the VMDK in the vCenter inventory.
This method assumes glance image is VMDK disk format and its
vmware_disktype is \'streamOptimized\'.'

def _fetch_stream_optimized_image(self, context, volume, image_service, image_id, image_size, adapter_type):

    try:
        (_host, rp, folder, summary) = self._select_ds_for_volume(volume)
    except exceptions.VimException as excep:
        err_msg = (_('Exception    in    _select_ds_for_volume:    %s.'), excep)
        raise exception.VolumeBackendAPIException(data=err_msg)
    size_gb = volume['size']
    LOG.debug('Selected    datastore    %(ds)s    for    new    volume    of    size    %(size)s    GB.', {'ds': summary.name, 'size': size_gb})
    profile_id = self._get_storage_profile_id(volume)
    disk_type = VMwareVcVmdkDriver._get_disk_type(volume)
    dummy_disk_size = 0
    extra_config = self._get_extra_config(volume)
    vm_create_spec = self.volumeops.get_create_spec(volume['name'], dummy_disk_size, disk_type, summary.name, profile_id=profile_id, adapter_type=adapter_type, extra_config=extra_config)
    cf = self.session.vim.client.factory
    vm_import_spec = cf.create('ns0:VirtualMachineImportSpec')
    vm_import_spec.configSpec = vm_create_spec
    try:
        timeout = self.configuration.vmware_image_transfer_timeout_secs
        host_ip = self.configuration.vmware_host_ip
        port = self.configuration.vmware_host_port
        LOG.debug('Fetching    glance    image:    %(id)s    to    server:    %(host)s.', {'id': image_id, 'host': host_ip})
        backing = image_transfer.download_stream_optimized_image(context, timeout, image_service, image_id, session=self.session, host=host_ip, port=port, resource_pool=rp, vm_folder=folder, vm_import_spec=vm_import_spec, image_size=image_size)
        self.volumeops.update_backing_disk_uuid(backing, volume['id'])
    except (exceptions.VimException, exceptions.VMwareDriverException):
        with excutils.save_and_reraise_exception():
            LOG.exception('Error    occurred    while    copying    image:    %(id)s    to    volume:    %(vol)s.', {'id': image_id, 'vol': volume['name']})
            backing = self.volumeops.get_backing(volume['name'])
            if backing:
                self.volumeops.delete_backing(backing)
    LOG.info('Done    copying    image:    %(id)s    to    volume:    %(vol)s.', {'id': image_id, 'vol': volume['name']})
