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 0c3bb34b..dc36b3ac 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."""