1 import FWCore.ParameterSet.Config
as cms
3 GlobalTag.connect =
"frontier://(proxyurl=http://localhost:3128)(serverurl=http://localhost:8000/FrontierOnProd)(serverurl=http://localhost:8000/FrontierOnProd)(retrieve-ziplevel=0)(failovertoserver=no)/CMS_CONDITIONS"
4 GlobalTag.pfnPrefix = cms.untracked.string(
"frontier://(proxyurl=http://localhost:3128)(serverurl=http://localhost:8000/FrontierOnProd)(serverurl=http://localhost:8000/FrontierOnProd)(retrieve-ziplevel=0)(failovertoserver=no)/")
5 GlobalTag.globaltag =
"GR_E_V42"
6 es_prefer_GlobalTag = cms.ESPrefer(
'PoolDBESSource',
'GlobalTag')
12 tier0DasUrl =
'https://cmsweb.cern.ch/t0wmadatasvc/prod/'
22 Class handling common Tier0-DAS queries and connected utilities
24 def __init__(self, url = 'https://cmsweb.cern.ch/t0wmadatasvc/prod/
', proxy = None ):
26 Need base url for Tier0-DAS as input
37 Get the JSON file for a give query specified via the Tier0-DAS url.
38 Timeout can be set via paramter.
46 opener = urllib2.build_opener(urllib2.HTTPHandler(),
47 urllib2.HTTPSHandler(),
48 urllib2.ProxyHandler({
'http':self.
_proxy,
'https':self.
_proxy}))
49 urllib2.install_opener(opener)
50 req = urllib2.Request(src)
51 req.add_header(
"User-Agent",
52 "DQMIntegration/1.0 python/%d.%d.%d" % sys.version_info[:3])
53 req.add_header(
"Accept",
"application/json")
54 jsonCall = urllib2.urlopen(req, timeout = tout)
55 url = jsonCall.geturl()
56 except urllib2.HTTPError, error:
58 errStr =
"Cannot retrieve Tier-0 DAS data from URL \"" + error.url +
"\""
60 errStr +=
" using proxy \"" + self.
_proxy +
"\""
63 raise urllib2.HTTPError(
"FIXME: handle exceptions")
64 except urllib2.URLError, error:
66 print 'Try # ' + str(self.
_retry) +
" connection to Tier-0 DAS timed-out"
70 return self.
getData(src,newtout)
72 errStr =
"Cannot retrieve Tier-0 DAS data from URL \"" + src +
"\""
74 errStr +=
" using proxy \"" + self.
_proxy +
"\""
78 raise urllib2.URLError(
'TimeOut reading ' + src)
85 jsonInfo = jsonCall.info()
88 jsonText = jsonCall.read()
89 data = json.loads(jsonText)
96 Extractt the result list out of the JSON file
100 resultList = json[
'result']
107 Extract the value corrisponding to a given key from a JSON file. It is also possible to apply further selections.
124 except KeyError
as error:
125 print "[Tier0DasInterface::getValues] key: " + key +
" not found in json file"
129 print "[Tier0DasInterface::getValues] unknown error"
137 Query to get the last run released for prompt
143 workflowlist = ast.literal_eval(results[0])
145 for workflow
in workflowlist:
146 run = workflow[
'run']
147 if int(run) > maxRun:
151 print "[Tier0DasInterface::lastPromptRun] error"
157 Query to ge the run for which the Tier0 system considers safe the update to the conditions
164 except Exception
as details:
165 print "[Tier0DasInterface::firstConditionSafeRun] error", details
171 Query the GT currently used by prompt = GT used by the last run released for prompt.
178 workflowlist = ast.literal_eval(results[0])
180 for workflow
in workflowlist:
181 if workflow[
'primary_dataset'] == dataset:
182 gt = workflow[
'global_tag']
188 print "[Tier0DasInterface::promptGlobalTag] error"
194 Query the GT currently used by express = GT used by the last run released for express.
202 config = ast.literal_eval(results[0])[0]
203 gt = config[
'global_tag']
209 print "[Tier0DasInterface::expressGlobalTag] error"
215 expressGT =
"UNKNOWN"
218 if 'http_proxy' in os.environ:
219 proxyurl = os.environ[
'http_proxy']
224 expressGT = test.expressGlobalTag()
225 print "Tier0 DAS express GT: ", expressGT
226 except Exception
as error:
230 GlobalTag.globaltag = expressGT
def firstConditionSafeRun