Пример #1
0
 def mapLFN(self, site, lfn, protocol=None):
     """Map LFN to given site"""
     if not protocol:
         protocol = 'srmv2'
     data = {'lfn': lfn, 'node': site}
     if protocol:
         data['protocol'] = protocol
     self.log.info("Mapping LFN %s for site %s using PhEDEx datasvc." % \
         (lfn, site))
     data = phedex_datasvc('lfn2pfn', self.phedex_url, **data)
     try:
         pfn = data['phedex']['mapping'][0]['pfn']
     except:
         raise Exception("PhEDEx data service did not return a PFN!")
     self.log.info("PhEDEx data service returned PFN %s for LFN %s." % \
         (pfn, lfn))
     return pfn
Пример #2
0
 def replicas(self, lfn, token=None, user=None):
     """Find LFN replicas in PhEDEx data-service"""
     self.log.info("Looking for the block of LFN %s." % lfn)
     block = self._dbs.blockLookup(lfn)
     query = {'block':block}
     self.log.info("Looking for replicas of %s" % block)
     results = phedex_datasvc('fileReplicas', self.phedex_url, block=block)
     blocks = [i for i in results['phedex']['block'] \
             if i.get('name', None) == block]
     if not blocks:
         raise Exception("Requested LFN does not exist in any block known " \
             "to PhEDEx.")
     block = blocks[0]
     files = [i for i in block.get('file', []) \
             if i.get('name', None) == lfn]
     if not files:
         raise Exception("Internal error: PhEDEx does not think LFN is in " \
             "the same block as DBS does.")
     file = files[0]
     replicas = [i['node'] for i in file.get('replica', []) if 'node' in i]
     self.log.info("There are the following replicas of %s: %s." % \
         (lfn, ', '.join(replicas)))
     return replicas