Skip to content
Snippets Groups Projects

[WIP] TransferDataAgent

Closed Hamza Zafar requested to merge hazafar/ILCDIRAC:transferDataAgent into Rel-v28r0
3 files
+ 263
0
Compare changes
  • Side-by-side
  • Inline
Files
3
__RCSID__ = "$Id $"
from DIRAC import S_OK
from DIRAC.DataManagementSystem.Agent.RequestOperations.RemoveReplica import RemoveReplica
from DIRAC.FrameworkSystem.Client.MonitoringClient import gMonitor
from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient
class RemoveReplicaWithCheck(RemoveReplica):
""" RemoveReplicaWithCheck class """
def __init__( self, operation = None, csPath = None ):
"""c'tor
:param self: self reference
:param Operation operation: operation to execute
:param str csPath: CS path for this handler
"""
# # base class ctor
RemoveReplica.__init__(self, operation, csPath)
self.fcClient = FileCatalogClient()
def __call__( self ):
""" remove replicas """
sourceSE = self.operation.SourceSE
targetSE = self.operation.TargetSE
fileIndices = []
for i in range(len(self.operation)):
opFile = self.operation[i]
lfn = opFile.LFN
res = self.fcClient.getReplicas(lfn)
if not res['OK']:
self.log.error('Failed to get replicas for LFN: %s, Error: %s' % (lfn, res['Message']))
continue
self.log.info(res['Value'])
if sourceSE not in res['Value']['Successful'][lfn]:
self.log.warn('File %s is lost on %s, skip removal from se %s' % (lfn, sourceSE, targetSE))
fileIndices.append(i)
if self.TargetSE not in res['Value']['Successful'][lfn]:
self.log.warn('File %s is already removed from %s ' % self.TargetSE)
for index in fileIndices:
del self.operation[index]
return super(RemoveReplicaWithCheck, self).__call__()
Loading