From e4cfde7a0d515c839e9149f943506fa5760feea7 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:32:22 -0800 Subject: [PATCH 1/3] Fixed app startup crashing nautobot during startup in some cases. (#321) --- changes/320.fixed | 1 + nautobot_device_onboarding/constants.py | 4 ---- nautobot_device_onboarding/nornir_plays/command_getter.py | 6 +++--- nautobot_device_onboarding/nornir_plays/empty_inventory.py | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 changes/320.fixed diff --git a/changes/320.fixed b/changes/320.fixed new file mode 100644 index 00000000..3ba7de8b --- /dev/null +++ b/changes/320.fixed @@ -0,0 +1 @@ +Fixed app startup crashing nautobot during startup in some cases. diff --git a/nautobot_device_onboarding/constants.py b/nautobot_device_onboarding/constants.py index 3b8e70ad..ffc8b209 100644 --- a/nautobot_device_onboarding/constants.py +++ b/nautobot_device_onboarding/constants.py @@ -1,7 +1,6 @@ """Constants for nautobot_device_onboarding app.""" from django.conf import settings -from nautobot.dcim.utils import get_all_network_driver_mappings NETMIKO_EXTRAS = ( settings.PLUGINS_CONFIG.get("nautobot_plugin_nornir", {}) @@ -23,9 +22,6 @@ } -# This is used in the new SSoT based jobs. -SUPPORTED_NETWORK_DRIVERS = list(get_all_network_driver_mappings().keys()) - # This is used in the new SSoT based jobs. Soon PYATS should be supported. SUPPORTED_COMMAND_PARSERS = ["textfsm", "ttp"] diff --git a/nautobot_device_onboarding/nornir_plays/command_getter.py b/nautobot_device_onboarding/nornir_plays/command_getter.py index fc2e0fb4..eff29225 100755 --- a/nautobot_device_onboarding/nornir_plays/command_getter.py +++ b/nautobot_device_onboarding/nornir_plays/command_getter.py @@ -20,7 +20,7 @@ from ntc_templates.parse import parse_output from ttp import ttp -from nautobot_device_onboarding.constants import SUPPORTED_COMMAND_PARSERS, SUPPORTED_NETWORK_DRIVERS +from nautobot_device_onboarding.constants import SUPPORTED_COMMAND_PARSERS from nautobot_device_onboarding.nornir_plays.empty_inventory import EmptyInventory from nautobot_device_onboarding.nornir_plays.inventory_creator import _set_inventory from nautobot_device_onboarding.nornir_plays.logger import NornirLogger @@ -112,7 +112,7 @@ def netmiko_send_commands( """Run commands specified in PLATFORM_COMMAND_MAP.""" if not task.host.platform: return Result(host=task.host, result=f"{task.host.name} has no platform set.", failed=True) - if task.host.platform not in SUPPORTED_NETWORK_DRIVERS or not "cisco_wlc_ssh": + if task.host.platform not in get_all_network_driver_mappings().keys() or not "cisco_wlc_ssh": return Result(host=task.host, result=f"{task.host.name} has a unsupported platform set.", failed=True) if not command_getter_yaml_data[task.host.platform].get(command_getter_job): return Result( @@ -354,7 +354,7 @@ def sync_network_data_command_getter(job_result, log_level, kwargs): "queryset": qs, "defaults": { "platform_parsing_info": add_platform_parsing_info(), - "network_driver_mappings": SUPPORTED_NETWORK_DRIVERS, + "network_driver_mappings": list(get_all_network_driver_mappings().keys()), "sync_vlans": kwargs["sync_vlans"], "sync_vrfs": kwargs["sync_vrfs"], "sync_cables": kwargs["sync_cables"], diff --git a/nautobot_device_onboarding/nornir_plays/empty_inventory.py b/nautobot_device_onboarding/nornir_plays/empty_inventory.py index 701a4afc..c8038529 100755 --- a/nautobot_device_onboarding/nornir_plays/empty_inventory.py +++ b/nautobot_device_onboarding/nornir_plays/empty_inventory.py @@ -1,8 +1,8 @@ """Empty Nornir Inventory Plugin.""" +from nautobot.dcim.utils import get_all_network_driver_mappings from nornir.core.inventory import Defaults, Groups, Hosts, Inventory -from nautobot_device_onboarding.constants import SUPPORTED_NETWORK_DRIVERS from nautobot_device_onboarding.nornir_plays.transform import add_platform_parsing_info @@ -15,7 +15,7 @@ def load(self) -> Inventory: defaults = Defaults( data={ "platform_parsing_info": add_platform_parsing_info(), - "network_driver_mappings": SUPPORTED_NETWORK_DRIVERS, + "network_driver_mappings": list(get_all_network_driver_mappings().keys()), } ) groups = Groups() From 4bec6d45d83558009f1015b806bc915987f7705c Mon Sep 17 00:00:00 2001 From: Stephen Kiely Date: Wed, 19 Feb 2025 12:22:12 -0600 Subject: [PATCH 2/3] Release 4.2.2 --- changes/320.fixed | 1 - docs/admin/release_notes/version_4.2.md | 6 ++++++ poetry.lock | 3 +-- pyproject.toml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 changes/320.fixed diff --git a/changes/320.fixed b/changes/320.fixed deleted file mode 100644 index 3ba7de8b..00000000 --- a/changes/320.fixed +++ /dev/null @@ -1 +0,0 @@ -Fixed app startup crashing nautobot during startup in some cases. diff --git a/docs/admin/release_notes/version_4.2.md b/docs/admin/release_notes/version_4.2.md index a94e3e98..67ac3589 100755 --- a/docs/admin/release_notes/version_4.2.md +++ b/docs/admin/release_notes/version_4.2.md @@ -11,6 +11,12 @@ Versioning](https://semver.org/spec/v2.0.0.html). - [#274](https://github.com/nautobot/nautobot-app-device-onboarding/issues/274) - Added TTP Parser support. - [#274](https://github.com/nautobot/nautobot-app-device-onboarding/issues/274) - Added Sync Device from Network support for Palo Alto Panos. +## [v4.2.2 (2025-02-19)](https://github.com/nautobot/nautobot-app-device-onboarding/releases/tag/v4.2.2) + +### Fixed + +- [#320](https://github.com/nautobot/nautobot-app-device-onboarding/issues/320) - Fixed app startup crashing nautobot during startup in some cases. + ## [v4.2.1 (2025-02-11)](https://github.com/nautobot/nautobot-app-device-onboarding/releases/tag/v4.2.1) ### Fixed diff --git a/poetry.lock b/poetry.lock index 5e8f2d86..b44b63d3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "amqp" @@ -3125,7 +3125,6 @@ files = [ {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:bb89f0a835bcfc1d42ccd5f41f04870c1b936d8507c6df12b7737febc40f0909"}, {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f0c2d907a1e102526dd2986df638343388b94c33860ff3bbe1384130828714b1"}, {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f8157bed2f51db683f31306aa497311b560f2265998122abe1dce6428bd86567"}, - {file = "psycopg2_binary-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:27422aa5f11fbcd9b18da48373eb67081243662f9b46e6fd07c3eb46e4535142"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-macosx_12_0_x86_64.whl", hash = "sha256:eb09aa7f9cecb45027683bb55aebaaf45a0df8bf6de68801a6afdc7947bb09d4"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b73d6d7f0ccdad7bc43e6d34273f70d587ef62f824d7261c4ae9b8b1b6af90e8"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ce5ab4bf46a211a8e924d307c1b1fcda82368586a19d0a24f8ae166f5c784864"}, diff --git a/pyproject.toml b/pyproject.toml index f7b53426..3438e568 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-device-onboarding" -version = "4.2.1" +version = "4.2.2" description = "A app for Nautobot to easily onboard new devices." authors = ["Network to Code, LLC "] license = "Apache-2.0" From ee5d077c851a7801db8f43bd57703ad829ac35d4 Mon Sep 17 00:00:00 2001 From: Stephen Kiely Date: Wed, 19 Feb 2025 12:27:38 -0600 Subject: [PATCH 3/3] Update docs/admin/release_notes/version_4.2.md Co-authored-by: Glenn Matthews --- docs/admin/release_notes/version_4.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/admin/release_notes/version_4.2.md b/docs/admin/release_notes/version_4.2.md index 67ac3589..6a1a5af4 100755 --- a/docs/admin/release_notes/version_4.2.md +++ b/docs/admin/release_notes/version_4.2.md @@ -15,7 +15,7 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed -- [#320](https://github.com/nautobot/nautobot-app-device-onboarding/issues/320) - Fixed app startup crashing nautobot during startup in some cases. +- [#320](https://github.com/nautobot/nautobot-app-device-onboarding/issues/320) - Fixed app startup crashing Nautobot during startup in some cases. ## [v4.2.1 (2025-02-11)](https://github.com/nautobot/nautobot-app-device-onboarding/releases/tag/v4.2.1)