当前位置: 首页>>代码示例>>Python>>正文


Python DiracAdmin.getSiteMask方法代码示例

本文整理汇总了Python中DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.getSiteMask方法的典型用法代码示例。如果您正苦于以下问题:Python DiracAdmin.getSiteMask方法的具体用法?Python DiracAdmin.getSiteMask怎么用?Python DiracAdmin.getSiteMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Interfaces.API.DiracAdmin.DiracAdmin的用法示例。


在下文中一共展示了DiracAdmin.getSiteMask方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
 def execute(self):
   """ Get all New tags, mark them as Installing. Old Installing tags are reset to New 
   """
   #### get site mask ###
   diracAdmin = DiracAdmin()
   res = diracAdmin.getSiteMask(printOutput=False)
   if not res["OK"]:
       self.log.error("error retrieving site mask: %s"%str(res["Message"]))
   site_mask = res["Value"]
   res = self.swtc.getTagsWithStatus("New")
   if not res['OK']:
     return res
   if not res['Value']:
     self.log.info("No 'New' tags to consider")
     
   for tag, ces in res['Value'].items():
     for ce in ces: 
       res = getSiteForCEs([ce])
       if not res["OK"]:
           self.log.error("could not retrieve Site name for CE %s"%ce)
       sites = res["Value"].keys()
       for site in sites:
           if site not in site_mask:
               self.log.info("CE/Site disabled %s"%site)
               continue
               # ignore this CE
       res = self.swtc.updateCEStatus(tag, ce, 'Installing')
       if not res['OK']:
         self.log.error(res['Message'])
         continue
       res = None
     
       if self.submitjobs:
         res = self.submitProbeJobs(ce)
       else:
         res = self.swtc.updateCEStatus(tag, ce, 'Valid')
       
       if not res['OK']:
         self.log.error(res['Message'])
       else:
         self.log.info("Done with %s at %s" %(tag, ce))
    
   ##Also, reset to New tags that were in Probing for too long.
   res = self.swtc.getTagsWithStatus("Installing", self.delay)
   if not res['OK']:
     self.log.error("Failed to get old 'Installing' tags")
   else:
     if not res['Value']:
       self.log.info("No 'Installing' tags to reset")
       
     for tag, ces in res['Value'].items():
       for ce in ces:
         res = self.swtc.updateCEStatus(tag, ce, 'New')
         if not res['OK']:
           self.log.error(res['Message'])
           continue
   return S_OK()
开发者ID:brianv0,项目名称:GlastDIRAC,代码行数:59,代码来源:SoftwareMonitorAgent.py

示例2: __getSitesMaskStatus

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
  def __getSitesMaskStatus( self, sitesName ):
    diracAdmin = DiracAdmin()
    activeSites = diracAdmin.getSiteMask()
#    wmsAdmin = RPCClient( 'WorkloadManagement/WMSAdministrator' )
#    activeSites = wmsAdmin.getSiteMask()

    if not activeSites[ 'OK' ]:
      return activeSites
    activeSites = activeSites[ 'Value' ]

    sitesStatus = {}

    for siteName in sitesName:
      if siteName in activeSites:
        sitesStatus[ siteName ] = 'Active'
      else:
        sitesStatus[ siteName ] = 'Banned'

    return S_OK( sitesStatus )
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:21,代码来源:SiteStatusMonitorHandler.py

示例3: execute

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
  def execute(self):
    """
      The main method of the agent. It get elements which need to be tested and
      evaluated from CS. Then it instantiates TestExecutor and StatusEvaluate and
      calls their main method to finish all the work.
    """

    from BESDIRAC.ResourceStatusSystem.SAM.SAMTest import TestConfiguration
    self.tests = TestConfiguration.TESTS
    self.__loadTestObj()

    self.testExecutor = TestExecutor( self.tests, self.apis )
    self.statusEvaluator = StatusEvaluator( self.apis )

    elements = []
    sitesCEs = {}

    # CE tests
    noTestSites = [ site.strip() for site in self.am_getOption( 'noTestSite', '' ).split( ',' ) if site != '' ]
    diracAdmin = DiracAdmin()
    activeSites = diracAdmin.getSiteMask()
