From bb0c4407a8efda948ed91b0f5ac82159167793b6 Mon Sep 17 00:00:00 2001 From: pszulczewski Date: Wed, 13 Sep 2023 10:16:27 +0200 Subject: [PATCH 1/2] Update location to use .natural_slug and bump up to NB rc.3 --- .github/workflows/ci.yml | 14 +++++++------- development/Dockerfile | 2 +- nautobot_plugin_nornir/__init__.py | 2 +- .../plugins/inventory/nautobot_orm.py | 4 ++-- pyproject.toml | 2 +- tasks.py | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fe6593..6d28ecd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: fail-fast: true matrix: python-version: ["3.11"] - nautobot-version: ["2.0.0-rc.2"] + nautobot-version: ["2.0.0-rc.3"] env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_PYTHON_VER: "${{ matrix.python-version }}" INVOKE_NAUTOBOT_PLUGIN_NORNIR_NAUTOBOT_VER: "${{ matrix.nautobot-version }}" @@ -122,20 +122,20 @@ jobs: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] db-backend: ["postgresql"] - nautobot-version: ["2.0.0-rc.2"] + nautobot-version: ["2.0.0-rc.3"] # The include is a method to limit the amount of jobs ran. This essentially # means that in addition to standard postgres and stable, also the lowest # supported version and with mysql include: - python-version: "3.11" db-backend: "postgresql" - nautobot-version: "2.0.0-rc.2" + nautobot-version: "2.0.0-rc.3" - python-version: "3.8" db-backend: "mysql" - nautobot-version: "2.0.0-rc.2" - - python-version: "3.11" - db-backend: "mysql" - nautobot-version: "latest" + nautobot-version: "2.0.0-rc.3" +# - python-version: "3.11" # TODO pin to 2.0-latest when available +# db-backend: "mysql" +# nautobot-version: "latest" runs-on: "ubuntu-20.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_PYTHON_VER: "${{ matrix.python-version }}" diff --git a/development/Dockerfile b/development/Dockerfile index cad6215..b89a369 100644 --- a/development/Dockerfile +++ b/development/Dockerfile @@ -7,7 +7,7 @@ # !!! USE CAUTION WHEN MODIFYING LINES BELOW # Accepts a desired Nautobot version as build argument, default to 2.0.0-rc.2 -ARG NAUTOBOT_VER="2.0.0-rc.2" +ARG NAUTOBOT_VER="2.0.0-rc.3" # Accepts a desired Python version as build argument, default to 3.8 ARG PYTHON_VER="3.8" diff --git a/nautobot_plugin_nornir/__init__.py b/nautobot_plugin_nornir/__init__.py index a9b862e..f258e60 100644 --- a/nautobot_plugin_nornir/__init__.py +++ b/nautobot_plugin_nornir/__init__.py @@ -20,7 +20,7 @@ class NornirConfig(PluginConfig): ) base_url = "plugin-nornir" required_settings = [] - min_version = "2.0.0-rc.1" + min_version = "2.0.0-rc.3" max_version = "2.9999" default_settings = {} caching_config = {} diff --git a/nautobot_plugin_nornir/plugins/inventory/nautobot_orm.py b/nautobot_plugin_nornir/plugins/inventory/nautobot_orm.py index 41fa1e2..e88d955 100644 --- a/nautobot_plugin_nornir/plugins/inventory/nautobot_orm.py +++ b/nautobot_plugin_nornir/plugins/inventory/nautobot_orm.py @@ -189,7 +189,7 @@ def create_host(self, device, cred, params: Dict): host["platform"] = device.platform.network_driver host["data"]["id"] = device.id host["data"]["type"] = device.device_type.model - host["data"]["location"] = device.location.name + host["data"]["location"] = device.location.natural_slug host["data"]["role"] = device.role.name host["data"]["config_context"] = dict(device.get_config_context()) host["data"]["custom_field_data"] = device.custom_field_data @@ -241,7 +241,7 @@ def get_host_groups(device): """ groups = [ "global", - f"location__{device.location.name}", + f"location__{device.location.natural_slug}", f"role__{device.role.name}", f"type__{device.device_type.model}", f"manufacturer__{device.device_type.manufacturer.name}", diff --git a/pyproject.toml b/pyproject.toml index 24cf9c7..9eb60a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ python = ">=3.8,<3.12" # Required for Python 3.7 for now. See: https://stackoverflow.com/a/73932581/194311 importlib-metadata = "4.13.0" # Used for local development -nautobot = { version = "2.0.0-rc.2", optional = true } +nautobot = { version = "2.0.0-rc.3", optional = true } nornir-nautobot = { git = "https://github.com/nautobot/nornir-nautobot.git", branch = "next-2.0" } # TODO: Point to 2.x version netutils = ">=1.0.0" diff --git a/tasks.py b/tasks.py index 89d054e..e13bc93 100644 --- a/tasks.py +++ b/tasks.py @@ -40,7 +40,7 @@ def is_truthy(arg): namespace.configure( { "nautobot_plugin_nornir": { - "nautobot_ver": "2.0.0-rc.2", + "nautobot_ver": "2.0.0-rc.3", "project_name": "nautobot_plugin_nornir", "python_ver": "3.11", "local": False, From 7df9de8183ee83b49855d075a786fff67d9457db Mon Sep 17 00:00:00 2001 From: pszulczewski Date: Tue, 19 Sep 2023 11:20:55 +0200 Subject: [PATCH 2/2] Update unittests --- nautobot_plugin_nornir/tests/test_nautobot_orm.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nautobot_plugin_nornir/tests/test_nautobot_orm.py b/nautobot_plugin_nornir/tests/test_nautobot_orm.py index bf55b65..523f50c 100644 --- a/nautobot_plugin_nornir/tests/test_nautobot_orm.py +++ b/nautobot_plugin_nornir/tests/test_nautobot_orm.py @@ -15,9 +15,13 @@ def setUp(self): self.location_type = LocationType.objects.create(name="Site") self.location_type.content_types.set([device_content_type]) active = Status.objects.get(name="Active") - self.site1 = Location.objects.create(name="USWEST", location_type_id=self.location_type.id, status_id=active.id) + self.location = Location.objects.create( + name="USWEST", location_type_id=self.location_type.id, status_id=active.id + ) self.manufacturer1 = Manufacturer.objects.create(name="Juniper") - self.platform = Platform.objects.create(name="Cisco IOS", network_driver="junos", napalm_driver="junos") + self.platform = Platform.objects.create( + name="Juniper Junos", network_driver="juniper_junos", napalm_driver="junos" + ) self.device_type1 = DeviceType.objects.create(model="SRX3600", manufacturer=self.manufacturer1) self.device_role1 = Role.objects.create(name="Firewall") self.device_role1.content_types.set([device_content_type]) @@ -26,7 +30,7 @@ def setUp(self): Device.objects.create( name="device1", - location=self.site1, + location=self.location, device_type=self.device_type1, platform=self.platform, role=self.device_role1, @@ -35,7 +39,7 @@ def setUp(self): Device.objects.create( name="device2", - location=self.site1, + location=self.location, device_type=self.device_type1, platform=self.platform, role=self.device_role2,