def _find_iso_sr(session):
 host = session.host_ref
 for (sr_ref, sr_rec) in session.get_all_refs_and_recs('SR'):
  LOG.debug('ISO: looking at SR %s', sr_rec)
  if (not (sr_rec['content_type'] == 'iso')):
   LOG.debug('ISO: not iso content')
   continue
  if ('i18n-key' not in sr_rec['other_config']):
   LOG.debug("ISO: iso content_type, no 'i18n-key' key")
   continue
  if (not (sr_rec['other_config']['i18n-key'] == 'local-storage-iso')):
   LOG.debug("ISO: iso content_type, i18n-key value not 'local-storage-iso'")
   continue
  LOG.debug('ISO: SR MATCHing our criteria')
  for pbd_ref in sr_rec['PBDs']:
   LOG.debug('ISO: ISO, looking to see if it is host local')
   pbd_rec = session.get_rec('PBD', pbd_ref)
   if (not pbd_rec):
    LOG.debug('ISO: PBD %s disappeared', pbd_ref)
    continue
   pbd_rec_host = pbd_rec['host']
   LOG.debug('ISO: PBD matching, want %(pbd_rec)s, have %(host)s', {'pbd_rec': pbd_rec, 'host': host})
   if (pbd_rec_host == host):
    LOG.debug('ISO: SR with local PBD')
    return sr_ref
 return None

def _find_iso_sr ( session ) : host = session . host_ref for ( sr_ref , sr_rec ) in session . get_all_refs_and_recs ( 'SR' ) : LOG . debug ( 'ISO: looking at SR %s' , sr_rec ) if ( not ( sr_rec [ 'content_type' ] == 'iso' ) ) : LOG . debug ( 'ISO: not iso content' ) continue if ( 'i18n-key' not in sr_rec [ 'other_config' ] ) : LOG . debug ( "ISO: iso content_type, no 'i18n-key' key" ) continue if ( not ( sr_rec [ 'other_config' ] [ 'i18n-key' ] == 'local-storage-iso' ) ) : LOG . debug ( "ISO: iso content_type, i18n-key value not 'local-storage-iso'" ) continue LOG . debug ( 'ISO: SR MATCHing our criteria' ) for pbd_ref in sr_rec [ 'PBDs' ] : LOG . debug ( 'ISO: ISO, looking to see if it is host local' ) pbd_rec = session . get_rec ( 'PBD' , pbd_ref ) if ( not pbd_rec ) : LOG . debug ( 'ISO: PBD %s disappeared' , pbd_ref ) continue pbd_rec_host = pbd_rec [ 'host' ] LOG . debug ( 'ISO: PBD matching, want %(pbd_rec)s, have %(host)s' , { 'pbd_rec' : pbd_rec , 'host' : host } ) if ( pbd_rec_host == host ) : LOG . debug ( 'ISO: SR with local PBD' ) return sr_ref return None
return the storage repository to hold iso images .