-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwmapprove.py
46 lines (40 loc) · 1.52 KB
/
wmapprove.py
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
from __future__ import print_function
import sys
import optparse
import time
from modules import wma
def getOptions():
parser = optparse.OptionParser()
parser.add_option('-w', '--workflows', help='Requests to be approved after batch announcement', dest='workflows', default='')
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')
try:
options,_ = parser.parse_args()
return options
except SystemExit:
print("Error in parsing options")
sys.exit(-1)
def approveRequest(options):
if options.workflows == '':
print('No workflows found')
sys.exit(-1)
workflows = set(options.workflows.split(','))
print('Approving requests: %s' % workflows)
if options.wmtest:
wma.testbed(options.wmtesturl)
for workflow in workflows:
tries = 1
while tries < 16:
try:
if(wma.getWorkflowStatus(wma.WMAGENT_URL, workflow) == 'new'):
wma.approveRequest(wma.WMAGENT_URL, workflow)
break
except Exception as e:
time.sleep(5)
print('Something went wrong: %s Try number: %s' % (str(e), tries))
tries += 1
if __name__ == '__main__':
options = getOptions()
approveRequest(options)