def upload_image_stream_optimized(context, image_id, instance, session, vm, vmdk_size):
 LOG.debug('Uploading image %s', image_id, instance=instance)
 metadata = IMAGE_API.get(context, image_id)
 read_handle = rw_handles.VmdkReadHandle(session, session._host, session._port, vm, None, vmdk_size)
 image_metadata = {'disk_format': constants.DISK_FORMAT_VMDK, 'is_public': metadata['is_public'], 'name': metadata['name'], 'status': 'active', 'container_format': constants.CONTAINER_FORMAT_BARE, 'size': 0, 'properties': {'vmware_image_version': 1, 'vmware_disktype': 'streamOptimized', 'owner_id': instance.project_id}}
 updater = loopingcall.FixedIntervalLoopingCall(read_handle.update_progress)
 try:
  updater.start(interval=NFC_LEASE_UPDATE_PERIOD)
  IMAGE_API.update(context, image_id, image_metadata, data=read_handle)
 finally:
  updater.stop()
  read_handle.close()
 LOG.debug('Uploaded image %s to the Glance image server', image_id, instance=instance)

def upload_image_stream_optimized ( context , image_id , instance , session , vm , vmdk_size ) : LOG . debug ( 'Uploading image %s' , image_id , instance = instance ) metadata = IMAGE_API . get ( context , image_id ) read_handle = rw_handles . VmdkReadHandle ( session , session . _host , session . _port , vm , None , vmdk_size ) image_metadata = { 'disk_format' : constants . DISK_FORMAT_VMDK , 'is_public' : metadata [ 'is_public' ] , 'name' : metadata [ 'name' ] , 'status' : 'active' , 'container_format' : constants . CONTAINER_FORMAT_BARE , 'size' : 0 , 'properties' : { 'vmware_image_version' : 1 , 'vmware_disktype' : 'streamOptimized' , 'owner_id' : instance . project_id } } updater = loopingcall . FixedIntervalLoopingCall ( read_handle . update_progress ) try : updater . start ( interval = NFC_LEASE_UPDATE_PERIOD ) IMAGE_API . update ( context , image_id , image_metadata , data = read_handle ) finally : updater . stop ( ) read_handle . close ( ) LOG . debug ( 'Uploaded image %s to the Glance image server' , image_id , instance = instance )
upload the snapshotted vm disk file to glance image server .