def _fetch_vhd_image(context, session, instance, image_id):
 LOG.debug('Asking xapi to fetch vhd image %s', image_id, instance=instance)
 handler = _choose_download_handler(context, instance)
 try:
  vdis = handler.download_image(context, session, instance, image_id)
 except Exception:
  default_handler = _default_download_handler()
  if (type(handler) == type(default_handler)):
   raise
  LOG.exception(_LE("Download handler '%(handler)s' raised an exception, falling back to default handler '%(default_handler)s'"), {'handler': handler, 'default_handler': default_handler})
  vdis = default_handler.download_image(context, session, instance, image_id)
 scan_default_sr(session)
 vdi_uuid = vdis['root']['uuid']
 try:
  _check_vdi_size(context, session, instance, vdi_uuid)
 except Exception:
  with excutils.save_and_reraise_exception():
   msg = 'Error while checking vdi size'
   LOG.debug(msg, instance=instance, exc_info=True)
   for vdi in vdis.values():
    vdi_uuid = vdi['uuid']
    vdi_ref = session.call_xenapi('VDI.get_by_uuid', vdi_uuid)
    safe_destroy_vdis(session, [vdi_ref])
 return vdis

def _fetch_vhd_image ( context , session , instance , image_id ) : LOG . debug ( 'Asking xapi to fetch vhd image %s' , image_id , instance = instance ) handler = _choose_download_handler ( context , instance ) try : vdis = handler . download_image ( context , session , instance , image_id ) except Exception : default_handler = _default_download_handler ( ) if ( type ( handler ) == type ( default_handler ) ) : raise LOG . exception ( _LE ( "Download handler '%(handler)s' raised an exception, falling back to default handler '%(default_handler)s'" ) , { 'handler' : handler , 'default_handler' : default_handler } ) vdis = default_handler . download_image ( context , session , instance , image_id ) scan_default_sr ( session ) vdi_uuid = vdis [ 'root' ] [ 'uuid' ] try : _check_vdi_size ( context , session , instance , vdi_uuid ) except Exception : with excutils . save_and_reraise_exception ( ) : msg = 'Error while checking vdi size' LOG . debug ( msg , instance = instance , exc_info = True ) for vdi in vdis . values ( ) : vdi_uuid = vdi [ 'uuid' ] vdi_ref = session . call_xenapi ( 'VDI.get_by_uuid' , vdi_uuid ) safe_destroy_vdis ( session , [ vdi_ref ] ) return vdis
tell glance to download an image and put the vhds into the sr returns: a list of dictionaries that describe vdis .