def setUp(self): """ set up DAS core module """ debug = 0 self.db = "test_mapping.db" config = deepcopy(das_readconfig()) dburi = config["mongodb"]["dburi"] logger = PrintManager("TestDASMapping", verbose=debug) config["logger"] = logger config["verbose"] = debug dbname = "test_mapping" collname = "db" config["mappingdb"] = dict(dburi=dburi, dbname=dbname, collname=collname) # add some maps to mapping db conn = MongoClient(dburi) conn.drop_database(dbname) self.coll = conn[dbname][collname] self.pmap = { "presentation": { "block": [{"ui": "Block name", "das": "block.name"}, {"ui": "Block size", "das": "block.size"}] }, "type": "presentation", } self.coll.insert(self.pmap) ver_token = verification_token(self.coll.find(exhaust=True)) rec = {"verification_token": ver_token, "type": "verification_token"} self.coll.insert(rec) self.mgr = DASMapping(config)
def main(): """Main function""" opt_mgr = DASOptionParser() opts, _ = opt_mgr.get_opt() if opts.umap: count = 0 system = '' for rec in read_service_map(opts.umap, field='uri'): print(json.dumps(rec)) count += 1 system = rec['system'] if system: # notations map must have system arecord = {'type': 'service', 'count': count, 'system': system} print(json.dumps(dict(arecord=arecord))) # output record(s) containing uris for listing allowed input_values for rec in read_service_map(opts.umap, field='input_values'): print(json.dumps(rec)) if opts.nmap: count = 0 system = '' for rec in read_service_map(opts.nmap, field='notations'): print(json.dumps(rec)) count += 1 system = rec['system'] if system: # notations map must have system arecord = {'type': 'notation', 'count': count, 'system': system} print(json.dumps(dict(arecord=arecord))) if opts.pmap: count = 0 system = 'presentation' for rec in read_service_map(opts.pmap, field='presentation'): print(json.dumps(rec)) count += 1 if count == 1: # we should have one presentation map arecord = {'type': 'presentation', 'count': count, 'system': system} print(json.dumps(dict(arecord=arecord))) # generate a verification token composed of all record hashes if opts.get_verification_token_for: with open(opts.get_verification_token_for) as file_: token = verification_token(json.loads(line) for line in file_ if line) print(json.dumps({'verification_token': token, 'type': 'verification_token'}))
def setUp(self): """ set up DAS core module """ debug = 0 self.db = 'test_mapping.db' config = deepcopy(das_readconfig()) dburi = config['mongodb']['dburi'] logger = PrintManager('TestDASMapping', verbose=debug) config['logger'] = logger config['verbose'] = debug dbname = 'test_mapping' collname = 'db' config['mappingdb'] = dict(dburi=dburi, dbname=dbname, collname=collname) # add some maps to mapping db conn = MongoClient(dburi) conn.drop_database(dbname) self.coll = conn[dbname][collname] self.pmap = {"presentation": {"block":[{"ui": "Block name", "das": "block.name"}, {"ui": "Block size", "das": "block.size"}]}, "type": "presentation"} self.coll.insert(self.pmap) url = 'https://cmsweb.cern.ch/dbs/prod/global/DBSReader/acquisitioneras/' dformat = 'JSON' system = 'dbs3' expire = 100 rec = {'system':system, 'urn': 'acquisitioneras', 'format':dformat, 'instances': ['prod/global'], 'url':url, 'expire': expire, 'lookup': 'era', 'params' : {}, 'das_map': [ {"das_key": "era", "rec_key":"era.name", "api_arg":"era"} ], 'type': 'service' } self.coll.insert(rec) ver_token = verification_token(self.coll.find(**PYMONGO_OPTS)) rec = {'verification_token':ver_token, 'type':'verification_token'} self.coll.insert(rec) self.mgr = DASMapping(config)
def setUp(self): """ set up DAS core module """ debug = 0 self.db = 'test_mapping.db' config = deepcopy(das_readconfig()) dburi = config['mongodb']['dburi'] logger = PrintManager('TestDASMapping', verbose=debug) config['logger'] = logger config['verbose'] = debug dbname = 'test_mapping' collname = 'db' config['mappingdb'] = dict(dburi=dburi, dbname=dbname, collname=collname) # add some maps to mapping db conn = MongoClient(dburi) conn.drop_database(dbname) self.coll = conn[dbname][collname] self.pmap = { "presentation": { "block": [{ "ui": "Block name", "das": "block.name" }, { "ui": "Block size", "das": "block.size" }] }, "type": "presentation" } self.coll.insert(self.pmap) url = 'https://cmsweb.cern.ch/dbs/prod/global/DBSReader/acquisitioneras/' dformat = 'JSON' system = 'dbs3' expire = 100 rec = { 'system': system, 'urn': 'acquisitioneras', 'format': dformat, 'instances': ['prod/global'], 'url': url, 'expire': expire, 'lookup': 'era', 'params': {}, 'das_map': [{ "das_key": "era", "rec_key": "era.name", "api_arg": "era" }], 'type': 'service' } self.coll.insert(rec) ver_token = verification_token(self.coll.find(**PYMONGO_OPTS)) rec = {'verification_token': ver_token, 'type': 'verification_token'} self.coll.insert(rec) self.mgr = DASMapping(config)