當前位置: 首頁>>代碼示例>>Python>>正文


Python PilotAgentsDB.deletePilot方法代碼示例

本文整理匯總了Python中DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB.deletePilot方法的典型用法代碼示例。如果您正苦於以下問題:Python PilotAgentsDB.deletePilot方法的具體用法?Python PilotAgentsDB.deletePilot怎麽用?Python PilotAgentsDB.deletePilot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB的用法示例。


在下文中一共展示了PilotAgentsDB.deletePilot方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PilotStatusAgent

# 需要導入模塊: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB [as 別名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB import deletePilot [as 別名]

#.........這裏部分代碼省略.........
            "OwnerGroup": condDict["OwnerGroup"],
            "GridType": condDict["GridType"],
            "Broker": condDict["Broker"],
        }
        result = self.pilotDB.selectPilots(clearDict, older=last_update)
        if not result["OK"]:
            self.log.warn("Failed to get the Pilot Agents fpr Waiting state")
            return result
        if not result["Value"]:
            return S_OK()
        refList = result["Value"]

        for pilotRef in refList:
            self.log.info("Setting Waiting pilot to Aborted: %s" % pilotRef)
            result = self.pilotDB.setPilotStatus(pilotRef, "Stalled", statusReason="Exceeded max waiting time")

        return S_OK()

    def clearParentJob(self, pRef, pDict, connection):
        """ Clear the parameteric parent job from the PilotAgentsDB
    """

        childList = pDict["ChildRefs"]

        # Check that at least one child is in the database
        children_ok = False
        for child in childList:
            result = self.pilotDB.getPilotInfo(child, conn=connection)
            if result["OK"]:
                if result["Value"]:
                    children_ok = True

        if children_ok:
            return self.pilotDB.deletePilot(pRef, conn=connection)
        else:
            self.log.verbose("Adding children for parent %s" % pRef)
            result = self.pilotDB.getPilotInfo(pRef)
            parentInfo = result["Value"][pRef]
            tqID = parentInfo["TaskQueueID"]
            ownerDN = parentInfo["OwnerDN"]
            ownerGroup = parentInfo["OwnerGroup"]
            broker = parentInfo["Broker"]
            gridType = parentInfo["GridType"]
            result = self.pilotDB.addPilotTQReference(
                childList, tqID, ownerDN, ownerGroup, broker=broker, gridType=gridType
            )
            if not result["OK"]:
                return result
            children_added = True
            for chRef, chDict in pDict["ChildDicts"].items():
                result = self.pilotDB.setPilotStatus(
                    chRef, chDict["Status"], destination=chDict["DestinationSite"], conn=connection
                )
                if not result["OK"]:
                    children_added = False
            if children_added:
                result = self.pilotDB.deletePilot(pRef, conn=connection)
            else:
                return S_ERROR("Failed to add children")
        return S_OK()

    def handleOldPilots(self, connection):
        """
      select all pilots that have not been updated in the last N days and declared them 
      Deleted, accounting for them.
    """
開發者ID:sposs,項目名稱:DIRAC,代碼行數:70,代碼來源:PilotStatusAgent.py

示例2: test_PilotsDB

