forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignWorkflow.py
More file actions
executable file
·193 lines (168 loc) · 6.1 KB
/
assignWorkflow.py
File metadata and controls
executable file
·193 lines (168 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env python
"""
Quick request assignment, useful if you want to avoid assigning by
Web interface and reqmgr.py is too unflexible.
"""
import sys
import optparse
import reqMgrClient as rqMgr
from pprint import pprint
from random import choice
T1_SITES = [
"T1_DE_KIT",
"T1_ES_PIC",
"T1_FR_CCIN2P3",
"T1_IT_CNAF",
"T1_RU_JINR",
"T1_UK_RAL",
"T1_US_FNAL"
]
T2_SITES = [
"T2_CH_CERN",
"T2_DE_DESY",
"T2_DE_RWTH",
"T2_ES_CIEMAT",
"T2_FR_CCIN2P3",
"T2_FR_IPHC",
"T2_IT_Bari",
"T2_IT_Legnaro",
"T2_IT_Pisa",
"T2_IT_Rome",
"T2_UK_London_Brunel",
"T2_UK_London_IC",
"T2_US_Caltech",
"T2_US_Florida",
"T2_US_MIT",
"T2_US_Nebraska",
"T2_US_Purdue",
"T2_US_UCSD",
"T2_US_Wisconsin"
]
ALL_SITES = T1_SITES + T2_SITES
def getRandomDiskSite(site=T1_SITES):
"""
Gets a random disk site and append _Disk
"""
s = choice(site)
if s.startswith("T1"):
s += "_Disk"
return s
def assignRequest(url, workflow, team, sites, era, procversion, activity, lfn,
procstring, trust_site=False, replica=False, verbose=False):
params = {"action": "Assign",
"Team" + team: "checked",
"SiteWhitelist": sites,
"SiteBlacklist": [],
"MergedLFNBase": lfn,
"UnmergedLFNBase": "/store/unmerged",
"MinMergeSize": 2147483648,
"MaxMergeSize": 4294967296,
"MaxMergeEvents": 50000,
"MaxRSS": 4294967296,
"MaxVSize": 4294967296,
"SoftTimeout" : 159600,
"AcquisitionEra": era,
"Dashboard": activity,
"ProcessingVersion": procversion,
"ProcessingString": procstring,
"checkbox" + workflow: "checked",
"CustodialSites": []
}
# add xrootd (trustSiteList)
if trust_site:
params['TrustSitelists'] = True
# if replica we add NonCustodial sites
if replica:
params["NonCustodialSites"] = getRandomDiskSite(),
params["NonCustodialSubType"] = "Replica"
if verbose:
pprint(params)
params['execute'] = True
res = rqMgr.assignWorkflow(url, workflow, team, params)
if res:
print 'Assigned workflow:', workflow, 'to site:', sites, 'with processing version', procversion
else:
print 'could not assign the workflow',workflow
def main():
url = 'cmsweb.cern.ch'
url_tb = 'cmsweb-testbed.cern.ch'
usage = "usage: %prog [options] [WORKFLOW]"
parser = optparse.OptionParser(usage=usage)
parser.add_option('-t', '--team', help='Type of Requests', dest='team')
parser.add_option('-s', '--sites', help='Site List, comma separated (no spaces),\
or "t1" for Tier-1\'s and "t2" for Tier-2\'s', dest='sites')
parser.add_option('-r', '--replica', action='store_true', dest='replica', default=False,
help='Adds a _Disk Non-Custodial Replica parameter')
parser.add_option('-e', '--era', help='Acquistion era', dest='era')
parser.add_option('-p', '--procversion', help='Processing Version, if empty it will leave the processing version\
that comes by defaul in the request', dest='procversion')
parser.add_option('-a', '--activity', help='Dashboard Activity (reprocessing, production or test), if empty will\
set reprocessing as default', dest='activity')
parser.add_option('-x', '--xrootd', help='Assign with trustSiteLocation=True (allows xrootd capabilities)',
action='store_true', default=False, dest='xrootd')
parser.add_option('-l', '--lfn', help='Merged LFN base', dest='lfn')
parser.add_option('-f', '--file', help='Text file with a list of wokflows. If this option is used, the same settings will be\
applyed to all workflows', dest='file')
parser.add_option('-v', '--verbose', help='Verbose',
action='store_true', default=False, dest='verbose')
parser.add_option('--testbed', help='Assign in testbed',
action='store_true', default=False, dest='testbed')
(options, args) = parser.parse_args()
if options.testbed:
url = url_tb
if options.file:
wfs = [l.strip() for l in open(options.file) if l.strip()]
elif len(args) == 1:
wfs = [args[0]]
else:
parser.error("Provide the workflow name or the file")
if not options.team:
parser.error("Provide the TEAM name")
sys.exit(0)
# parse site list
if options.sites:
if options.sites == "t1":
sites = T1_SITES
elif options.sites == "t2":
sites = T2_SITES
else:
sites = [site for site in options.sites.split(',')]
# default site list (all sites), comment out what you want to discard
else:
sites = ALL_SITES
# activity reprocessing by default
activity = 'reprocessing'
if options.activity:
activity = options.activity
else:
activity = 'reprocessing'
#trustSiteListAsLocation = False
trust_site = False
if options.xrootd:
trust_site = True
team = options.team
for wf in wfs:
wf = rqMgr.Workflow(wf, url=url)
# check options that were provided particularly
if options.era:
era = options.era
else:
era = wf.info['AcquisitionEra']
# lfn backfill by default
if options.lfn:
lfn = options.lfn
elif "MergedLFNBase" in wf.info:
lfn = wf.info['MergedLFNBase']
else:
lfn = '/store/backfill/1'
# given or default processing version
if options.procversion:
procversion = options.procversion
else:
procversion = wf.info['ProcessingVersion']
procstring = wf.info['ProcessingString']
assignRequest(url, wf.name, team, sites, era, procversion,
activity, lfn, procstring, trust_site, options.replica, options.verbose)
sys.exit(0)
if __name__ == "__main__":
main()