#    wmsAdmin = RPCClient('WorkloadManagement/WMSAdministrator')
#    activeSites = wmsAdmin.getSiteMask()
    if not activeSites[ 'OK' ]:
      return activeSites
    activeSites = [ site for site in activeSites[ 'Value' ] if site not in noTestSites ]
    gLogger.info('Active sites: %s', activeSites)

    for siteName in activeSites:
      domain = siteName.split('.')[ 0 ]
      vos = BESUtils.getSiteVO( siteName )
      if 'CLOUD' != domain:
        siteCEs = CSHelpers.getSiteComputingElements( siteName )
        sitesCEs[ siteName ] = siteCEs
        for ce in siteCEs:
          elements.append( { 'ElementName' : ce,
                                                  'ElementType' : 'ComputingElement',
                                                  'VO' : vos } )
          gLogger.debug("List of elements: %s" % ce)

      else:
        sitesCEs[ siteName ] = [ siteName ]
        elements.append( { 'ElementName' : siteName,
                                                'ElementType' : 'CLOUD',
                                                'VO' : vos } )

    # SE tests
    ses = gConfig.getValue( 'Resources/StorageElementGroups/SE-USER' )
    for se in ses.split( ', ' ):
      seSites = BESUtils.getSitesForSE( se )
      for seSite in seSites:
        gLogger.debug( 'Site for SE %s: %s' % (se, seSite) )
        if seSite not in activeSites:
          continue
        vos = BESUtils.getSiteVO( seSite )
        gLogger.debug( 'vos for SE %s under site %s: %s' % (se, seSite, vos) )
        if len(vos) == 0:
          continue
        vo = vos[0]
        elements.append( { 'ElementName' : se,
                                              'ElementType' : 'StorageElement',
                                              'VO' : vo } )
        gLogger.info( 'VO for SE %s: %s' % ( se, vo ) )
        break

    lastCheckTime = datetime.utcnow().replace(microsecond = 0)
    self.elementsStatus = {}

    threads = []
    for elementDict in elements:
      t = threading.Thread( target = self._execute, args = ( elementDict, ) )
      threads.append( t )
      t.start()

    for thread in threads:
      thread.join()

    for siteName in activeSites:
      seList = CSHelpers.getSiteStorageElements( siteName )
      se = ''
      if [] != seList:
        se = seList[ 0 ]
      try:
        seStatus = self.elementsStatus[ se ][ 'all' ]
      except KeyError:
        seStatus = None

      voStatus = { 'all' : [] }
      for ce in sitesCEs[ siteName ]:
        if not self.elementsStatus.has_key( ce ):
          continue
        for vo, status in self.elementsStatus[ ce ].items():
          if vo not in voStatus:
            voStatus[ vo ] = []
          voStatus[ vo ].append( status )

      for vo, ceStatusList in voStatus.items():
        if ceStatusList == [] and seStatus == None:
          continue
        res = self.statusEvaluator.evaluateSiteStatus( siteName, ceStatusList, seStatus, vo = vo, lastCheckTime = lastCheckTime)
#.........这里部分代码省略.........
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:103,代码来源:SAMTestAgent.py

示例4: doNew

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
  def doNew( self, masterParams = None ):
    """
      Gets the parameters to run, either from the master method or from its
      own arguments.

      It contacts the WMSAdministrator with a list of site names, or a single
      site.

      If there are jobs, are recorded and then returned.
    """

    if masterParams is not None:
      name = masterParams
    else:
      params = self._prepareCommand()
      if not params[ 'OK' ]:
        return params
      name = params[ 'Value' ]

