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 )