def fetch_image(context, instance, host, port, dc_name, ds_name, file_path, cookies=None):
 image_ref = instance.image_ref
 LOG.debug('Downloading image file data %(image_ref)s to the data store %(data_store_name)s', {'image_ref': image_ref, 'data_store_name': ds_name}, instance=instance)
 metadata = IMAGE_API.get(context, image_ref)
 file_size = int(metadata['size'])
 read_iter = IMAGE_API.download(context, image_ref)
 read_file_handle = rw_handles.ImageReadHandle(read_iter)
 write_file_handle = rw_handles.FileWriteHandle(host, port, dc_name, ds_name, cookies, file_path, file_size)
 image_transfer(read_file_handle, write_file_handle)
 LOG.debug('Downloaded image file data %(image_ref)s to %(upload_name)s on the data store %(data_store_name)s', {'image_ref': image_ref, 'upload_name': ('n/a' if (file_path is None) else file_path), 'data_store_name': ('n/a' if (ds_name is None) else ds_name)}, instance=instance)

def fetch_image ( context , instance , host , port , dc_name , ds_name , file_path , cookies = None ) : image_ref = instance . image_ref LOG . debug ( 'Downloading image file data %(image_ref)s to the data store %(data_store_name)s' , { 'image_ref' : image_ref , 'data_store_name' : ds_name } , instance = instance ) metadata = IMAGE_API . get ( context , image_ref ) file_size = int ( metadata [ 'size' ] ) read_iter = IMAGE_API . download ( context , image_ref ) read_file_handle = rw_handles . ImageReadHandle ( read_iter ) write_file_handle = rw_handles . FileWriteHandle ( host , port , dc_name , ds_name , cookies , file_path , file_size ) image_transfer ( read_file_handle , write_file_handle ) LOG . debug ( 'Downloaded image file data %(image_ref)s to %(upload_name)s on the data store %(data_store_name)s' , { 'image_ref' : image_ref , 'upload_name' : ( 'n/a' if ( file_path is None ) else file_path ) , 'data_store_name' : ( 'n/a' if ( ds_name is None ) else ds_name ) } , instance = instance )
download image from the glance image server .