#    resultMask = self.wmsAdmin.getSiteMask()
    diracAdmin = DiracAdmin()
    resultMask = diracAdmin.getSiteMask()
    if not resultMask[ 'OK' ]:
      return resultMask
    resultMask = resultMask[ 'Value' ]

    # selectDict, sortList, startItem, maxItems
    # Returns statistics of Last day !
    results = self.wmsAdmin.getSiteSummaryWeb( { 'Site' : name }, [], 0, 0 )
    if not results[ 'OK' ]:
      return results
    results = results[ 'Value' ]

    if not 'ParameterNames' in results:
      return S_ERROR( 'Wrong result dictionary, missing "ParameterNames"' )
    params = results[ 'ParameterNames' ]

    if not 'Records' in results:
      return S_ERROR( 'Wrong formed result dictionary, missing "Records"' )
    records = results[ 'Records' ]

    uniformResult = []
    siteJobs = {}

    for record in records:

      # This returns a dictionary with the following keys
      # 'Site', 'GridType', 'Country', 'Tier', 'MaskStatus', 'Received',
      # 'Checking', 'Staging', 'Waiting', 'Matched', 'Running', 'Stalled',
      # 'Done', 'Completed', 'Failed', 'Efficiency', 'Status'
      jobDict = dict( zip( params , record ))
      siteJobs[ jobDict.pop( 'Site' ) ] = jobDict

#       # We cast efficiency to a float
#       jobDict[ 'Efficiency' ] = float( jobDict[ 'Efficiency' ] )

#       uniformResult.append( jobDict )

    for site in name:
      recordDict = {}
      recordDict[ 'Site' ] = site
      if site in resultMask:
        recordDict[ 'MaskStatus' ] = 'Active'
      else:
        recordDict[ 'MaskStatus' ] = 'Banned'

      if siteJobs.has_key( site ):
#        recordDict[ 'MaskStatus' ] = siteJobs[ site ][ 'MaskStatus' ]
        recordDict[ 'Running' ] = siteJobs[ site ][ 'Running' ]
        recordDict[ 'Waiting' ] = siteJobs[ site ][ 'Waiting' ] + siteJobs[ site ][ 'Checking' ]
        recordDict[ 'Done' ] = siteJobs[ site ][ 'Done' ]
        recordDict[ 'Failed' ] = siteJobs[ site ][ 'Failed' ]
        recordDict[ 'Completed' ] = siteJobs[ site ][ 'Completed' ]
        recordDict[ 'Stalled' ] = siteJobs[ site ][ 'Stalled' ]
        recordDict[ 'Efficiency' ] = float( siteJobs[ site ][ 'Efficiency' ] )
        recordDict[ 'Status' ] = siteJobs[ site ][ 'Status' ]
      else:
        recordDict[ 'Running' ] = 0
        recordDict[ 'Waiting' ] = 0
        recordDict[ 'Done' ] = 0
        recordDict[ 'Failed' ] = 0
        recordDict[ 'Completed' ] = 0
        recordDict[ 'Stalled' ] = 0
        recordDict[ 'Efficiency' ] = 0.0
        recordDict[ 'Status' ] = 'Idle'

      uniformResult.append( recordDict )

    storeRes = self._storeCommand( uniformResult )
    if not storeRes[ 'OK' ]:
      return storeRes

    return S_OK( uniformResult )
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:95,代码来源:JobIHEPCommand.py

