This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
setReqMgrStatus.py
executable file
·42 lines (34 loc) · 1.75 KB
/
setReqMgrStatus.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
#!/usr/bin/env python
import reqMgrClient as reqmgr
import optparse
def setStatus(url, workflowname, newstatus, cascade):
print "Setting %s to %s" % (workflowname, newstatus)
if newstatus == 'closed-out':
return reqmgr.closeOutWorkflow(url, workflowname, cascade)
elif newstatus == 'announced':
return reqmgr.announceWorkflow(url, workflowname, cascade)
elif newstatus == "staged":
return reqmgr.setStatusToStaged(url, workflowname, cascade)
elif newstatus == "staging":
return reqmgr.setStatusToStaging(url, workflowname, cascade)
else:
print "ERROR: Cannot set status to ", newstatus
def main():
parser = optparse.OptionParser()
parser.add_option('-u', '--url', help='Which server to communicate with', default='cmsweb.cern.ch', choices=['cmsweb.cern.ch', 'cmsweb-testbed.cern.ch'])
parser.add_option('-w', '--workflow', help='Workflow name')
parser.add_option('-f', '--file', help='A file name which contains the workflows (One workflow in each line)')
parser.add_option('-c', '--cascade', help='Set the workflow state in cascade mode', default=False)
parser.add_option('-s', '--status', help='The new status', choices=['staging', 'staged', 'closed-out', 'announced'])
(options, args) = parser.parse_args()
if not options.status:
parser.error('Status is not given')
if options.workflow:
setStatus(options.url, options.workflow, options.status, options.cascade)
elif options.file:
for workflow in filter(None, open(options.file).read().split('\n')):
setStatus(options.url, workflow, options.status, options.cascade)
else:
parser.error("You should provide either workflow or file options")
if __name__ == "__main__":
main()