Replies: 1 comment
-
The job id is not given as an argument to the JobRunner, but you are able to fetch the latest result from your JobName. For instance, creating a journal entry linking to the result of the script. from extras.models import JournalEntry, Script as ScriptModel
from extras.choices import JournalEntryKindChoices
from core.models import Job
class MyScript(Script):
script = ScriptModel.objects.get(name=self.class_name)
# script.result returns a job object for the last job.
result: Job = script.result
JournalEntry.objects.create(
assigned_object=site,
kind=JournalEntryKindChoices.KIND_SUCCESS,
comments=f"Scripted deployment completed successfully. [{self.name}]({reverse('extras:script_result', args=[result.pk])})",
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm writing a script that will automatically generate interface configurations and output it. I've also created a custom_field that is intended to store the URL to the last ran job for that interface if ran.
What I'm trying to do is get the current
job.id
inside the script and update the custom field with the URL to the report before the script even completes entirely - how can I do this?Essentially I want to do
interface.custom_field_data['last_config_render'] = f'https://netbox.example.com/extras/scripts/results/{self.job.id}'
but cannot get the job id.Beta Was this translation helpful? Give feedback.
All reactions