Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terminal errors in subtask logging #256

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/192.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes lack of logging of certain termination based failures.
6 changes: 3 additions & 3 deletions nautobot_device_onboarding/jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def junos_get_valid_interfaces(interfaces):
"""Get valid interfaces from Junos."""
result = {}
for interface in interfaces:
result[interface['name']] = {}
if interface['units']:
for unit in interface['units']:
result[interface["name"]] = {}
if interface["units"]:
for unit in interface["units"]:
result[f"{interface['name']}.{unit}"] = {}
return result
12 changes: 11 additions & 1 deletion nautobot_device_onboarding/nornir_plays/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ def task_instance_completed(self, task: Task, host: Host, result: MultiResult) -

def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult) -> None:
"""Processor for logging and data processing on subtask completed."""
self.logger.info(f"Subtask completed: {task.name}, {task.host}.", extra={"object": task.host})
self.logger.info(
f"Subtask {'failed' if result.failed else 'succeeded'}: {task.name}, {task.host}.",
extra={"object": task.host},
)
if result.failed:
for res in result:
if res.exception:
self.logger.info(
f"{host.name} an exception occured: {res.exception}.",
extra={"object": host.name},
)

def subtask_instance_started(self, task: Task, host: Host) -> None: # show command start
"""Processor for logging and data processing on subtask start."""
Expand Down