def upload_image(context, image, instance, **kwargs):
 LOG.debug((_('Uploading image %s to the Glance image server') % image), instance=instance)
 read_file_handle = read_write_util.VMwareHTTPReadFile(kwargs.get('host'), kwargs.get('data_center_name'), kwargs.get('datastore_name'), kwargs.get('cookies'), kwargs.get('file_path'))
 file_size = read_file_handle.get_size()
 (image_service, image_id) = glance.get_remote_image_service(context, image)
 image_metadata = {'disk_format': 'vmdk', 'is_public': 'false', 'name': kwargs.get('snapshot_name'), 'status': 'active', 'container_format': 'bare', 'size': file_size, 'properties': {'vmware_adaptertype': kwargs.get('adapter_type'), 'vmware_ostype': kwargs.get('os_type'), 'vmware_image_version': kwargs.get('image_version'), 'owner_id': instance['project_id']}}
 start_transfer(context, read_file_handle, file_size, image_service=image_service, image_id=image_id, image_meta=image_metadata)
 LOG.debug((_('Uploaded image %s to the Glance image server') % image), instance=instance)

def upload_image ( context , image , instance , ** kwargs ) : LOG . debug ( ( _ ( 'Uploading image %s to the Glance image server' ) % image ) , instance = instance ) read_file_handle = read_write_util . VMwareHTTPReadFile ( kwargs . get ( 'host' ) , kwargs . get ( 'data_center_name' ) , kwargs . get ( 'datastore_name' ) , kwargs . get ( 'cookies' ) , kwargs . get ( 'file_path' ) ) file_size = read_file_handle . get_size ( ) ( image_service , image_id ) = glance . get_remote_image_service ( context , image ) image_metadata = { 'disk_format' : 'vmdk' , 'is_public' : 'false' , 'name' : kwargs . get ( 'snapshot_name' ) , 'status' : 'active' , 'container_format' : 'bare' , 'size' : file_size , 'properties' : { 'vmware_adaptertype' : kwargs . get ( 'adapter_type' ) , 'vmware_ostype' : kwargs . get ( 'os_type' ) , 'vmware_image_version' : kwargs . get ( 'image_version' ) , 'owner_id' : instance [ 'project_id' ] } } start_transfer ( context , read_file_handle , file_size , image_service = image_service , image_id = image_id , image_meta = image_metadata ) LOG . debug ( ( _ ( 'Uploaded image %s to the Glance image server' ) % image ) , instance = instance )
upload the snapshotted vm disk file to glance image server .