#NEWLINE# def _do_run( self , runner , runnertype_db , action_db , liveaction_db ) : #NEWLINE# #INDENT# runner . auth_token = self . _create_auth_token ( runner . context ) #NEWLINE# updated_liveaction_db = None #NEWLINE# try : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( runner_params , action_params ) = param_utils . render_final_params ( runnertype_db . runner_parameters , action_db . parameters , liveaction_db . parameters , liveaction_db . context ) #NEWLINE# runner . runner_parameters = runner_params #NEWLINE# #UNINDENT# except ParamException as e : #NEWLINE# #INDENT# raise actionrunner . ActionRunnerException ( str ( e ) ) #NEWLINE# #UNINDENT# LOG . debug ( 'Performing pre-run for runner: %s' , runner . runner_id ) #NEWLINE# runner . pre_run ( ) #NEWLINE# resolved_action_params = ResolvedActionParameters ( action_db = action_db , runner_type_db = runnertype_db , runner_parameters = runner_params , action_parameters = action_params ) #NEWLINE# extra = { #NEWLINE# #INDENT# 'runner' : runner , #NEWLINE# 'parameters' : resolved_action_params , #NEWLINE# #UNINDENT# } #NEWLINE# LOG . debug ( ( 'Performing run for runner: %s' % runner . runner_id ) , extra = extra ) #NEWLINE# ( status , result , context ) = runner . run ( action_params ) #NEWLINE# try : #NEWLINE# #INDENT# result = json . loads ( result ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# action_completed = ( status in action_constants . LIVEACTION_COMPLETED_STATES ) #NEWLINE# if ( isinstance ( runner , AsyncActionRunner ) and ( not action_completed ) ) : #NEWLINE# #INDENT# self . _setup_async_query ( runner . id , runnertype_db , context ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# LOG . exception ( 'Failed to run action.' ) #NEWLINE# ( _ , ex , tb ) = sys . exc_info ( ) #NEWLINE# status = action_constants . LIVEACTION_STATUS_FAILED #NEWLINE# result = { #NEWLINE# #INDENT# 'error' : str ( ex ) , #NEWLINE# 'traceback' : '' . join ( traceback . format_tb ( tb , 20 ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# context = None #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# extra = { #NEWLINE# #INDENT# 'result' : result , #NEWLINE# 'status' : status , #NEWLINE# #UNINDENT# } #NEWLINE# LOG . debug ( ( 'Action "%s" completed.' % action_db . name ) , extra = extra ) #NEWLINE# try : #NEWLINE# #INDENT# LOG . debug ( 'Setting status: %s for liveaction: %s' , status , liveaction_db . id ) #NEWLINE# updated_liveaction_db = self . _update_live_action_db ( liveaction_db . id , status , result , context ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# error = ( 'Cannot update LiveAction object for id: %s, status: %s, result: %s.' % ( liveaction_db . id , status , result ) ) #NEWLINE# LOG . exception ( error ) #NEWLINE# raise #NEWLINE# #UNINDENT# executions . update_execution ( updated_liveaction_db ) #NEWLINE# extra = { #NEWLINE# #INDENT# 'liveaction_db' : updated_liveaction_db , #NEWLINE# #UNINDENT# } #NEWLINE# LOG . debug ( 'Updated liveaction after run' , extra = extra ) #NEWLINE# self . _clean_up_auth_token ( runner = runner , status = status ) #NEWLINE# #UNINDENT# LOG . debug ( 'Performing post_run for runner: %s' , runner . runner_id ) #NEWLINE# runner . post_run ( status = status , result = result ) #NEWLINE# runner . container_service = None #NEWLINE# LOG . debug ( 'Runner do_run result' , extra = { #NEWLINE# #INDENT# 'result' : updated_liveaction_db . result , #NEWLINE# #UNINDENT# } ) #NEWLINE# LOG . audit ( 'Liveaction completed' , extra = { #NEWLINE# #INDENT# 'liveaction_db' : updated_liveaction_db , #NEWLINE# #UNINDENT# } ) #NEWLINE# return updated_liveaction_db