def _find_cached_image(session, image_id, sr_ref):
 name_label = _get_image_vdi_label(image_id)
 recs = session.call_xenapi('VDI.get_all_records_where', ('field "name__label"="%s"' % name_label))
 number_found = len(recs)
 if (number_found > 0):
  if (number_found > 1):
   LOG.warning(_LW('Multiple base images for image: %s'), image_id)
  return list(recs.keys())[0]

def _find_cached_image ( session , image_id , sr_ref ) : name_label = _get_image_vdi_label ( image_id ) recs = session . call_xenapi ( 'VDI.get_all_records_where' , ( 'field "name__label"="%s"' % name_label ) ) number_found = len ( recs ) if ( number_found > 0 ) : if ( number_found > 1 ) : LOG . warning ( _LW ( 'Multiple base images for image: %s' ) , image_id ) return list ( recs . keys ( ) ) [ 0 ]
returns the vdi-ref of the cached image .