forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabortAndClone.py
58 lines (51 loc) · 1.83 KB
/
abortAndClone.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
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""
Abort a given list of workflows and then clone them, also
INVALIDATES original dataset, since the clone will have increased
version number
This can be used when input workflows are in status: acquired (or running open/closed)
Please use rejectAndClone for workflows in status assigened or assignment-approved
The cloned requests have a newly generated RequestName,
new timestamp, RequestDate, however -everything- else is copied from the original request.
input arg: Text file with list of workflows.
"""
import urllib2,urllib, httplib, sys, re, os
try:
import json
except:
import simplejson as json
import resubmit, reqMgrClient
import RelVal.setDatasetStatusDBS3 as dbs3
dbs3_url = 'https://cmsweb.cern.ch/dbs/prod/global/DBSWriter'
url = 'cmsweb.cern.ch'
def main():
"""
Read the text file, for each workflow try:
First abort it, then clone it.
"""
args=sys.argv[1:]
if not len(args)==3:
print "usage:abortAndClone file.txt user group"
sys.exit(0)
filename = args[0]
user = args[1]
group = args[2]
#reading workflow list
workflows = [wf.strip() for wf in open(filename).readlines() if wf.strip()]
for workflow in workflows:
#abort workflow
print "Aborting workflow: " + workflow
reqMgrClient.abortWorkflow(url, workflow)
print "Aborted. Now cloning workflow..."
#invalidates datasets
print "Invalidating datasets"
datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
for dataset in datasets:
print dataset
dbs3.setStatusDBS3(dbs3_url, dataset, 'INVALID', None)
#clone workflow
clone = resubmit.cloneWorkflow(workflow, user, group)
print "Cloned workflow: ", clone
sys.exit(0);
if __name__ == "__main__":
main()