예제 #1
0
파일: ReqClient.py 프로젝트: thom991/DIRAC
def printFTSJobs(request):
    """ Prints the FTSJobs associated to a request

      :param request: Request object
  """

    try:
        if request.RequestID:

            # We try first the new FTS3 system

            from DIRAC.DataManagementSystem.Client.FTS3Client import FTS3Client
            fts3Client = FTS3Client()
            res = fts3Client.ping()

            if res['OK']:
                associatedFTS3Jobs = []
                for op in request:
                    res = fts3Client.getOperationsFromRMSOpID(op.OperationID)
                    if res['OK']:
                        for fts3Op in res['Value']:
                            associatedFTS3Jobs.extend(fts3Op.ftsJobs)
                if associatedFTS3Jobs:
                    gLogger.always(
                        '\n\nFTS3 jobs associated: \n%s' %
                        '\n'.join('%s@%s (%s)' %
                                  (job.ftsGUID, job.ftsServer, job.status)
                                  for job in associatedFTS3Jobs))
                return

            # If we are here, the attempt with the new FTS3 system did not work, let's try the old FTS system
            gLogger.debug("Could not instantiate FTS3Client", res)
            from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient
            ftsClient = FTSClient()
            res = ftsClient.ping()
            if not res['OK']:
                gLogger.debug("Could not instantiate FtsClient", res)
                return

            res = ftsClient.getFTSJobsForRequest(request.RequestID)
            if res['OK']:
                ftsJobs = res['Value']
                if ftsJobs:
                    gLogger.always('         FTS jobs associated: %s' %
                                   ','.join('%s (%s)' %
                                            (job.FTSGUID, job.Status)
                                            for job in ftsJobs))

    # ImportError can be thrown for the old client
    # AttributeError can be thrown because the deserialization will not have
    # happened correctly on the new fts3 (CC7 typically), and the error is not
    # properly propagated
    except (ImportError, AttributeError) as err:
        gLogger.debug("Could not instantiate FtsClient because of Exception",
                      repr(err))
예제 #2
0
def printFTSJobs(request):
  """ Prints the FTSJobs associated to a request

      :param request: Request object
  """

  try:
    if request.RequestID:

      # We try first the new FTS3 system

      from DIRAC.DataManagementSystem.Client.FTS3Client import FTS3Client
      fts3Client = FTS3Client()
      res = fts3Client.ping()

      if res['OK']:
        associatedFTS3Jobs = []
        for op in request:
          res = fts3Client.getOperationsFromRMSOpID(op.OperationID)
          if res['OK']:
            for fts3Op in res['Value']:
              associatedFTS3Jobs.extend(fts3Op.ftsJobs)
        if associatedFTS3Jobs:
          gLogger.always(
              '\n\nFTS3 jobs associated: \n%s' %
              '\n'.join(
                  '%s@%s (%s)' %
                  (job.ftsGUID,
                   job.ftsServer,
                   job.status) for job in associatedFTS3Jobs))
        return

      # If we are here, the attempt with the new FTS3 system did not work, let's try the old FTS system
      gLogger.debug("Could not instantiate FTS3Client", res)
      from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient
      ftsClient = FTSClient()
      res = ftsClient.ping()
      if not res['OK']:
        gLogger.debug("Could not instantiate FtsClient", res)
        return

      res = ftsClient.getFTSJobsForRequest(request.RequestID)
      if res['OK']:
        ftsJobs = res['Value']
        if ftsJobs:
          gLogger.always('         FTS jobs associated: %s' % ','.join('%s (%s)' % (job.FTSGUID, job.Status)
                                                                       for job in ftsJobs))

  # ImportError can be thrown for the old client
  # AttributeError can be thrown because the deserialization will not have
  # happened correctly on the new fts3 (CC7 typically), and the error is not
  # properly propagated
  except (ImportError, AttributeError) as err:
    gLogger.debug("Could not instantiate FtsClient because of Exception", repr(err))
예제 #3
0
def printRequest(request, status=None, full=False, verbose=True, terse=False):
    global output

    ftsClient = None
    try:
        if request.RequestID:
            from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient
            ftsClient = FTSClient()
            res = ftsClient.ping()
            if not res['OK']:
                gLogger.debug("Could not instantiate FtsClient", res)
                ftsClient = None
    except ImportError as err:
        gLogger.debug("Could not instantiate FtsClient because of Exception",
                      repr(err))

    if full:
        output = ''
        prettyPrint(json.loads(request.toJSON()['Value']))
        gLogger.always(output)
    else:
        if not status:
            status = request.Status
        gLogger.always(
            "Request name='%s' ID=%s Status='%s'%s%s%s" %
            (request.RequestName, request.RequestID if hasattr(
                request, 'RequestID') else '(not set yet)', request.Status,
             " ('%s' in DB)" % status if status != request.Status else '',
             (" Error='%s'" % request.Error)
             if request.Error and request.Error.strip() else "",
             (" Job=%s" % request.JobID) if request.JobID else ""))
        gLogger.always("Created %s, Updated %s%s" %
                       (request.CreationTime, request.LastUpdate,
                        (", NotBefore %s" %
                         request.NotBefore) if request.NotBefore else ""))
        if request.OwnerDN:
            gLogger.always("Owner: '%s', Group: %s" %
                           (request.OwnerDN, request.OwnerGroup))
        for indexOperation in enumerate(request):
            op = indexOperation[1]
            if not terse or op.Status == 'Failed':
                printOperation(indexOperation, verbose, onlyFailed=terse)

    if ftsClient:
        # Check if FTS job exists
        res = ftsClient.getFTSJobsForRequest(request.RequestID)
        if res['OK']:
            ftsJobs = res['Value']
            if ftsJobs:
                gLogger.always('         FTS jobs associated: %s' %
                               ','.join('%s (%s)' % (job.FTSGUID, job.Status)
                                        for job in ftsJobs))
예제 #4
0
def printFTSJobs(request):
  """ Prints the FTSJobs associated to a request

      :param request: Request object
  """

  try:
    if request.RequestID:

      # We try first the new FTS3 system

      from DIRAC.DataManagementSystem.Client.FTS3Client import FTS3Client
      fts3Client = FTS3Client()
      res = fts3Client.ping()

      if res['OK']:
        associatedFTS3Jobs = []
        for op in request:
          res = fts3Client.getOperationsFromRMSOpID(op.OperationID)
          if res['OK']:
            for fts3Op in res['Value']:
              associatedFTS3Jobs.extend(fts3Op.ftsJobs)
        if associatedFTS3Jobs:
          gLogger.always(
              '\n\nFTS3 jobs associated: \n%s' %
              '\n'.join(
                  '%s@%s (%s)' %
                  (job.ftsGUID,
                   job.ftsServer,
                   job.status) for job in associatedFTS3Jobs))
        return

      # If we are here, the attempt with the new FTS3 system did not work, let's try the old FTS system
      gLogger.debug("Could not instantiate FTS3Client", res)
      from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient
      ftsClient = FTSClient()
      res = ftsClient.ping()
      if not res['OK']:
        gLogger.debug("Could not instantiate FtsClient", res)
        return

      res = ftsClient.getFTSJobsForRequest(request.RequestID)
      if res['OK']:
        ftsJobs = res['Value']
        if ftsJobs:
          gLogger.always('         FTS jobs associated: %s' % ','.join('%s (%s)' % (job.FTSGUID, job.Status)
                                                                       for job in ftsJobs))

  except ImportError as err:
    gLogger.debug("Could not instantiate FtsClient because of Exception", repr(err))