コード例 #1
0
    def _getDirectoryPhysicalSizeFromUsage(self, lfns, connection):
        """ Get the total size of the requested directories
    """
        paths = lfns.keys()
        successful = {}
        failed = {}
        for path in paths:
            result = self.findDir(path)
            if not result['OK']:
                failed[path] = "Directory not found"
                continue
            if not result['Value']:
                failed[path] = "Directory not found"
                continue
            dirID = result['Value']

            req = "SELECT S.SEID, S.SEName, D.SESize, D.SEFiles FROM FC_DirectoryUsage as D, FC_StorageElements as S"
            req += "  WHERE S.SEID=D.SEID AND D.DirID=%d" % dirID
            result = self.db._query(req, connection)
            if not result['OK']:
                failed[path] = result['Message']
            elif not result['Value']:
                successful[path] = {}
            elif result['Value'][0][0]:
                seDict = {}
                totalSize = 0
                totalFiles = 0
                for seID, seName, seSize, seFiles in result['Value']:
                    if seSize or seFiles:
                        seDict[seName] = {'Size': seSize, 'Files': seFiles}
                        totalSize += seSize
                        totalFiles += seFiles
                    else:
                        req = 'DELETE FROM FC_DirectoryUsage WHERE SEID=%d AND DirID=%d' % (
                            seID, dirID)
                        result = self.db._update(req)
                        if not result['OK']:
                            gLogger(
                                'Failed to delete entry from FC_DirectoryUsage',
                                result['Message'])
                seDict['TotalSize'] = int(totalSize)
                seDict['TotalFiles'] = int(totalFiles)
                successful[path] = seDict
            else:
                successful[path] = {}

        return S_OK({'Successful': successful, 'Failed': failed})
コード例 #2
0
ファイル: AgentReactor.py プロジェクト: hanyl/DIRAC
 def runNumCycles( self, agentName = None, numCycles = 1 ):
   """
     Run all defined agents a given number of cycles
   """
   if agentName:
     self.loadAgentModule( agentName )
   error = ''
   for aName in self.__agentModules:
     result = self.setAgentModuleCyclesToExecute( aName, numCycles )
     if not result['OK']:
       error = 'Failed to set cycles to execute'
       gLogger( '%s:' % error, aName )
       break
   if error:
     return S_ERROR( error )
   self.go()
   return S_OK()
コード例 #3
0
 def runNumCycles(self, agentName=None, numCycles=1):
     """
   Run all defined agents a given number of cycles
 """
     if agentName:
         self.loadAgentModules([agentName])
     error = ''
     for aName in self.__agentModules:
         result = self.setAgentModuleCyclesToExecute(aName, numCycles)
         if not result['OK']:
             error = 'Failed to set cycles to execute'
             gLogger('%s:' % error, aName)
             break
     if error:
         return S_ERROR(error)
     self.go()
     return S_OK()
コード例 #4
0
ファイル: DirectoryTreeBase.py プロジェクト: kanwx/DIRAC
  def _getDirectoryPhysicalSizeFromUsage(self,lfns,connection):
    """ Get the total size of the requested directories
    """
    paths = lfns.keys()
    successful = {}
    failed = {}
    for path in paths:
      result = self.findDir(path)
      if not result['OK']:
        failed[path] = "Directory not found"
        continue
      if not result['Value']:
        failed[path] = "Directory not found"
        continue
      dirID = result['Value']

      req = "SELECT S.SEID, S.SEName, D.SESize, D.SEFiles FROM FC_DirectoryUsage as D, FC_StorageElements as S"
      req += "  WHERE S.SEID=D.SEID AND D.DirID=%d" % dirID
      result = self.db._query(req,connection)
      if not result['OK']:
        failed[path] = result['Message']
      elif not result['Value']:
        successful[path] = {}
      elif result['Value'][0][0]:
        seDict = {}
        totalSize = 0
        totalFiles = 0
        for seID, seName,seSize,seFiles in result['Value']:
          if seSize or seFiles:
            seDict[seName] = {'Size':seSize,'Files':seFiles}
            totalSize += seSize
            totalFiles += seFiles
          else:
            req = 'DELETE FROM FC_DirectoryUsage WHERE SEID=%d AND DirID=%d' % ( seID, dirID )
            result = self.db._update( req )
            if not result['OK']:
              gLogger( 'Failed to delete entry from FC_DirectoryUsage', result['Message'] )
        seDict['TotalSize'] = int(totalSize)
        seDict['TotalFiles'] = int(totalFiles)
        successful[path] = seDict
      else:
        successful[path] = {}

    return S_OK({'Successful':successful,'Failed':failed})
コード例 #5
0
args = Script.getPositionalArgs()
if len(args):
    iKey = args[0]
print '*INFO* looking for key %s'%iKey
# first, get all jobs which are marked as stalled
status = "Failed"
minor_stat = "Job stalled: pilot not running"
owner = "zimmer"
dirac = Dirac()
jobs = []
conditions = {"Status":status,"MinorStatus":minor_stat,"Owner":owner}
res = dirac.selectJobs( status = status,
                       minorStatus = minor_stat,
                       owner = owner)
if not res['OK']:
    gLogger("ERROR retrieving jobs")
    gLogger(res["Message"])
    exitCode = 2
else:
    conds = []
    for n, v in conditions.items():
        if v:
            conds.append( '%s = %s' % ( n, v ) )
    jobs = res['Value']
pilot_refs = {}
for job in jobs:
    # next get pilot refs
    key = job
    res = dirac.parameters( job, printOutput = False )
    if not res['OK']:
        gLogger.error("ERROR retrieving job parameters")