This repository was archived by the owner on Jul 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathwmupload.py
More file actions
executable file
·53 lines (48 loc) · 2.54 KB
/
wmupload.py
File metadata and controls
executable file
·53 lines (48 loc) · 2.54 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
#! /usr/bin/env python
from __future__ import print_function
import optparse
import os
from modules import wma
def prepare_parser():
parser = optparse.OptionParser()
parser.add_option('-u', '--user', help='Username', dest='user',
default=os.environ['WMCONTROL_USER'] if 'WMCONTROL_USER' in os.environ else '')
parser.add_option('-g', '--group', help='User group', dest='group',
default=os.environ['WMCONTROL_GROUP'] if 'WMCONTROL_GROUP' in os.environ else '')
parser.add_option('-l', '--label', help='Label and description of config', dest='label',
default='Uploaded through wmupload')
parser.add_option('--wmtest', help='To inject requests to the cmsweb test bed', action='store_true' ,
dest='wmtest', default=False)
parser.add_option('--wmtesturl', help='To inject to a specific testbed', dest='wmtesturl',
default='cmsweb-testbed.cern.ch')
parser.add_option('--create-tweak',
help='Instead of performing the submission directly, tweak the parameters and just save them as JSON',
dest='create_tweak',
default=False,
action='store_true')
parser.add_option('--from-tweak',
help='Submit the configuration to the ReqMgr2 cache loading tweaked parameters from a JSON file, instead of loading the module',
dest='from_tweak',
default=False,
action='store_true')
return parser
def main():
parser = prepare_parser()
options, args = parser.parse_args()
if options.create_tweak and options.from_tweak:
raise RuntimeError('--create-tweak and --from-tweak are mutually exclusive options. Select only one of them')
if options.wmtest:
print("Setting to injection in cmswebtest : ", options.wmtesturl)
wma.testbed(options.wmtesturl)
for cfg_name in args:
if options.create_tweak:
wma.tweaks_to_file(cfg_name)
else:
# INFO: The tweak file was created using the original
# configuration file in a previous execution.
tweaks = wma.from_tweaks_file(cfg_name) if options.from_tweak else {}
patched_config_file = wma.patch_configuration_file(cfg_name)
config_file = patched_config_file if patched_config_file else cfg_name
wma.upload_to_couch(config_file, options.label, options.user, options.group, tweaks=tweaks)
if __name__ == "__main__":
main()