def queryDBSv3(self, api, **params): if not os.environ.get('X509_USER_PROXY', ''): raise UserError('VOMS proxy needed to query DBS3! Environment variable X509_USER_PROXY is not set!') proxyPath = utils.resolvePath(os.environ.get('X509_USER_PROXY', ''), mustExist = False) if not os.path.exists(proxyPath): raise UserError('VOMS proxy needed to query DBS3! Environment variable X509_USER_PROXY is "%s"' % proxyPath) return readJSON(self.url + '/%s' % api, params, cert = proxyPath)
def getPhedexSEList(self, blockPath, dictSE): dictSE[blockPath] = [] url = 'https://cmsweb.cern.ch/phedex/datasvc/json/prod/blockreplicas' for phedexBlock in readJSON(url, {'block': blockPath})['phedex']['block']: for replica in phedexBlock['replica']: if self.nodeFilter(replica['node'], replica['complete'] == 'y'): location = None if self.locationFormat == 'hostname': location = replica.get('se') elif self.locationFormat == 'sitedb': location = replica.get('node') elif self.locationFormat == 'both' and (replica.get('node') or replica.get('se')): location = '%s/%s' % (replica.get('node'), replica.get('se')) if location: dictSE[blockPath].append(location) else: utils.vprint('Warning: Dataset block %s replica at %s / %s is skipped!' % (blockPath, replica.get('node'), replica.get('se')), -1)
def getPhedexSEList(self, blockPath, dictSE): dictSE[blockPath] = [] url = 'https://cmsweb.cern.ch/phedex/datasvc/json/prod/blockreplicas' for phedexBlock in readJSON(url, {'block': blockPath})['phedex']['block']: for replica in phedexBlock['replica']: if self.nodeFilter(replica['node'], replica['complete'] == 'y'): location = None if self._locationFormat == CMSLocationFormat.hostname: location = replica.get('se') elif self._locationFormat == CMSLocationFormat.siteDB: location = replica.get('node') elif (self._locationFormat == CMSLocationFormat.both) and ( replica.get('node') or replica.get('se')): location = '%s/%s' % (replica.get('node'), replica.get('se')) if location: dictSE[blockPath].append(location) else: utils.vprint( 'Warning: Dataset block %s replica at %s / %s is skipped!' % (blockPath, replica.get('node'), replica.get('se')), -1)
def lfn2pfn(node, lfn): return readJSON('https://cmsweb.cern.ch/phedex/datasvc/json/prod/lfn2pfn', {'node': node, 'protocol': 'srmv2', 'lfn': lfn})['phedex']['mapping'][0]['pfn']
from grid_control.gc_exceptions import RuntimeError from grid_control.utils.webservice import readJSON from grid_control_cms.provider_sitedb import SiteDB def lfn2pfn(node, lfn): return readJSON('https://cmsweb.cern.ch/phedex/datasvc/json/prod/lfn2pfn', {'node': node, 'protocol': 'srmv2', 'lfn': lfn})['phedex']['mapping'][0]['pfn'] parser = optparse.OptionParser() parser.add_option('-s', '--SE', dest='SE', default=None, help='Resolve LFN on CMS SE into PFN') parser.add_option('', '--lfn', dest='lfn', default='/store/user/<hypernews name>', help='Name of default LFN') parser.add_option('', '--se-prot', dest='seprot', default='srmv2', help='Name of default SE protocol') (opts, args) = parseOptions(parser) if opts.SE: if '<hypernews name>' in opts.lfn: token = AccessToken.getInstance('VomsProxy', getConfig(), None) site_db = SiteDB() hnName = site_db.dn_to_username(dn=token.getFQUsername()) if not hnName: raise RuntimeError('Unable to map grid certificate to hypernews name!') opts.lfn = opts.lfn.replace('<hypernews name>', hnName) tmp = readJSON('https://cmsweb.cern.ch/phedex/datasvc/json/prod/lfn2pfn', {'node': opts.SE, 'protocol': opts.seprot, 'lfn': opts.lfn})['phedex']['mapping'] for entry in tmp: if len(tmp) > 1: print entry['node'], print entry['pfn']
from gcSupport import Options, Plugin, getConfig, scriptOptions from grid_control.utils.webservice import readJSON from grid_control_cms.provider_sitedb import SiteDB def lfn2pfn(node, lfn): return readJSON('https://cmsweb.cern.ch/phedex/datasvc/json/prod/lfn2pfn', {'node': node, 'protocol': 'srmv2', 'lfn': lfn})['phedex']['mapping'][0]['pfn'] parser = Options() parser.addText(None, 's', 'SE', default = None, help = 'Resolve LFN on CMS SE into PFN') parser.addText(None, ' ', 'se-prot', default = 'srmv2', help = 'Name of default SE protocol') parser.addText(None, ' ', 'lfn', default = '/store/user/<hypernews name>', help = 'Name of default LFN') options = scriptOptions(parser) if options.opts.SE: if '<hypernews name>' in options.opts.lfn: token = Plugin.getClass('AccessToken').createInstance('VomsProxy', getConfig(), None) site_db = SiteDB() hnName = site_db.dn_to_username(dn=token.getFQUsername()) if not hnName: raise Exception('Unable to map grid certificate to hypernews name!') options.opts.lfn = options.opts.lfn.replace('<hypernews name>', hnName) tmp = readJSON('https://cmsweb.cern.ch/phedex/datasvc/json/prod/lfn2pfn', {'node': options.opts.SE, 'protocol': options.opts.se_prot, 'lfn': options.opts.lfn})['phedex']['mapping'] for entry in tmp: if len(tmp) > 1: print(entry['node'] + ' ' + entry['pfn']) print(entry['pfn'])