def cloud_from_sites(self, sites=[]):

        # Return the cloud given the site
        if not sites:
            sites = self.sites

        if sites.__class__.__name__ == 'str':
            sites = [sites]

        if len(sites) == 0:
            return {}

        mapping = {}

        # sort info for site -> cloud
        for cloud in self.list_clouds():
            cloud_sites = getSites(self._cloudNameList[cloud])
            for site in cloud_sites:
                mapping[site] = cloud

        # now output the mapping requested
        output = {}
        for site in sites:
            try:
                output[site] = mapping[site]
            except:
                logger.warning(
                    "Could not find cloud associated with site '%s'." % site)
                if site == 'CERN-MOCKTEST':
                    output[site] = 'T0'

        return output
Beispiel #2
0
    def cloud_from_sites( self, sites = [] ):
        
        # Return the cloud given the site
        if not sites:
            sites = self.sites

        if sites.__class__.__name__ == 'str':
            sites = [sites]

        if len(sites) == 0:
            return {}
        
        mapping = {}
        
        # sort info for site -> cloud
        for cloud in self.list_clouds():
            cloud_sites = getSites(self._cloudNameList[cloud])
            for site in cloud_sites:
                mapping[ site ] = cloud

        # now output the mapping requested
        output = {}
        for site in sites:
            try:
                output[site] = mapping[site]
            except:
                logger.warning("Could not find cloud associated with site '%s'." % site)
                if site == 'CERN-MOCKTEST':
                    output[site] = 'T0'

        return output
    def list_sites_cloud(self, cloudName='', blacklist=True, req_str=''):

        if cloudName:
            cloudID = cloudName
        else:
            cloudID = self.cloud

        try:
            cloud = self._cloudNameList[cloudID]
        except:
            cloud = cloudID

        sites = getSites(cloud)

        # exclude sites
        for site in self.excluded_sites:
            if site in sites:
                sites.remove(site)

        # blacklist
        if (blacklist):
            _refreshCESEInfo()
            for bad_site in CESEInfo['blacklist']:
                try:
                    sites.remove(bad_site)
                except ValueError:
                    pass

        if (req_str != '') and (self._name == 'AtlasLCGRequirements'):
            # check release requirements
            old_software = self.software
            self.software = [req_str]
            be = self._getParent()
            matches = be.get_requirement_matches()

            # find the ces for each site
            new_sites = []
            for site in sites:
                ces = getCEsForSites([site])
                for ce in ces:
                    if ce in matches:
                        new_sites.append(site)
                        break

            sites = new_sites

        if sites:
            return sites
        raise BackendError(
            'LCG',
            'Could not find any sites for selected cloud %s. Allowed clouds: %s'
            % (cloud, self._cloudNameList.keys()))
Beispiel #4
0
    def list_sites_cloud(self, cloudName='', blacklist=True, req_str = ''):


        if cloudName:
            cloudID = cloudName
        else:
            cloudID = self.cloud

        try:
            cloud = self._cloudNameList[cloudID]
        except:
            cloud = cloudID
           
        sites = getSites(cloud)
        
        # exclude sites
        for site in self.excluded_sites:
            if site in sites:
                sites.remove(site)

        # blacklist
        if (blacklist):
            _refreshCESEInfo()
            for bad_site in CESEInfo['blacklist']:
                try:
                    sites.remove(bad_site)
                except ValueError:
                    pass
                
        if (req_str != '') and (self._name == 'AtlasLCGRequirements'):
            # check release requirements
            old_software = self.software
            self.software = [req_str]
            be = self._getParent()
            matches = be.get_requirement_matches()

            # find the ces for each site
            new_sites = []
            for site in sites:
                ces = getCEsForSites([site])
                for ce in ces:
                    if ce in matches:
                        new_sites.append(site)
                        break

            sites = new_sites
            
        if sites:
            return sites
        raise BackendError('LCG','Could not find any sites for selected cloud %s. Allowed clouds: %s'%(cloud,self._cloudNameList.keys()))
def getAllSites(only_lcg=True,
                resolve=False,
                excluded_clouds=[],
                excluded_sites=[],
                blacklist=True):
    '''list all sites defined in TiersOfATLAS'''

    _refreshToACache()
    _refreshCESEInfo()

    sites = []
    if not 'TO' in excluded_clouds:
        sites += getSites('CERN')
    if not 'IT' in excluded_clouds:
        sites += getSites('ITALYSITES')
    if not 'ES' in excluded_clouds:
        sites += getSites('SPAINSITES')
    if not 'FR' in excluded_clouds:
        sites += getSites('FRANCESITES')
    if not 'UK' in excluded_clouds:
        sites += getSites('UKSITES')
    if not 'DE' in excluded_clouds:
        sites += getSites('FZKSITES')
    if not 'NL' in excluded_clouds:
        sites += getSites('NLSITES')
    if not 'TW' in excluded_clouds:
        sites += getSites('TAIWANSITES')
    if not 'CA' in excluded_clouds:
        sites += getSites('CANADASITES')

    if not only_lcg:
        sites += getSites('USASITES')
        sites += getSites('NDGF')

    # exclude sites
    for site in excluded_sites:
        if site in sites:
            sites.remove(site)

    if resolve: sites = _resolveSites(sites)

    # exclude sites - check again after site resolution
    for site in excluded_sites:
        if site in sites:
            sites.remove(site)

    sites.sort()

    if (blacklist):
        for bad_site in CESEInfo['blacklist']:
            try:
                sites.remove(bad_site)
            except ValueError:
                pass

    return sites
Beispiel #6
0
def getAllSites(only_lcg=True,resolve=False, excluded_clouds=[], excluded_sites=[], blacklist=True):
    '''list all sites defined in TiersOfATLAS'''

    _refreshToACache()
    _refreshCESEInfo()

    sites = []
    if not 'TO' in excluded_clouds:
        sites += getSites('CERN')
    if not 'IT' in excluded_clouds:
        sites += getSites('ITALYSITES')
    if not 'ES' in excluded_clouds:
        sites += getSites('SPAINSITES')
    if not 'FR' in excluded_clouds:
        sites += getSites('FRANCESITES')
    if not 'UK' in excluded_clouds:
        sites += getSites('UKSITES')
    if not 'DE' in excluded_clouds:
        sites += getSites('FZKSITES')
    if not 'NL' in excluded_clouds:
        sites += getSites('NLSITES')
    if not 'TW' in excluded_clouds:
        sites += getSites('TAIWANSITES')
    if not 'CA' in excluded_clouds:
        sites += getSites('CANADASITES')    

    if not only_lcg:
        sites += getSites('USASITES')
        sites += getSites('NDGF')

    # exclude sites
    for site in excluded_sites:
        if site in sites:
            sites.remove(site)
    
    if resolve: sites = _resolveSites(sites)

    # exclude sites - check again after site resolution
    for site in excluded_sites:
        if site in sites:
            sites.remove(site)

    sites.sort()

    if (blacklist):
        for bad_site in CESEInfo['blacklist']:
            try:
                sites.remove(bad_site)
            except ValueError:
                pass
     
    return sites