# 需要導入模塊: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB [as 別名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB import deletePilot [as 別名]
  def test_PilotsDB( self ):

    wmsAdministrator = RPCClient( 'WorkloadManagement/WMSAdministrator' )
    pilotAgentDB = PilotAgentsDB()


    res = wmsAdministrator.addPilotTQReference( ['aPilot'], 1, '/a/ownerDN', 'a/owner/Group' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'Submitted': 1L} )
    res = pilotAgentDB.deletePilot( 'aPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {} )

    res = wmsAdministrator.addPilotTQReference( ['anotherPilot'], 1, '/a/ownerDN', 'a/owner/Group' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.storePilotOutput( 'anotherPilot', 'This is an output', 'this is an error' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotOutput( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'OwnerDN': '/a/ownerDN',
                                     'OwnerGroup': 'a/owner/Group',
                                     'StdErr': 'this is an error',
                                     'FileList': [],
                                     'StdOut': 'This is an output'} )
    # need a job for the following
#     res = wmsAdministrator.getJobPilotOutput( 1 )
#     self.assertEqual( res['Value'], {'OwnerDN': '/a/ownerDN', 'OwnerGroup': 'a/owner/Group',
#                                      'StdErr': 'this is an error', 'FileList': [], 'StdOut': 'This is an output'} )
#     self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotInfo( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['anotherPilot']['AccountingSent'], 'False' )
    self.assertEqual( res['Value']['anotherPilot']['PilotJobReference'], 'anotherPilot' )

    res = wmsAdministrator.selectPilots( {} )
    self.assert_( res['OK'] )
#     res = wmsAdministrator.getPilotLoggingInfo( 'anotherPilot' )
#     self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotSummary( '', '' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['Total']['Submitted'], 1 )
    res = wmsAdministrator.getPilotMonitorWeb( {}, [], 0, 100 )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['TotalRecords'], 1 )
    res = wmsAdministrator.getPilotMonitorSelectors()
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'GridType': ['DIRAC'], 
                                     'OwnerGroup': ['a/owner/Group'], 
                                     'DestinationSite': ['NotAssigned'], 
                                     'Broker': ['Unknown'], 'Status': ['Submitted'], 
                                     'OwnerDN': ['/a/ownerDN'], 
                                     'GridSite': ['Unknown'], 
                                     'Owner': []} )
    res = wmsAdministrator.getPilotSummaryWeb( {}, [], 0, 100 )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['TotalRecords'], 1 )

    res = wmsAdministrator.setAccountingFlag( 'anotherPilot', 'True' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.setPilotStatus( 'anotherPilot', 'Running' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotInfo( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['anotherPilot']['AccountingSent'], 'True' )
    self.assertEqual( res['Value']['anotherPilot']['Status'], 'Running' )

    res = wmsAdministrator.setJobForPilot( 123, 'anotherPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.setPilotBenchmark( 'anotherPilot', 12.3 )
    self.assert_( res['OK'] )
    res = wmsAdministrator.countPilots( {} )
    self.assert_( res['OK'] )
#     res = wmsAdministrator.getCounters()
#     # getPilotStatistics

    res = pilotAgentDB.deletePilot( 'anotherPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {} )
開發者ID:avedaee,項目名稱:TestDIRAC,代碼行數:86,代碼來源:TestClientWMS.py

示例3: PilotStatusAgent

# 需要導入模塊: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB [as 別名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB import deletePilot [as 別名]

#.........這裏部分代碼省略.........
                 'OwnerDN': condDict['OwnerDN'],
                 'OwnerGroup': condDict['OwnerGroup'],
                 'GridType': condDict['GridType'],
                 'Broker': condDict['Broker']}
    result = self.pilotDB.selectPilots(clearDict, older=last_update)
    if not result['OK']:
      self.log.warn('Failed to get the Pilot Agents for Waiting state')
      return result
    if not result['Value']:
      return S_OK()
    refList = result['Value']

    for pilotRef in refList:
      self.log.info('Setting Waiting pilot to Stalled: %s' % pilotRef)
      result = self.pilotDB.setPilotStatus(pilotRef, 'Stalled', statusReason='Exceeded max waiting time')

    return S_OK()

  def clearParentJob(self, pRef, pDict, connection):
    """ Clear the parameteric parent job from the PilotAgentsDB
    """

    childList = pDict['ChildRefs']

    # Check that at least one child is in the database
    children_ok = False
    for child in childList:
      result = self.pilotDB.getPilotInfo(child, conn=connection)
      if result['OK']:
        if result['Value']:
          children_ok = True

    if children_ok:
      return self.pilotDB.deletePilot(pRef, conn=connection)
    else:
      self.log.verbose('Adding children for parent %s' % pRef)
      result = self.pilotDB.getPilotInfo(pRef)
      parentInfo = result['Value'][pRef]
      tqID = parentInfo['TaskQueueID']
      ownerDN = parentInfo['OwnerDN']
      ownerGroup = parentInfo['OwnerGroup']
      broker = parentInfo['Broker']
      gridType = parentInfo['GridType']
      result = self.pilotDB.addPilotTQReference(childList, tqID, ownerDN, ownerGroup,
                                                broker=broker, gridType=gridType)
      if not result['OK']:
        return result
      children_added = True
      for chRef, chDict in pDict['ChildDicts'].items():
        result = self.pilotDB.setPilotStatus(chRef, chDict['Status'],
                                             destination=chDict['DestinationSite'],
                                             conn=connection)
        if not result['OK']:
          children_added = False
      if children_added:
        result = self.pilotDB.deletePilot(pRef, conn=connection)
      else:
        return S_ERROR('Failed to add children')
    return S_OK()

  def handleOldPilots(self, connection):
    """
      select all pilots that have not been updated in the last N days and declared them
      Deleted, accounting for them.
    """
    pilotsToAccount = {}
開發者ID:DIRACGrid,項目名稱:DIRAC,代碼行數:70,代碼來源:PilotStatusAgent.py

示例4: PilotStatusAgent

# 需要導入模塊: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB [as 別名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB import deletePilot [as 別名]

#.........這裏部分代碼省略.........
                 'OwnerDN':condDict['OwnerDN'],
                 'OwnerGroup':condDict['OwnerGroup'],
                 'GridType':condDict['GridType'],
                 'Broker':condDict['Broker']}
    result = self.pilotDB.selectPilots( clearDict, older = last_update )
    if not result['OK']:
      self.log.warn( 'Failed to get the Pilot Agents for Waiting state' )
      return result
    if not result['Value']:
      return S_OK()
    refList = result['Value']

    for pilotRef in refList:
      self.log.info( 'Setting Waiting pilot to Aborted: %s' % pilotRef )
      result = self.pilotDB.setPilotStatus( pilotRef, 'Stalled', statusReason = 'Exceeded max waiting time' )

    return S_OK()

  def clearParentJob( self, pRef, pDict, connection ):
    """ Clear the parameteric parent job from the PilotAgentsDB
    """

    childList = pDict['ChildRefs']

    # Check that at least one child is in the database
    children_ok = False
    for child in childList:
      result = self.pilotDB.getPilotInfo( child, conn = connection )
      if result['OK']:
        if result['Value']:
          children_ok = True

    if children_ok:
      return self.pilotDB.deletePilot( pRef, conn = connection )
    else:
      self.log.verbose( 'Adding children for parent %s' % pRef )
      result = self.pilotDB.getPilotInfo( pRef )
      parentInfo = result['Value'][pRef]
      tqID = parentInfo['TaskQueueID']
      ownerDN = parentInfo['OwnerDN']
      ownerGroup = parentInfo['OwnerGroup']
      broker = parentInfo['Broker']
      gridType = parentInfo['GridType']
      result = self.pilotDB.addPilotTQReference( childList, tqID, ownerDN, ownerGroup,
                                                broker = broker, gridType = gridType )
      if not result['OK']:
        return result
      children_added = True
      for chRef, chDict in pDict['ChildDicts'].items():
        result = self.pilotDB.setPilotStatus( chRef, chDict['Status'],
                                             destination = chDict['DestinationSite'],
                                             conn = connection )
        if not result['OK']:
          children_added = False
      if children_added :
        result = self.pilotDB.deletePilot( pRef, conn = connection )
      else:
        return S_ERROR( 'Failed to add children' )
    return S_OK()

  def handleOldPilots( self, connection ):
    """
      select all pilots that have not been updated in the last N days and declared them 
      Deleted, accounting for them.
    """
    pilotsToAccount = {}
開發者ID:cj501885963,項目名稱:DIRAC,代碼行數:70,代碼來源:PilotStatusAgent.py


注:本文中的DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB.PilotAgentsDB.deletePilot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。