Пример #1
0
  def __setJobSite( self, jobState, siteList ):
    """ Set the site attribute
    """
    numSites = len( siteList )
    if numSites == 0:
      self.jobLog.info( "Any site is candidate" )
      return jobState.setAttribute( "Site", "ANY" )
    elif numSites == 1:
      self.jobLog.info( "Only site %s is candidate" % siteList[0] )
      return jobState.setAttribute( "Site", siteList[0] )

    tierSite = []
    tierLevel = -1
    for siteName in siteList:
      result = getSiteTier( siteName )
      if not result[ 'OK' ]:
        self.jobLog.error( "Cannot get tier for site %s" % ( siteName ) )
        continue
      siteTier = result[ 'Value' ]
      if tierLevel == -1 or tierLevel > siteTier:
        tierLevel = siteTier
        tierSite = []
      if tierLevel == siteTier:
        tierSite.append( siteName )

    if len( tierSite ) == 1:
      siteName = "Group.%s" % ".".join( tierSite[0].split( "." )[1:] )
      self.jobLog.info( "Group %s is candidate" % siteName )
    else:
      siteName = "Multiple"
      self.jobLog.info( "Multiple sites are candidate" )

    return jobState.setAttribute( "Site", siteName )
Пример #2
0
    def _getSiteTiers(self, siteList):
        """ retun dict {'Site':Tier}
    """
        siteTierDict = {}
        for siteName in siteList:
            result = getSiteTier(siteName)
            if not result['OK']:
                self.jobLog.error("Cannot get tier for site %s" % (siteName))
                siteTier = 2
            else:
                siteTier = int(result['Value'])
            siteTierDict.setdefault(siteName, siteTier)

        return siteTierDict
Пример #3
0
  def _getSiteTiers( self, siteList ):
    """ retun dict {'Site':Tier}
    """
    siteTierDict = {}
    for siteName in siteList:
      result = getSiteTier( siteName )
      if not result[ 'OK' ]:
        self.jobLog.error( "Cannot get tier for site %s" % ( siteName ) )
        siteTier = 2
      else:
        siteTier = int( result[ 'Value' ] )
      siteTierDict.setdefault( siteName, siteTier )

    return siteTierDict
Пример #4
0
    def banTier1s(self):
        """ Sets Tier1s as banned.
    """
        tier1s = []
        sites = getSites()
        if not sites['OK']:
            return sites

        for site in sites['Value']:
            tier = getSiteTier(site)
            if not tier['OK']:
                return tier
            if int(tier['Value']) in (0, 1):
                tier1s.append(site)

        self.LHCbJob.setBannedSites(tier1s)
Пример #5
0
  def __getSiteGroup( self, stagingSites ):
    """ Get the name of the site group if applicable. Later can be replaced by site groups defined in the CS
    """
    tier1 = ''
    groupName = ''
    for site in stagingSites:
      result = getSiteTier( site )
      if not result['OK']:
        self.log.error( result['Message'] )
        continue
      tier = result['Value']
      if tier in [0, 1]:
        tier1 = site
        if tier == 0:
          break

    if tier1:
      grid, sname, ccode = tier1.split( '.' )
      groupName = '.'.join( ['Group', sname, ccode] )

    return S_OK( groupName )
Пример #6
0
    def __getSiteGroup(self, stagingSites):
        """ Get the name of the site group if applicable. Later can be replaced by site groups defined in the CS
    """
        tier1 = ""
        groupName = ""
        for site in stagingSites:
            result = getSiteTier(site)
            if not result["OK"]:
                self.log.error(result["Message"])
                continue
            tier = result["Value"]
            if tier in [0, 1]:
                tier1 = site
                if tier == 0:
                    break

        if tier1:
            grid, sname, ccode = tier1.split(".")
            groupName = ".".join(["Group", sname, ccode])

        return S_OK(groupName)
Пример #7
0
    def __getSiteGroup(self, stagingSites):
        """ Get the name of the site group if applicable. Later can be replaced by site groups defined in the CS
    """
        tier1 = ''
        groupName = ''
        for site in stagingSites:
            result = getSiteTier(site)
            if not result['OK']:
                self.log.error(result['Message'])
                continue
            tier = result['Value']
            if tier in [0, 1]:
                tier1 = site
                if tier == 0:
                    break

        if tier1:
            grid, sname, ccode = tier1.split('.')
            groupName = '.'.join(['Group', sname, ccode])

        return S_OK(groupName)
Пример #8
0
    def __setJobSite(self, jobState, siteList):
        """ Set the site attribute
    """
        numSites = len(siteList)
        if numSites == 0:
            self.jobLog.info("Any site is candidate")
            return jobState.setAttribute("Site", "ANY")
        elif numSites == 1:
            self.jobLog.info("Only site %s is candidate" % siteList[0])
            return jobState.setAttribute("Site", siteList[0])

        tierSite = []
        tierLevel = -1
        for siteName in siteList:
            result = getSiteTier(siteName)
            if not result["OK"]:
                self.jobLog.error("Cannot get tier for site %s" % (siteName))
                continue
            siteTier = result["Value"]

            # FIXME: hack for cases where you get a T0 together with T1(s) in the list of sites and you want to see "multiple"
            if siteTier == 0:
                siteTier = 1

            if tierLevel == -1 or tierLevel > siteTier:
                tierLevel = siteTier
                tierSite = []
            if tierLevel == siteTier:
                tierSite.append(siteName)

        if len(tierSite) == 1:
            siteName = "Group.%s" % ".".join(tierSite[0].split(".")[1:])
            self.jobLog.info("Group %s is candidate" % siteName)
        else:
            siteName = "Multiple"
            self.jobLog.info("Multiple sites are candidate")

        return jobState.setAttribute("Site", siteName)