def printRequest( request, status = None, full = False, verbose = True, terse = False ): from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient global output ftsClient = FTSClient() if full: output = '' prettyPrint( 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, 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" % ( request.CreationTime, request.LastUpdate ) ) 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 ) # 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] ) )
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))
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))
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))
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))
args = Script.getPositionalArgs() if len(args) != 1: Script.showHelp() try: requestID = long(args[0]) except ValueError: DIRAC.gLogger.error("requestID should be an integer") DIRAC.exit(-1) from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient from DIRAC.DataManagementSystem.Client.FTSJob import FTSJob ftsClient = FTSClient() ftsJobs = ftsClient.getFTSJobsForRequest( requestID, list(FTSJob.INITSTATES + FTSJob.TRANSSTATES + FTSJob.FINALSTATES)) if not ftsJobs["OK"]: DIRAC.gLogger.error(ftsJobs["Message"]) DIRAC.exit(-1) ftsJobs = ftsJobs["Value"] if not ftsJobs: DIRAC.gLogger.always("No FTSJobs found for requestID %s" % requestID) DIRAC.exit(0) DIRAC.gLogger.always("Found %s FTSJobs for requestID %s" % (len(ftsJobs), requestID)) jobKeys = ("SourceSE", "TargetSE", "Status", "Files", "Size", "Completeness", "CreationTime", "SubmitTime", "LastUpdate",
args = Script.getPositionalArgs() if len( args ) != 1: Script.showHelp() try: requestID = long( args[0] ) except ValueError: DIRAC.gLogger.error( "requestID should be an integer" ) DIRAC.exit( -1 ) from DIRAC.DataManagementSystem.Client.FTSClient import FTSClient from DIRAC.DataManagementSystem.Client.FTSJob import FTSJob ftsClient = FTSClient() ftsJobs = ftsClient.getFTSJobsForRequest( requestID, list( FTSJob.INITSTATES + FTSJob.TRANSSTATES + FTSJob.FINALSTATES ) ) if not ftsJobs["OK"]: DIRAC.gLogger.error( ftsJobs["Message"] ) DIRAC.exit( -1 ) ftsJobs = ftsJobs["Value"] if not ftsJobs: DIRAC.gLogger.always( "No FTSJobs found for requestID %s" % requestID ) DIRAC.exit( 0 ) DIRAC.gLogger.always( "Found %s FTSJobs for requestID %s" % ( len( ftsJobs ), requestID ) ) jobKeys = ( "SourceSE", "TargetSE", "Status", "Files", "Size", "Completeness", "CreationTime", "SubmitTime", "LastUpdate", "Error" ) fileKeys = ( "SourceSURL", "TargetSURL", "Attempt", "Status", "Error" ) for i, ftsJob in enumerate( ftsJobs ) :