Example #1
0
def getSitesForSE( storageElement, gridName = '', withSiteLocalSEMapping = False ):
  """ Given a DIRAC SE name this method returns a list of corresponding sites.
      Optionally restrict to Grid specified by name.
  """

  result = DMSHelpers().getSitesForSE( storageElement, connectionLevel = 'DOWNLOAD' if withSiteLocalSEMapping else 'LOCAL' )
  if not result['OK'] or not gridName:
    return result

  return S_OK( [site for site in result['Value'] if siteGridName( site ) == gridName] )
Example #2
0
def getSiteSEMapping( gridName = '', withSiteLocalSEMapping = False ):
  """ Returns a dictionary of all sites and their localSEs as a list, e.g.
      {'LCG.CERN.ch':['CERN-RAW','CERN-RDST',...]}
      If gridName is specified, result is restricted to that Grid type.
  """
  result = DMSHelpers().getSiteSEMapping()
  if not result['OK']:
    return result
  if withSiteLocalSEMapping:
    mapping = result['Value'][2]
  else:
    mapping = result['Value'][1]
  if gridName:
    mapping = dict( ( site, mapping[site] ) for site in mapping if siteGridName( site ) == gridName )
  return S_OK( mapping )