Closed MeganerdDev closed 8 months ago
Got some edge cases left I think, but pretty much everything but making CI happy is left
I left a few TODO entries, but nothing is a blocker I think
Not sure if making pylint happy for generator is mandatory for merge or if we can add an ignore for this case
# pylint: disable=use-a-generator
Thanks for the feedback, Ill get this updated!
My current action/to-do items for this PR:
status update on TODO item -> "have a job's user-input widgets prompt for chat user input" I have a working concept, will update PR with that soon!
This now provides a separate nautobot subcommand init-job-form
When /nautobot init-job-form
is called without a job name it presents a drop-down dialog
Otherwise you can specify the job name, eg: /nautobot init-job-form "demo-job"
Caveats:
init-job-form
could be merged to a single subcommand with init-job
, have the input form call itself with the additional argsI removed this helper function, noting in case we want to re-add (eg: enable_job subcommand would use this)
def enable_job(module, name, source="local"):
"""
Helper function to look up a job by class and job model and enable it.
Args:
module (str): Job module name
name (str): Job class name
source (str): Job grouping (default: "local")
"""
job_class = get_job(f"{module}.{name}")
job_model = Job.objects.get(module_name=module, job_class_name=name) # .restrict() may be preferred if we pass user
if not job_model.enabled:
job_model.enabled = True
job_model.validated_save()
return
Noting some things for the current status of this PR:
init_job
and init_job_form
subcommands? Not required for PR, but may be the better patternenable_job
subcommand using the helper above? Not required for PR, can be its own PRFixed items:
enqueue_job
and refresh_from_db
Awesome work @MeganerdDev! The only thing I'd note is the addition of some documentation in the /nautobot
commands table.
Closes: #223
224 closed in favor of this rebase
What's Changed
Adds the following nautobot subcommands:
init_job()
asinit-job
init_job
subccomand which initiates a Nautobot job by job namekwargs
JSON-string dictionary to init_jobs (untested but looks good)get_jobs()
asget-jobs
get_jobs
which returns all Nautobot jobs viewable to userkwargs
JSON-string list to get_jobs export header items (tested as working)filter_jobs()
asfilter-jobs
filter_jobs
which returns filtered set of Nautobot jobs viewable to user/nautobot filter-jobs "enabled"
or/nautobot filter-jobs "enabled,installed"
/nautobot filter-jobs '{"enabled": true}'
Remaining work
init_job
should presen thet job form itemsinit_job
method we can pass kwargs as JSON-string (untested)TODO
Screenshots
/nautobot init-job
/nautobot init-jobs for job that is not enabled
if there is a failed job, we will return the job_result.result message
/nautobot get-jobs
by default we will get some head items
/nautobot get-jobs '["id", "name", "installed", "tags"]'
we can specify the header items we want with a JSON formatted list
if there is a bad key, eg:
/nautobot get-jobs '["id", "name", "invalid key demo"]'
/nautobot filter-jobs "enabled"
Notes