From 4f612476237305b23716919264dc1526bd3cee29 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Tue, 31 Oct 2023 14:28:25 -0500 Subject: [PATCH 1/3] Closes #668 - Removed unneeded lookup for GoldenConfigSetting --- .github/workflows/ci.yml | 1 + docs/admin/release_notes/version_1.6.md | 6 ++++++ nautobot_golden_config/template_content.py | 10 ++++++++-- .../nautobot_golden_config/content_template.html | 2 -- pyproject.toml | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90d231d3..fb9334b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: # yamllint disable-line rule:truthy rule:comments branches: - "main" - "develop" + - "ltm-1.6" tags: - "v*" pull_request: ~ diff --git a/docs/admin/release_notes/version_1.6.md b/docs/admin/release_notes/version_1.6.md index 1e047824..259d890a 100755 --- a/docs/admin/release_notes/version_1.6.md +++ b/docs/admin/release_notes/version_1.6.md @@ -5,6 +5,12 @@ - Add functionality to compliance result to provide a Remediation plan. - Supports Nautobot >=1.6.1,<2.0.0. +## v1.6.3 - 2023-10 + +### Fixed + +- [#668](https://github.com/nautobot/nautobot-plugin-golden-config/issue/668) - Removed unneeded lookup for GoldenConfigSetting + ## v1.6.2 - 2023-09 ### Fixed diff --git a/nautobot_golden_config/template_content.py b/nautobot_golden_config/template_content.py index 6234cdb1..1dc769e6 100644 --- a/nautobot_golden_config/template_content.py +++ b/nautobot_golden_config/template_content.py @@ -19,6 +19,8 @@ def get_device(self): def right_page(self): """Content to add to the configuration compliance.""" comp_obj = ConfigCompliance.objects.filter(device=self.get_device()).values("rule__feature__name", "compliance") + if not comp_obj: + return "" extra_context = { "compliance": comp_obj, "device": self.get_device(), @@ -52,6 +54,8 @@ def right_page(self): .order_by("rule__feature__name") .values("rule__feature__name", "compliant", "non_compliant") ) + if not comp_obj: + return "" extra_context = {"compliance": comp_obj, "template_type": "site"} return self.render( "nautobot_golden_config/content_template.html", @@ -72,13 +76,13 @@ def right_page(self): """Content to add to the configuration compliance.""" device = self.get_device() golden_config = GoldenConfig.objects.filter(device=device).first() - settings = get_device_to_settings_map(queryset=Device.objects.filter(id=device.id)) + if not golden_config: + return "" extra_context = { "device": self.get_device(), # device, "golden_config": golden_config, "template_type": "device-configs", "config_features": CONFIG_FEATURES, - "matched_config_setting": settings.get(device.id, False), } return self.render( "nautobot_golden_config/content_template.html", @@ -108,6 +112,8 @@ def right_page(self): .order_by("rule__feature__name") .values("rule__feature__name", "compliant", "non_compliant") ) + if not comp_obj: + return "" extra_context = {"compliance": comp_obj, "template_type": "site"} return self.render( "nautobot_golden_config/content_template.html", diff --git a/nautobot_golden_config/templates/nautobot_golden_config/content_template.html b/nautobot_golden_config/templates/nautobot_golden_config/content_template.html index 8b1f6572..294c25bf 100644 --- a/nautobot_golden_config/templates/nautobot_golden_config/content_template.html +++ b/nautobot_golden_config/templates/nautobot_golden_config/content_template.html @@ -64,7 +64,6 @@ Config - {% if matched_config_setting %} {% if config_features.compliance and golden_config.compliance_config %} @@ -118,7 +117,6 @@ {% endif %} - {% endif %} {% endif %} diff --git a/pyproject.toml b/pyproject.toml index d938e5de..db6678c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-golden-config" -version = "1.6.2" +version = "1.6.3" description = "A plugin for configuration on nautobot" authors = ["Network to Code, LLC", ""] From 1d20c94c73dd6d1b4c3f3ecded0f2b4e0f3de965 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Tue, 31 Oct 2023 14:49:26 -0500 Subject: [PATCH 2/3] flake8 --- nautobot_golden_config/template_content.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nautobot_golden_config/template_content.py b/nautobot_golden_config/template_content.py index 1dc769e6..3f55c98b 100644 --- a/nautobot_golden_config/template_content.py +++ b/nautobot_golden_config/template_content.py @@ -1,10 +1,8 @@ """Added content to the device model view for config compliance.""" from django.db.models import Count, Q -from nautobot.dcim.models import Device from nautobot.extras.plugins import PluginTemplateExtension from nautobot_golden_config.models import ConfigCompliance, GoldenConfig from nautobot_golden_config.utilities.constant import CONFIG_FEATURES, ENABLE_COMPLIANCE -from nautobot_golden_config.utilities.helper import get_device_to_settings_map class ConfigComplianceDeviceCheck(PluginTemplateExtension): # pylint: disable=abstract-method From 6e8ab093700c9843da90abdd671d2ca1f51e7881 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Tue, 31 Oct 2023 15:04:58 -0500 Subject: [PATCH 3/3] update matrix for just 1.6 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb9334b7..e4493d46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,9 +117,9 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.11"] db-backend: ["postgresql"] - nautobot-version: ["latest"] + nautobot-version: ["ltm-1.6"] # 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 @@ -132,7 +132,7 @@ jobs: nautobot-version: "1.6.1" - python-version: "3.11" db-backend: "mysql" - nautobot-version: "latest" + nautobot-version: "ltm-1.6" runs-on: "ubuntu-20.04" env: INVOKE_NAUTOBOT_GOLDEN_CONFIG_PYTHON_VER: "${{ matrix.python-version }}"