37
37
from st2common .models .api .action import LiveActionAPI
38
38
from st2common .models .api .action import LiveActionCreateAPI
39
39
from st2common .models .api .base import jsexpose
40
+ from st2common .models .api .base import cast_argument_value
40
41
from st2common .models .api .execution import ActionExecutionAPI
41
42
from st2common .persistence .liveaction import LiveAction
42
43
from st2common .persistence .execution import ActionExecution
@@ -276,22 +277,25 @@ def validate(self):
276
277
return self
277
278
278
279
@jsexpose (body_cls = ExecutionSpecificationAPI , status_code = http_client .CREATED )
279
- def post (self , spec , execution_id ):
280
+ def post (self , spec_api , execution_id , no_merge = False ):
280
281
"""
281
282
Re-run the provided action execution optionally specifying override parameters.
282
283
283
284
Handles requests:
284
285
285
286
POST /executions/<id>/re_run
286
287
"""
288
+ no_merge = cast_argument_value (value_type = bool , value = no_merge )
287
289
existing_execution = self ._get_one (id = execution_id , exclude_fields = self .exclude_fields )
288
290
289
- if spec .tasks and existing_execution .runner ['name' ] != 'mistral-v2' :
291
+ if spec_api .tasks and existing_execution .runner ['name' ] != 'mistral-v2' :
290
292
raise ValueError ('Task option is only supported for Mistral workflows.' )
291
293
292
294
# Merge in any parameters provided by the user
293
- new_parameters = copy .deepcopy (getattr (existing_execution , 'parameters' , {}))
294
- new_parameters .update (spec .parameters )
295
+ new_parameters = {}
296
+ if not no_merge :
297
+ new_parameters .update (getattr (existing_execution , 'parameters' , {}))
298
+ new_parameters .update (spec_api .parameters )
295
299
296
300
# Create object for the new execution
297
301
action_ref = existing_execution .action ['ref' ]
@@ -303,11 +307,11 @@ def post(self, spec, execution_id):
303
307
}
304
308
}
305
309
306
- if spec .tasks :
307
- context ['re-run' ]['tasks' ] = spec .tasks
310
+ if spec_api .tasks :
311
+ context ['re-run' ]['tasks' ] = spec_api .tasks
308
312
309
- if spec .reset :
310
- context ['re-run' ]['reset' ] = spec .reset
313
+ if spec_api .reset :
314
+ context ['re-run' ]['reset' ] = spec_api .reset
311
315
312
316
# Add trace to the new execution
313
317
trace = trace_service .get_trace_db_by_action_execution (
@@ -319,7 +323,7 @@ def post(self, spec, execution_id):
319
323
new_liveaction_api = LiveActionCreateAPI (action = action_ref ,
320
324
context = context ,
321
325
parameters = new_parameters ,
322
- user = spec .user )
326
+ user = spec_api .user )
323
327
324
328
return self ._handle_schedule_execution (liveaction_api = new_liveaction_api )
325
329
0 commit comments