def _find_sr(session):
 host = session.host_ref
 try:
  tokens = CONF.xenserver.sr_matching_filter.split(':')
  filter_criteria = tokens[0]
  filter_pattern = tokens[1]
 except IndexError:
  LOG.warning(_LW("Flag sr_matching_filter '%s' does not respect formatting convention"), CONF.xenserver.sr_matching_filter)
  return None
 if (filter_criteria == 'other-config'):
  (key, value) = filter_pattern.split('=', 1)
  for (sr_ref, sr_rec) in session.get_all_refs_and_recs('SR'):
   if (not ((key in sr_rec['other_config']) and (sr_rec['other_config'][key] == value))):
    continue
   for pbd_ref in sr_rec['PBDs']:
    pbd_rec = session.get_rec('PBD', pbd_ref)
    if (pbd_rec and (pbd_rec['host'] == host)):
     return sr_ref
 elif ((filter_criteria == 'default-sr') and (filter_pattern == 'true')):
  pool_ref = session.call_xenapi('pool.get_all')[0]
  sr_ref = session.call_xenapi('pool.get_default_SR', pool_ref)
  if sr_ref:
   return sr_ref
 LOG.error(_LE("XenAPI is unable to find a Storage Repository to install guest instances on. Please check your configuration (e.g. set a default SR for the pool) and/or configure the flag 'sr_matching_filter'."))
 return None

def _find_sr ( session ) : host = session . host_ref try : tokens = CONF . xenserver . sr_matching_filter . split ( ':' ) filter_criteria = tokens [ 0 ] filter_pattern = tokens [ 1 ] except IndexError : LOG . warning ( _LW ( "Flag sr_matching_filter '%s' does not respect formatting convention" ) , CONF . xenserver . sr_matching_filter ) return None if ( filter_criteria == 'other-config' ) : ( key , value ) = filter_pattern . split ( '=' , 1 ) for ( sr_ref , sr_rec ) in session . get_all_refs_and_recs ( 'SR' ) : if ( not ( ( key in sr_rec [ 'other_config' ] ) and ( sr_rec [ 'other_config' ] [ key ] == value ) ) ) : continue for pbd_ref in sr_rec [ 'PBDs' ] : pbd_rec = session . get_rec ( 'PBD' , pbd_ref ) if ( pbd_rec and ( pbd_rec [ 'host' ] == host ) ) : return sr_ref elif ( ( filter_criteria == 'default-sr' ) and ( filter_pattern == 'true' ) ) : pool_ref = session . call_xenapi ( 'pool.get_all' ) [ 0 ] sr_ref = session . call_xenapi ( 'pool.get_default_SR' , pool_ref ) if sr_ref : return sr_ref LOG . error ( _LE ( "XenAPI is unable to find a Storage Repository to install guest instances on. Please check your configuration (e.g. set a default SR for the pool) and/or configure the flag 'sr_matching_filter'." ) ) return None
return the storage repository to hold vm images .