示例5: SoftwareManagementAgent

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
class SoftwareManagementAgent( AgentModule ):
  """ Agent to run software management things
  """
  def initialize(self):
    self.pollingTime = self.am_getOption('PollingTime', 86400)
    gMonitor.registerActivity("Iteration", "Agent Loops", AGENT_NAME, "Loops/min", gMonitor.OP_SUM)
    self.ppc = ProcessProdClient()
    self.dirac = DiracILC()
    self.diracadmin = DiracAdmin()
    self.am_setOption( 'shifterProxy', 'Admin' )
    
    return S_OK()

  ##############################################################################
  def execute(self):
    """  First we update the site list and banned site
    """
    res = getProxyInfo(False, False)
    if not res['OK']:
      self.log.error("submitTasks: Failed to determine credentials for submission", res['Message'])
      return res
    proxyInfo = res['Value']
    owner = proxyInfo['username']
    ownerGroup = proxyInfo['group']
    self.log.info("submitTasks: Jobs will be submitted with the credentials %s:%s" % (owner, ownerGroup))    
    
    sites = self.diracadmin.getSiteMask()['Value']
    for site in sites:
      res = self.ppc.changeSiteStatus( {'SiteName' : site, 'Status' : 'OK'} )
      if not res['OK']:
        self.log.error('Cannot add or update site %s' % site)
        
    banned_sites = self.diracadmin.getBannedSites()['Value']
    for banned_site in banned_sites:
      self.ppc.changeSiteStatus( {'SiteName' : banned_site, 'Status' : 'Banned'} )
      if not res['OK']:
        self.log.error('Cannot mark as banned site %s' % banned_site)
        
    ##Then we need to get new installation tasks
    res = self.ppc.getInstallSoftwareTask()
    if not res['OK']:
      self.log.error('Failed to obtain task')
    task_dict = res['Value']
    for softdict in task_dict.values():
      self.log.info('Will install %s %s at %s' % (softdict['AppName'], softdict['AppVersion'], softdict['Sites']))
      for site in softdict['Sites']:
        j = UserJob()
        j.setPlatform(softdict['Platform'])
        j.dontPromptMe()
        j.setDestination(site)
        j.setJobGroup("Installation")
        j.setName('install_%s' % site)
        j._addSoftware(softdict['AppName'], softdict['AppVersion'])
        #Add the application here somehow.
        res  = j.append(SoftwareInstall())
        if not res['OK']:
          self.log.error(res['Message'])
          continue
        res = j.submit(self.dirac)
        #res = self.dirac.submit(j)
        if not res['OK']:
          self.log.error('Could not create the job')
          continue
        jobdict = {}
        jobdict['AppName'] = softdict['AppName']
        jobdict['AppVersion'] = softdict['AppVersion']
        jobdict['Platform'] = softdict['Platform']
        jobdict['JobID'] = res['Value']
        jobdict['Status'] = 'Waiting'
        jobdict['Site'] = site
        res = self.ppc.addOrUpdateJob(jobdict)
        if not res['OK']:
          self.log.error('Could not add job %s: %s' % (jobdict['JobID'], res['Message']))
    
    ##Monitor jobs
    jobs = {}
    res = self.ppc.getJobs()
    if not res['OK']:
      self.log.error('Could not retrieve jobs')
    else:
      jobs = res['Value']
      for job in jobs:
        res = self.dirac.status(job['JobID'])
        if res['OK']:
          jobstatuses = res['Value'] 
          job['Status'] = jobstatuses['JobID']['Status']
          res = self.ppc.addOrUpdateJob(job)
          if not res['OK']:
            self.log.error("Failed to updated job %s: %s" % (job['JobID'], res['Message']))
        else:
          self.log.error("Failed to update job %s status" % job['JobID'])
          
    return S_OK()
开发者ID:akiyamiyamoto,项目名称:ilddirac,代码行数:95,代码来源:SoftwareManagementAgent.py

示例6: DiracAdmin

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
########################################################################
__RCSID__ = "7ad103d (2010-12-05 08:04:55 +0000) Andrei Tsaregorodtsev <[email protected]>"


from DIRAC.Core.Base import Script

Script.setUsageMessage( """
Get the list of sites enabled in the mask for job submission

Usage:
   %s [options]
""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = True )

import DIRAC
from DIRAC import gLogger
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin

diracAdmin = DiracAdmin()

gLogger.setLevel('ALWAYS')

result = diracAdmin.getSiteMask(printOutput=True)
if result['OK']:
  DIRAC.exit( 0 )
else:
  print result['Message']
  DIRAC.exit( 2 )

开发者ID:sbel,项目名称:bes3-jinr,代码行数:31,代码来源:dirac-admin-get-site-mask.py

示例7: DiracAdmin

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getSiteMask [as 别名]
# Author :  Stuart Paterson
########################################################################

__RCSID__ = "$Id$"


from DIRAC.Core.Base import Script

Script.setUsageMessage( """
Get the list of sites enabled in the mask for job submission

Usage:
   %s [options]
""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = True )

from DIRAC import exit as DIRACExit, gLogger
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin

diracAdmin = DiracAdmin()

gLogger.setLevel('ALWAYS')

result = diracAdmin.getSiteMask(printOutput=True, status="Active")
if result['OK']:
  DIRACExit( 0 )
else:
  print result['Message']
  DIRACExit( 2 )
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:32,代码来源:dirac-admin-get-site-mask.py


注:本文中的DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.getSiteMask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。