From 273f39ddb85cdc6762a0d57699cd9e9a9e69ee6e Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 11 Oct 2024 14:17:53 -0500 Subject: [PATCH 1/2] fix connection and timeout failures not showing in job results --- nautobot_device_onboarding/nornir_plays/processor.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nautobot_device_onboarding/nornir_plays/processor.py b/nautobot_device_onboarding/nornir_plays/processor.py index 0c3bb34b..838b6e44 100755 --- a/nautobot_device_onboarding/nornir_plays/processor.py +++ b/nautobot_device_onboarding/nornir_plays/processor.py @@ -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.""" From 914502d30488a9358498f13ff53edae61ccacb14 Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 11 Oct 2024 14:29:16 -0500 Subject: [PATCH 2/2] fix logging --- changes/192.fixed | 1 + nautobot_device_onboarding/jinja_filters.py | 6 +++--- nautobot_device_onboarding/nornir_plays/processor.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100755 changes/192.fixed diff --git a/changes/192.fixed b/changes/192.fixed new file mode 100755 index 00000000..71cd741b --- /dev/null +++ b/changes/192.fixed @@ -0,0 +1 @@ +Fixes lack of logging of certain termination based failures. diff --git a/nautobot_device_onboarding/jinja_filters.py b/nautobot_device_onboarding/jinja_filters.py index 17792c8e..aadd8129 100755 --- a/nautobot_device_onboarding/jinja_filters.py +++ b/nautobot_device_onboarding/jinja_filters.py @@ -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 diff --git a/nautobot_device_onboarding/nornir_plays/processor.py b/nautobot_device_onboarding/nornir_plays/processor.py index 838b6e44..dc36b3ac 100755 --- a/nautobot_device_onboarding/nornir_plays/processor.py +++ b/nautobot_device_onboarding/nornir_plays/processor.py @@ -89,7 +89,7 @@ def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult """Processor for logging and data processing on subtask completed.""" self.logger.info( f"Subtask {'failed' if result.failed else 'succeeded'}: {task.name}, {task.host}.", - extra={"object": task.host} + extra={"object": task.host}, ) if result.failed: for res in result: