Beispiel #1
0
def getGridSRMs( vo, bdiiInfo = None, srmBlackList = None, unUsed = False ):
  
  result = ldapService( serviceType = 'SRM', vo = vo )
  if not result['OK']:
    return result
  srmBdiiDict = result['Value']

  knownSRMs = set()
  if srmBlackList is not None:
    knownSRMs = knownSRMs.union( set( srmBlackList ) )

  siteSRMDict = {}
  for srm in srmBdiiDict:
    
    endPoint = srm.get( 'GlueServiceEndpoint', '')
    srmHost = ''
    if endPoint:
      result = pfnparse( endPoint )
      if not result['OK']:
        continue
      srmHost = result['Value']['Host']
    if not srmHost:
      continue  
    
    if srmHost in knownSRMs:
      continue
    
    if unUsed:
      result = getDIRACSesForSRM( srmHost )
      if not result['OK']:
        return result
      diracSEs = result['Value']
      if diracSEs:
        # If it is a known SRM and only new SRMs are requested, continue
        continue
    site = srm.get( 'GlueForeignKey', '' ).replace( 'GlueSiteUniqueID=', '' )     
    siteSRMDict.setdefault( site, {} )
    siteSRMDict[site][srmHost] = srm
      
  if bdiiInfo is None:    
    result = getBdiiSEInfo( vo )
    if not result['OK']:
      return result
    seBdiiDict = result['Value']
  else:
    seBdiiDict = bdiiInfo  
 
  srmSeDict = {}  
  for site in siteSRMDict:
    srms = siteSRMDict[site].keys()
    for srm in srms:
      if seBdiiDict.get( site, {} ).get( 'SEs', {} ).get( srm, {} ):
        srmSeDict.setdefault( site, {} )
        srmSeDict[site].setdefault( srm, {} )
        srmSeDict[site][srm]['SRM'] = siteSRMDict[site][srm]
        srmSeDict[site][srm]['SE'] = seBdiiDict[site]['SEs'][srm]    
      
  return S_OK( srmSeDict ) 
Beispiel #2
0
def getGridSRMs( vo, bdiiInfo = None, srmBlackList = None, unUsed = False ):
  
  result = ldapService( serviceType = 'SRM', vo = vo )
  if not result['OK']:
    return result
  srmBdiiDict = result['Value']

  knownSRMs = set()
  if srmBlackList is not None:
    knownSRMs = knownSRMs.union( set( srmBlackList ) )

  siteSRMDict = {}
  for srm in srmBdiiDict:
    
    endPoint = srm.get( 'GlueServiceEndpoint', '')
    srmHost = ''
    if endPoint:
      result = pfnparse( endPoint )
      if not result['OK']:
        continue
      srmHost = result['Value']['Host']
    if not srmHost:
      continue  
    
    if srmHost in knownSRMs:
      continue
    
    if unUsed:
      result = getDIRACSesForSRM( srmHost )
      if not result['OK']:
        return result
      diracSEs = result['Value']
      if diracSEs:
        # If it is a known SRM and only new SRMs are requested, continue
        continue
    site = srm.get( 'GlueForeignKey', '' ).replace( 'GlueSiteUniqueID=', '' )     
    siteSRMDict.setdefault( site, {} )
    siteSRMDict[site][srmHost] = srm
      
  if bdiiInfo is None:    
    result = getBdiiSEInfo( vo )
    if not result['OK']:
      return result
    seBdiiDict = result['Value']
  else:
    seBdiiDict = bdiiInfo  
 
  srmSeDict = {}  
  for site in siteSRMDict:
    srms = siteSRMDict[site].keys()
    for srm in srms:
      if seBdiiDict.get( site, {} ).get( 'SEs', {} ).get( srm, {} ):
        srmSeDict.setdefault( site, {} )
        srmSeDict[site].setdefault( srm, {} )
        srmSeDict[site][srm]['SRM'] = siteSRMDict[site][srm]
        srmSeDict[site][srm]['SE'] = seBdiiDict[site]['SEs'][srm]    
      
  return S_OK( srmSeDict ) 
Beispiel #3
0
    def __getBdiiSEInfo(self, vo):

        if vo in self.voBdiiSEDict:
            return S_OK(self.voBdiiSEDict[vo])
        self.log.info("Check for available SEs for VO", vo)
        result = getBdiiSEInfo(vo)
        message = ''
        if not result['OK']:
            message = result['Message']
            for bdii in self.alternativeBDIIs:
                result = getBdiiSEInfo(vo, host=bdii)
                if result['OK']:
                    break
        if not result['OK']:
            if message:
                self.log.error("Error during BDII request", message)
            else:
                self.log.error("Error during BDII request", result['Message'])
        else:
            self.voBdiiSEDict[vo] = result['Value']
        return result
Beispiel #4
0
  def __getBdiiSEInfo( self, vo ):

    if vo in self.voBdiiSEDict:
      return S_OK( self.voBdiiSEDict[vo] )
    self.log.info( "Check for available SEs for VO", vo )
    result = getBdiiSEInfo( vo )
    message = ''
    if not result['OK']:
      message = result['Message']
      for bdii in self.alternativeBDIIs :
        result = getBdiiSEInfo( vo, host = bdii )
        if result['OK']:
          break
    if not result['OK']:
      if message:
        self.log.error( "Error during BDII request", message )
      else:
        self.log.error( "Error during BDII request", result['Message'] )
    else:
      self.voBdiiSEDict[vo] = result['Value']
    return result
Beispiel #5
0
def getGridSEs(vo, bdiiInfo=None, seBlackList=None):
    """ Get all the SEs available for a given VO 
  """
    seBdiiDict = bdiiInfo
    if bdiiInfo is None:
        result = getBdiiSEInfo(vo)
        if not result['OK']:
            return result
        seBdiiDict = result['Value']

    knownSEs = set()
    if seBlackList is not None:
        knownSEs = knownSEs.union(set(seBlackList))

    siteDict = {}
    for site in seBdiiDict:
        for gridSE in seBdiiDict[site]['SEs']:
            seDict = seBdiiDict[site]['SEs'][gridSE]

            #if "lhcb" in seDict['GlueSAName']:
            #  print '+'*80
            #  print gridSE
            #  for k,v in seDict.items():
            #    print k,'\t',v

            if not gridSE in knownSEs:
                siteDict.setdefault(site, {})
                if type(seDict['GlueSAAccessControlBaseRule']
                        ) == types.ListType:
                    voList = [
                        re.sub('^VO:', '', s)
                        for s in seDict['GlueSAAccessControlBaseRule']
                    ]
                else:
                    voList = [
                        re.sub('^VO:', '',
                               seDict['GlueSAAccessControlBaseRule'])
                    ]
                siteDict[site][gridSE] = {
                    'GridSite': seDict['GlueSiteUniqueID'],
                    'BackendType': seDict['GlueSEImplementationName'],
                    'Description': seDict.get('GlueSEName', '-'),
                    'VOs': voList
                }

    result = S_OK(siteDict)
    result['BdiiInfo'] = seBdiiDict
    return result
Beispiel #6
0
def getGridSEs( vo, bdiiInfo = None, seBlackList = None ):
  """ Get all the SEs available for a given VO 
  """
  seBdiiDict = bdiiInfo
  if bdiiInfo is None:
    result = getBdiiSEInfo( vo )
    if not result['OK']:
      return result
    seBdiiDict = result['Value']

  knownSEs = set()
  if seBlackList is not None:
    knownSEs = knownSEs.union( set( seBlackList ) )
    
  siteDict = {}
  for site in seBdiiDict:
    for gridSE in seBdiiDict[site]['SEs']:
      seDict = seBdiiDict[site]['SEs'][gridSE]
      
      #if "lhcb" in seDict['GlueSAName']: 
      #  print '+'*80
      #  print gridSE
      #  for k,v in seDict.items():
      #    print k,'\t',v 
        
    
      if not gridSE in knownSEs:
        siteDict.setdefault( site, {} )
        if type( seDict['GlueSAAccessControlBaseRule'] ) == types.ListType:
          voList = [ re.sub( '^VO:', '', s ) for s in seDict['GlueSAAccessControlBaseRule'] ]
        else:
          voList = [ re.sub( '^VO:', '', seDict['GlueSAAccessControlBaseRule'] ) ]  
        siteDict[site][gridSE] = { 'GridSite': seDict['GlueSiteUniqueID'],
                                   'BackendType': seDict['GlueSEImplementationName'],
                                   'Description': seDict.get( 'GlueSEName', '-' ),
                                   'VOs': voList
                                 } 
    
  result = S_OK( siteDict )
  result['BdiiInfo'] = seBdiiDict
  return result
Beispiel #7
0
def getGridSEs(vo, bdiiInfo=None, seBlackList=None):
  """ Get all the SEs available for a given VO

      :param str vo: VO name
      :param dict bdiiInfo: information from BDII
      :param list seBlackList: SEs from black list

      :return: S_OK(dict)/S_ERROR()
  """
  seBdiiDict = bdiiInfo
  if bdiiInfo is None:
    result = getBdiiSEInfo(vo)
    if not result['OK']:
      return result
    seBdiiDict = result['Value']

  knownSEs = set()
  if seBlackList is not None:
    knownSEs = knownSEs.union(set(seBlackList))

  siteDict = {}
  for site in seBdiiDict:
    for gridSE in seBdiiDict[site]['SEs']:
      seDict = seBdiiDict[site]['SEs'][gridSE]

      if gridSE not in knownSEs:
        siteDict.setdefault(site, {})
        if isinstance(seDict['GlueSAAccessControlBaseRule'], list):
          voList = [re.sub('^VO:', '', s) for s in seDict['GlueSAAccessControlBaseRule']]
        else:
          voList = [re.sub('^VO:', '', seDict['GlueSAAccessControlBaseRule'])]
        siteDict[site][gridSE] = {'GridSite': seDict['GlueSiteUniqueID'],
                                  'BackendType': seDict['GlueSEImplementationName'],
                                  'Description': seDict.get('GlueSEName', '-'),
                                  'VOs': voList
                                  }

  result = S_OK(siteDict)
  result['BdiiInfo'] = seBdiiDict
  return result
Beispiel #8
0
def getGridSRMs(vo, bdiiInfo=None, srmBlackList=None, unUsed=False):
  """ Get all the SRMs available for a given VO

      :param str vo: VO name
      :param dict bdiiInfo: information from BDII
      :param list srmBlackList: SRMs from black list
      :param bool unUsed: unused

      :return: S_OK(dict)/S_ERROR()
  """
  result = ldapService(serviceType='SRM', vo=vo)
  if not result['OK']:
    return result
  srmBdiiDict = result['Value']

  knownSRMs = set()
  if srmBlackList is not None:
    knownSRMs = knownSRMs.union(set(srmBlackList))

  siteSRMDict = {}
  for srm in srmBdiiDict:
    srm = dict(srm)
    endPoint = srm.get('GlueServiceEndpoint', '')
    srmHost = ''
    if endPoint:
      srmHost = urlparse(endPoint).hostname
    if not srmHost:
      continue

    if srmHost in knownSRMs:
      continue

    if unUsed:
      result = getDIRACSesForHostName(srmHost)
      if not result['OK']:
        return result
      diracSEs = result['Value']
      if diracSEs:
        # If it is a known SRM and only new SRMs are requested, continue
        continue
    site = srm.get('GlueForeignKey', '').replace('GlueSiteUniqueID=', '')
    siteSRMDict.setdefault(site, {})
    siteSRMDict[site][srmHost] = srm

  if bdiiInfo is None:
    result = getBdiiSEInfo(vo)
    if not result['OK']:
      return result
    seBdiiDict = dict(result['Value'])
  else:
    seBdiiDict = dict(bdiiInfo)

  srmSeDict = {}
  for site in siteSRMDict:
    srms = siteSRMDict[site].keys()
    for srm in srms:
      if seBdiiDict.get(site, {}).get('SEs', {}).get(srm, {}):
        srmSeDict.setdefault(site, {})
        srmSeDict[site].setdefault(srm, {})
        srmSeDict[site][srm]['SRM'] = siteSRMDict[site][srm]
        srmSeDict[site][srm]['SE'] = seBdiiDict[site]['SEs'][srm]

  return S_OK(srmSeDict)