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


Python DiracAdmin.killPilot方法代码示例

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


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

示例1: len

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import killPilot [as 别名]
  Kill the specified pilot
"""
__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s <pilot reference>' % Script.scriptName ] ) )

Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

if len( args ) < 1:
  Script.showHelp()
  
pilotRef = args[0]  

from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0

result = diracAdmin.killPilot( pilotRef )
if not result['OK']:
  DIRAC.gLogger.error( 'Failed to kill pilot', pilotRef )
  DIRAC.gLogger.error( result['Message'] )
  exitCode = 1

DIRAC.exit( exitCode )
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:32,代码来源:dirac-admin-kill-pilot.py

示例2: PilotStatusAgent

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

#.........这里部分代码省略.........
      select all pilots that have not been updated in the last N days and declared them
      Deleted, accounting for them.
    """
    pilotsToAccount = {}
    timeLimitToConsider = Time.toString(Time.dateTime() - Time.day * self.pilotStalledDays)
    result = self.pilotDB.selectPilots({'Status': self.queryStateList},
                                       older=timeLimitToConsider,
                                       timeStamp='LastUpdateTime')
    if not result['OK']:
      self.log.error('Failed to get the Pilot Agents')
      return result
    if not result['Value']:
      return S_OK()

    refList = result['Value']
    result = self.pilotDB.getPilotInfo(refList)
    if not result['OK']:
      self.log.error('Failed to get Info for Pilot Agents')
      return result

    pilotsDict = result['Value']

    for pRef in pilotsDict:
      if pilotsDict[pRef].get('Jobs') and self._checkJobLastUpdateTime(pilotsDict[pRef]['Jobs'], self.pilotStalledDays):
        self.log.debug('%s should not be deleted since one job of %s is running.' %
                       (str(pRef), str(pilotsDict[pRef]['Jobs'])))
        continue
      deletedJobDict = pilotsDict[pRef]
      deletedJobDict['Status'] = 'Deleted'
      deletedJobDict['StatusDate'] = Time.dateTime()
      pilotsToAccount[pRef] = deletedJobDict
      if len(pilotsToAccount) > 100:
        self.accountPilots(pilotsToAccount, connection)
        self._killPilots(pilotsToAccount)
        pilotsToAccount = {}

    self.accountPilots(pilotsToAccount, connection)
    self._killPilots(pilotsToAccount)

    return S_OK()

  def accountPilots(self, pilotsToAccount, connection):
    """ account for pilots
    """
    accountingFlag = False
    pae = self.am_getOption('PilotAccountingEnabled', 'yes')
    if pae.lower() == "yes":
      accountingFlag = True

    if not pilotsToAccount:
      self.log.info('No pilots to Account')
      return S_OK()

    accountingSent = False
    if accountingFlag:
      retVal = self.pilotDB.getPilotInfo(pilotsToAccount.keys(), conn=connection)
      if not retVal['OK']:
        self.log.error('Fail to retrieve Info for pilots', retVal['Message'])
        return retVal
      dbData = retVal['Value']
      for pref in dbData:
        if pref in pilotsToAccount:
          if dbData[pref]['Status'] not in self.finalStateList:
            dbData[pref]['Status'] = pilotsToAccount[pref]['Status']
            dbData[pref]['DestinationSite'] = pilotsToAccount[pref]['DestinationSite']
            dbData[pref]['LastUpdateTime'] = pilotsToAccount[pref]['StatusDate']
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:70,代码来源:PilotStatusAgent.py

示例3: PilotStatusAgent

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

#.........这里部分代码省略.........
      Deleted, accounting for them.
    """
    pilotsToAccount = {}
    timeLimitToConsider = Time.toString( Time.dateTime() - Time.day * self.pilotStalledDays )
    # A.T. Below looks to be a bug 
    #result = self.pilotDB.selectPilots( {'Status':self.queryStateList} , older=None, timeStamp='LastUpdateTime' )
    result = self.pilotDB.selectPilots( { 'Status':self.queryStateList} ,
                                        older = timeLimitToConsider,
                                        timeStamp = 'LastUpdateTime' )
    if not result['OK']:
      self.log.error( 'Failed to get the Pilot Agents' )
      return result
    if not result['Value']:
      return S_OK()

    refList = result['Value']
    result = self.pilotDB.getPilotInfo( refList )
    if not result['OK']:
      self.log.error( 'Failed to get Info for Pilot Agents' )
      return result

    pilotsDict = result['Value']

    for pRef in pilotsDict:
      if pilotsDict[pRef].has_key('Jobs') and len(pilotsDict[pRef]['Jobs']) > 0 and self._checkJobLastUpdateTime(pilotsDict[pRef]['Jobs'],self.pilotStalledDays):
        self.log.debug('%s should not be deleted since one job of %s is running.' % ( str(pRef) , str(pilotsDict[pRef]['Jobs']) ) )
        continue
      deletedJobDict = pilotsDict[pRef]
      deletedJobDict['Status'] = 'Deleted'
      deletedJobDict['StatusDate'] = Time.dateTime()
      pilotsToAccount[ pRef ] = deletedJobDict
      if len( pilotsToAccount ) > 100:
        self.accountPilots( pilotsToAccount, connection )
        self._killPilots( pilotsToAccount )
        pilotsToAccount = {}

    self.accountPilots( pilotsToAccount, connection )
    self._killPilots( pilotsToAccount )


    return S_OK()

  def accountPilots( self, pilotsToAccount, connection ):
    """ account for pilots
    """
    accountingFlag = False
    pae = self.am_getOption( 'PilotAccountingEnabled', 'yes' )
    if pae.lower() == "yes":
      accountingFlag = True

    if not pilotsToAccount:
      self.log.info( 'No pilots to Account' )
      return S_OK()

    accountingSent = False
    if accountingFlag:
      retVal = self.pilotDB.getPilotInfo( pilotsToAccount.keys(), conn = connection )
      if not retVal['OK']:
        self.log.error( 'Fail to retrieve Info for pilots', retVal['Message'] )
        return retVal
      dbData = retVal[ 'Value' ]
      for pref in dbData:
        if pref in pilotsToAccount:
          if dbData[pref][ 'Status' ] not in self.finalStateList:
            dbData[pref][ 'Status' ] = pilotsToAccount[pref][ 'Status' ]
            dbData[pref][ 'DestinationSite' ] = pilotsToAccount[pref][ 'DestinationSite' ]
开发者ID:cj501885963,项目名称:DIRAC,代码行数:70,代码来源:PilotStatusAgent.py


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