Skip to content

Commit

Permalink
refactor: rename _template_id as _action_name
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Shimkus <[email protected]>
  • Loading branch information
jshimkus-rh committed Oct 25, 2023
1 parent 30bb0c7 commit 7d35428
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ansible_rulebook/action/run_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def _job_data(self) -> dict:
return data

@property
def _template_id(self) -> str:
def _action_name(self) -> str:
raise NotImplementedError

def __init__(self, metadata: Metadata, control: Control, **action_args):
self.helper = Helper(metadata, control, self._template_id)
self.helper = Helper(metadata, control, self._action_name)
self.action_args = action_args
self.job_id = str(uuid.uuid4())
self.name = self.action_args["name"]
Expand All @@ -75,7 +75,7 @@ async def _run(self):
await asyncio.sleep(delay)
logger.info(
"Previous %s failed. Retry %d of %d",
self._template_id,
self._action_name,
i,
retries,
)
Expand Down
8 changes: 4 additions & 4 deletions ansible_rulebook/action/run_job_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class RunJobTemplate(RunTemplate):
the controller. It waits for the job to be complete.
"""

@property
def _action_name(self):
return "run_job_template"

@property
def _exceptions(self):
return super()._exceptions + (JobTemplateNotFoundException,)
Expand All @@ -35,10 +39,6 @@ def _exceptions(self):
def _run_job(self):
return job_template_runner.run_job_template

@property
def _template_id(self):
return "run_job_template"

@property
def _template_name(self):
return "job template"
Expand Down
8 changes: 4 additions & 4 deletions ansible_rulebook/action/run_playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ class RunPlaybook(RunBase):
ansible-runner
"""

@property
def _action_name(self) -> str:
return "run_playbook"

@property
def _job_data(self) -> dict:
data = super()._job_data
data["hosts"] = self.host_limit
return data

@property
def _template_id(self) -> str:
return "run_playbook"

def __init__(self, metadata: Metadata, control: Control, **action_args):
super().__init__(metadata, control, **action_args)
self.default_copy_files = True
Expand Down
8 changes: 4 additions & 4 deletions ansible_rulebook/action/run_workflow_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class RunWorkflowTemplate(RunTemplate):
the controller. It waits for the job to be complete.
"""

@property
def _action_name(self):
return "run_workflow_template"

@property
def _exceptions(self):
return super()._exceptions + (WorkflowJobTemplateNotFoundException,)
Expand All @@ -35,10 +39,6 @@ def _exceptions(self):
def _run_job(self):
return job_template_runner.run_workflow_job_template

@property
def _template_id(self):
return "run_workflow_template"

@property
def _template_name(self):
return "workflow template"
Expand Down

0 comments on commit 7d35428

Please sign in to comment.