def _run(self): """Check for migration bit, set file done when migrated.""" self.waitingFiles = self.getWaitingFilesList() self.log.notice("Waiting files:", len(self.waitingFiles)) targetSESet = set(self.operation.targetSEList) self.log.notice("Target SEs:", ",".join(targetSESet)) migrated = True for opFile in self.waitingFiles: self.log.notice("Checking:", opFile.LFN) for targetSE in targetSESet: se = StorageElement(targetSE) if not se.status()["TapeSE"]: migrated = True and migrated continue metaData = returnSingleResult(se.getFileMetadata(opFile.LFN)) self.log.debug("MetaData: %s" % pformat(metaData)) if not metaData["OK"]: self.log.error("Failed to get metadata:", "%s: %s" % (opFile.LFN, metaData["Message"])) migrated = False continue migrated = metaData["Value"].get("Migrated", 0) == 1 and migrated if migrated: self.log.notice("File has been migrated:", opFile.LFN) opFile.Status = "Done" else: self.log.notice("File has NOT been migrated:", opFile.LFN) now = datetime.datetime.utcnow().replace(microsecond=0) extraDelay = datetime.timedelta(minutes=20) self.request.NotBefore = now + extraDelay
def _run(self): """Check for migration bit, set file done when migrated.""" self.waitingFiles = self.getWaitingFilesList() self.log.notice('Waiting files:', len(self.waitingFiles)) targetSESet = set(self.operation.targetSEList) self.log.notice('Target SEs:', ','.join(targetSESet)) migrated = True for opFile in self.waitingFiles: self.log.notice('Checking:', opFile.LFN) for targetSE in targetSESet: se = StorageElement(targetSE) if not se.status()['TapeSE']: migrated = True and migrated continue metaData = returnSingleResult(se.getFileMetadata(opFile.LFN)) self.log.debug('MetaData: %s' % pformat(metaData)) if not metaData['OK']: self.log.error( 'Failed to get metadata:', '%s: %s' % (opFile.LFN, metaData['Message'])) migrated = False continue migrated = metaData['Value'].get('Migrated', 0) == 1 and migrated if migrated: self.log.notice('File has been migrated:', opFile.LFN) opFile.Status = 'Done' else: self.log.notice('File has NOT been migrated:', opFile.LFN) now = datetime.datetime.utcnow().replace(microsecond=0) extraDelay = datetime.timedelta(minutes=20) self.request.NotBefore = now + extraDelay
def printSEInfo(voName): fields = ("SE", "Status", "Protocols", "Aliases") records = [] for se in DMSHelpers(voName).getStorageElements( ): # this will get the full list of SEs, not only the vo's ones. seObject = StorageElement(se) if not (seObject.vo and voName in seObject.vo.strip().split(",") or not seObject.voName): continue result = seObject.status() status = [] for statusType in ["Write", "Read"]: if result[statusType]: status.append(statusType) if status: status = "/".join(status) else: status = "InActive" records.append((se, status, ",".join([ seProtocol["Protocol"] for seProtocol in seObject.protocolOptions ]))) gLogger.notice( printTable(fields, records, printOut=False, columnSeparator=" ")) return S_OK()
def printSEInfo(voName): result = Resources.getStorageElements(vo=voName) if not result['OK']: gLogger.error('Failed to get SE information') DIRACExit(-1) seDict = result['Value'] fields = ('SE', 'Status', 'Protocols', 'Aliases') records = [] for se in seDict: seObject = StorageElement(se) result = seObject.status() status = [] for statusType in ['Write', 'Read']: if result[statusType]: status.append(statusType) if status: status = '/'.join(status) else: status = "InActive" records.append((se, status, ",".join(seDict[se]["Protocols"]), ",".join(seDict[se]["Aliases"]))) gLogger.notice( printTable(fields, records, printOut=False, columnSeparator=' ')) return S_OK()