|
13 | 13 | username = getpass.getuser() |
14 | 14 |
|
15 | 15 | def rejector(url, specific, options=None): |
| 16 | + |
| 17 | + if options.test: |
| 18 | + print "Test mode - no changes propagate to the production system" |
16 | 19 |
|
17 | 20 | if not componentInfo(soft=['wtc','jira']).check(): return |
18 | 21 |
|
@@ -62,18 +65,26 @@ def rejector(url, specific, options=None): |
62 | 65 |
|
63 | 66 | comment="" |
64 | 67 | if options.comments: comment = ", reason: "+options.comments |
65 | | - if options.keep: |
66 | | - wfi.sendLog('rejector','invalidating the workflow by unified operator {}{}'.format(username, comment)) |
| 68 | + if options.test: |
| 69 | + if options.keep: |
| 70 | + print 'invalidating the workflow by unified operator {}{}'.format(username, comment) |
| 71 | + else: |
| 72 | + print 'invalidating the workflow and outputs by unified operator {}{}'.format(username, comment) |
| 73 | + results = [True] |
67 | 74 | else: |
68 | | - wfi.sendLog('rejector','invalidating the workflow and outputs by unified operator {}{}'.format(username, comment)) |
| 75 | + if options.keep: |
| 76 | + wfi.sendLog('rejector','invalidating the workflow by unified operator {}{}'.format(username, comment)) |
| 77 | + else: |
| 78 | + wfi.sendLog('rejector','invalidating the workflow and outputs by unified operator {}{}'.format(username, comment)) |
69 | 79 |
|
70 | | - results = invalidate(url, wfi, only_resub=True, with_output= (not options.keep)) |
| 80 | + results = invalidate(url, wfi, only_resub=True, with_output= (not options.keep)) |
71 | 81 |
|
72 | 82 | if all(results): |
73 | 83 | print wfo.name,"rejected" |
74 | 84 | if options and options.clone: |
75 | | - wfo.status = 'trouble' |
76 | | - session.commit() |
| 85 | + if not options.test: |
| 86 | + wfo.status = 'trouble' |
| 87 | + session.commit() |
77 | 88 | schema = wfi.getSchema() |
78 | 89 | schema['Requestor'] = os.getenv('USER') |
79 | 90 | schema['Group'] = 'DATAOPS' |
@@ -209,8 +220,11 @@ def rejector(url, specific, options=None): |
209 | 220 | tmcore = schema[sname].pop('Multicore') |
210 | 221 | tmem = schema[sname].pop('Memory') |
211 | 222 | if mcore and tmcore != mcore: |
212 | | - wfi.sendLog('rejector','the conversion to stepchain encoutered different value of Multicore %d != %d'%( tmcore, mcore)) |
213 | | - sendLog('rejector','the conversion of %s to stepchain encoutered different value of Multicore %d != %d'%( wfo.name, tmcore, mcore), level='critical') |
| 223 | + if options.test: |
| 224 | + print 'the conversion of %s to stepchain encoutered different value of Multicore %d != %d' % (wfo.name, tmcore, mcore) |
| 225 | + else: |
| 226 | + wfi.sendLog('rejector','the conversion to stepchain encoutered different value of Multicore %d != %d'%( tmcore, mcore)) |
| 227 | + sendLog('rejector','the conversion of %s to stepchain encoutered different value of Multicore %d != %d'%( wfo.name, tmcore, mcore), level='critical') |
214 | 228 | mcore = max(mcore, tmcore) |
215 | 229 | mem = max(mem, tmem) |
216 | 230 | schema[sname]['StepName'] = schema[sname].pop('TaskName') |
@@ -240,39 +254,45 @@ def rejector(url, specific, options=None): |
240 | 254 | schema['Multicore'] = mcore |
241 | 255 | schema['Memory'] = mem |
242 | 256 | print json.dumps( schema, indent=2 ) |
243 | | - newWorkflow = reqMgrClient.submitWorkflow(url, schema) |
244 | | - if not newWorkflow: |
245 | | - msg = "Error in cloning {}".format(wfo.name) |
246 | | - print(msg) |
247 | | - wfi.sendLog('rejector',msg) |
248 | | - |
249 | | - # Get the error message |
250 | | - time.sleep(5) |
251 | | - data = reqMgrClient.requestManagerPost(url, "/reqmgr2/data/request", schema) |
252 | | - wfi.sendLog('rejector',data) |
253 | | - |
254 | | - print json.dumps( schema, indent=2 ) |
255 | | - return |
256 | | - print newWorkflow |
| 257 | + if not options.test: |
| 258 | + newWorkflow = reqMgrClient.submitWorkflow(url, schema) |
| 259 | + if not newWorkflow: |
| 260 | + msg = "Error in cloning {}".format(wfo.name) |
| 261 | + print(msg) |
| 262 | + wfi.sendLog('rejector',msg) |
257 | 263 |
|
258 | | - data = reqMgrClient.setWorkflowApproved(url, newWorkflow) |
259 | | - print data |
260 | | - wfi.sendLog('rejector','Cloned into %s by unified operator %s'%( newWorkflow, comment )) |
261 | | - #wfi.notifyRequestor('Cloned into %s by unified operator %s'%( newWorkflow, comment ),do_batch=False) |
| 264 | + # Get the error message |
| 265 | + time.sleep(5) |
| 266 | + data = reqMgrClient.requestManagerPost(url, "/reqmgr2/data/request", schema) |
| 267 | + wfi.sendLog('rejector',data) |
| 268 | + |
| 269 | + print json.dumps( schema, indent=2 ) |
| 270 | + return |
| 271 | + print newWorkflow |
| 272 | + |
| 273 | + data = reqMgrClient.setWorkflowApproved(url, newWorkflow) |
| 274 | + print data |
| 275 | + wfi.sendLog('rejector','Cloned into %s by unified operator %s'%( newWorkflow, comment )) |
| 276 | + #wfi.notifyRequestor('Cloned into %s by unified operator %s'%( newWorkflow, comment ),do_batch=False) |
262 | 277 | else: |
263 | | - wfo.status = 'trouble' if options.set_trouble else 'forget' |
264 | | - wfi.notifyRequestor('Rejected by unified operator %s'%( comment ),do_batch=False) |
265 | | - session.commit() |
| 278 | + if options.test: |
| 279 | + print 'Rejected by unified operator %s'%( comment ) |
| 280 | + else: |
| 281 | + wfo.status = 'trouble' if options.set_trouble else 'forget' |
| 282 | + wfi.notifyRequestor('Rejected by unified operator %s'%( comment ),do_batch=False) |
| 283 | + session.commit() |
266 | 284 |
|
267 | 285 | else: |
268 | | - msg = "Error in rejecting {}: {}".format(wfo.name,results) |
269 | | - print(msg) |
270 | | - wfi.sendLog('rejector',msg) |
| 286 | + msg = "Error in rejecting {}: {}".format(wfo.name, results) |
| 287 | + print msg |
| 288 | + if not options.test: |
| 289 | + wfi.sendLog('rejector', msg) |
271 | 290 |
|
272 | 291 | if __name__ == "__main__": |
273 | 292 | url = reqmgr_url |
274 | 293 |
|
275 | 294 | parser = optparse.OptionParser() |
| 295 | + parser.add_option('-t', '--test', help="test mode - no changes are made", default=False, action="store_true") |
276 | 296 | parser.add_option('-c','--clone',help="clone the workflow",default=False,action="store_true") |
277 | 297 | parser.add_option('--comments', help="Give a comment to the clone",default="") |
278 | 298 | parser.add_option('-k','--keep',help="keep the outpuy in current status", default=False,action="store_true") |
|
0 commit comments