| 435 | return ActionExecution.get_by_id(execution_id) if execution_id else None |
| 436 | |
| 437 | def _get_runner(self, runner_type_db, action_db, liveaction_db): |
| 438 | resolved_entry_point = self._get_entry_point_abs_path( |
| 439 | action_db.pack, action_db.entry_point |
| 440 | ) |
| 441 | context = getattr(liveaction_db, "context", dict()) |
| 442 | user = context.get("user", cfg.CONF.system_user.user) |
| 443 | config = None |
| 444 | |
| 445 | # Note: Right now configs are only supported by the Python runner actions |
| 446 | if ( |
| 447 | runner_type_db.name == "python-script" |
| 448 | or runner_type_db.runner_module == "python_runner" |
| 449 | ): |
| 450 | LOG.debug("Loading config from pack for python runner.") |
| 451 | config_loader = ContentPackConfigLoader(pack_name=action_db.pack, user=user) |
| 452 | config = config_loader.get_config() |
| 453 | |
| 454 | runner = get_runner(name=runner_type_db.name, config=config) |
| 455 | |
| 456 | # TODO: Pass those arguments to the constructor instead of late |
| 457 | # assignment, late assignment is awful |
| 458 | runner.runner_type = runner_type_db |
| 459 | runner.action = action_db |
| 460 | runner.action_name = action_db.name |
| 461 | runner.liveaction = liveaction_db |
| 462 | runner.liveaction_id = str(liveaction_db.id) |
| 463 | runner.execution = ActionExecution.get(liveaction__id=runner.liveaction_id) |
| 464 | runner.execution_id = str(runner.execution.id) |
| 465 | runner.entry_point = resolved_entry_point |
| 466 | runner.context = context |
| 467 | runner.callback = getattr(liveaction_db, "callback", dict()) |
| 468 | runner.libs_dir_path = self._get_action_libs_abs_path( |
| 469 | action_db.pack, action_db.entry_point |
| 470 | ) |
| 471 | |
| 472 | # For re-run, get the ActionExecutionDB in which the re-run is based on. |
| 473 | rerun_ref_id = runner.context.get("re-run", {}).get("ref") |
| 474 | runner.rerun_ex_ref = ( |
| 475 | ActionExecution.get(id=rerun_ref_id) if rerun_ref_id else None |
| 476 | ) |
| 477 | |
| 478 | return runner |
| 479 | |
| 480 | def _create_auth_token(self, context, action_db, liveaction_db): |
| 481 | if not context: |