def getUnusableSites(self, statusType): """ For a given statusType, returns all sites that are usable: their status for that particular statusType is either Banned or Probing; in a list. examples >>> siteStatus.getUnusableSites( 'ComputingAccess' ) S_OK( [ 'LCG.CERN.ch', 'LCG.IN2P3.fr',... ] ) >>> siteStatus.getUnsusableSites( None ) S_ERROR( ... ) >>> siteStatus.getUnusableSites( 'RubbishAccess' ) S_ERROR( ... ) :Parameters: **statusType** - `string` name of the statusType to be matched :return: S_OK() || S_ERROR() """ result = self.getUnusableElements('Site', statusType) if not result['OK']: return result resultList = [] for site in result['Value']: resultNames = getSiteFullNames(site) if result['OK']: resultList += resultNames['Value'] return S_OK(resultList)
def getSiteCEMapping(): """ Returns a dictionary of all sites and their CEs as a list, e.g. {'LCG.CERN.ch':['ce101.cern.ch',...]} If gridName is specified, result is restricted to that Grid type. """ siteCEMapping = {} resourceHelper = Resources() result = resourceHelper.getEligibleSites() if not result['OK']: return result sites = result['Value'] for site in sites: result = resourceHelper.getEligibleResources('Computing', {'Site': site}) if not result['OK']: continue ceList = result['Value'] result = getSiteFullNames(site) if not result['OK']: continue for sName in result['Value']: siteCEMapping[sName] = ceList return S_OK(siteCEMapping)
def getSiteCEMapping(): """ Returns a dictionary of all sites and their CEs as a list, e.g. {'LCG.CERN.ch':['ce101.cern.ch',...]} If gridName is specified, result is restricted to that Grid type. """ siteCEMapping = {} resourceHelper = Resources() result = resourceHelper.getEligibleSites() if not result['OK']: return result sites = result['Value'] for site in sites: result = resourceHelper.getEligibleResources( 'Computing', {'Site':site} ) if not result['OK']: continue ceList = result['Value'] result = getSiteFullNames( site ) if not result['OK']: continue for sName in result['Value']: siteCEMapping[sName] = ceList return S_OK( siteCEMapping )
def getUnusableSites( self, statusType ): """ For a given statusType, returns all sites that are usable: their status for that particular statusType is either Banned or Probing; in a list. examples >>> siteStatus.getUnusableSites( 'ComputingAccess' ) S_OK( [ 'LCG.CERN.ch', 'LCG.IN2P3.fr',... ] ) >>> siteStatus.getUnsusableSites( None ) S_ERROR( ... ) >>> siteStatus.getUnusableSites( 'RubbishAccess' ) S_ERROR( ... ) :Parameters: **statusType** - `string` name of the statusType to be matched :return: S_OK() || S_ERROR() """ result = self.getUnusableElements( 'Site', statusType ) if not result['OK']: return result resultList = [] for site in result['Value']: resultNames = getSiteFullNames( site ) if result['OK']: resultList += resultNames['Value'] return S_OK( resultList )
def getSiteForCE(computingElement): """ Given a Grid CE name this method returns the DIRAC site name. """ result = getSiteForResource(computingElement) if not result['OK']: return result site = result['Value'] result = getSiteFullNames(site) if not result['OK']: return result siteFullName = result['Value'][0] return S_OK(siteFullName)
def getSiteForCE( computingElement ): """ Given a Grid CE name this method returns the DIRAC site name. """ result = getSiteForResource( computingElement ) if not result['OK']: return result site = result['Value'] result = getSiteFullNames( site ) if not result['OK']: return result siteFullName = result['Value'][0] return S_OK( siteFullName )
def getSiteMaskLogging(self, site=None, printOutput=False): """Retrieves site mask logging information. Example usage: >>> print diracAdmin.getSiteMaskLogging('LCG.AUVER.fr') {'OK': True, 'Value': } :returns: S_OK,S_ERROR """ result = self.__checkSiteIsValid(site) if not result['OK']: return result rssClient = ResourceStatusClient() result = rssClient.selectStatusElement('Site', 'History', name=site, statusType='ComputingAccess') if not result['OK']: return result siteDict = {} for logTuple in result['Value']: status, reason, siteName, dateEffective, dateTokenExpiration, eType, sType, eID, lastCheckTime, author = logTuple result = getSiteFullNames(siteName) if not result['OK']: continue for sName in result['Value']: if site is None or (site and site == sName): siteDict.setdefault(sName, []) siteDict[sName].append((status, reason, dateEffective, author, dateTokenExpiration)) if printOutput: if site: print '\nSite Mask Logging Info for %s\n' % site else: print '\nAll Site Mask Logging Info\n' for site, tupleList in siteDict.items(): if not site: print '\n===> %s\n' % site for tup in tupleList: print str( tup[0] ).ljust( 8 ) + str( tup[1] ).ljust( 20 ) + \ '( ' + str( tup[2] ).ljust( len( str( tup[2] ) ) ) + ' ) "' + str( tup[3] ) + '"' print ' ' return S_OK(siteDict)
def getSiteMaskLogging( self, site = None, printOutput = False ): """Retrieves site mask logging information. Example usage: >>> print diracAdmin.getSiteMaskLogging('LCG.AUVER.fr') {'OK': True, 'Value': } :returns: S_OK,S_ERROR """ result = self.__checkSiteIsValid( site ) if not result['OK']: return result rssClient = ResourceStatusClient() result = rssClient.selectStatusElement( 'Site', 'History', name = site, statusType = 'ComputingAccess' ) if not result['OK']: return result siteDict = {} for logTuple in result['Value']: status,reason,siteName,dateEffective,dateTokenExpiration,eType,sType,eID,lastCheckTime,author = logTuple result = getSiteFullNames( siteName ) if not result['OK']: continue for sName in result['Value']: if site is None or (site and site == sName): siteDict.setdefault( sName, [] ) siteDict[sName].append( (status,reason,dateEffective,author,dateTokenExpiration) ) if printOutput: if site: print '\nSite Mask Logging Info for %s\n' % site else: print '\nAll Site Mask Logging Info\n' for site, tupleList in siteDict.items(): if not site: print '\n===> %s\n' % site for tup in tupleList: print str( tup[0] ).ljust( 8 ) + str( tup[1] ).ljust( 20 ) + \ '( ' + str( tup[2] ).ljust( len( str( tup[2] ) ) ) + ' ) "' + str( tup[3] ) + '"' print ' ' return S_OK( siteDict )
def getSiteSEMapping(): """ 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. """ siteSEMapping = {} resourceHelper = Resources() result = resourceHelper.getEligibleSites() if not result['OK']: return result sites = result['Value'] for site in sites: result = resourceHelper.getEligibleResources('Storage', {'Site': site}) if not result['OK']: continue seList = result['Value'] result = getSiteFullNames(site) if not result['OK']: continue for sName in result['Value']: siteSEMapping[sName] = seList # Add Sites from the SiteToLocalSEMapping in the CS opsHelper = Operations() result = opsHelper.getSiteMapping('Storage', 'LocalSE') if result['OK']: mapping = result['Value'] for site in mapping: if site not in siteSEMapping: siteSEMapping[site] = mapping[site] else: for se in mapping[site]: if se not in siteSEMapping[site]: siteSEMapping[site].append(se) return S_OK(siteSEMapping)
def getSiteSEMapping(): """ 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. """ siteSEMapping = {} resourceHelper = Resources() result = resourceHelper.getEligibleSites() if not result['OK']: return result sites = result['Value'] for site in sites: result = resourceHelper.getEligibleResources( 'Storage', {'Site':site} ) if not result['OK']: continue seList = result['Value'] result = getSiteFullNames( site ) if not result['OK']: continue for sName in result['Value']: siteSEMapping[sName] = seList # Add Sites from the SiteToLocalSEMapping in the CS opsHelper = Operations() result = opsHelper.getSiteMapping( 'Storage', 'LocalSE' ) if result['OK']: mapping = result['Value'] for site in mapping: if site not in siteSEMapping: siteSEMapping[site] = mapping[site] else: for se in mapping[site]: if se not in siteSEMapping[site]: siteSEMapping[site].append( se ) return S_OK( siteSEMapping )