Skip to content

Commit

Permalink
Merge pull request #669 from nautobot/u/whitej6-panel-patch
Browse files Browse the repository at this point in the history
Closes #668 - Removed unneeded lookup for GoldenConfigSetting
  • Loading branch information
whitej6 authored Oct 31, 2023
2 parents 97a7a79 + 6e8ab09 commit d914934
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: # yamllint disable-line rule:truthy rule:comments
branches:
- "main"
- "develop"
- "ltm-1.6"
tags:
- "v*"
pull_request: ~
Expand Down Expand Up @@ -116,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
Expand All @@ -131,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 }}"
Expand Down
6 changes: 6 additions & 0 deletions docs/admin/release_notes/version_1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions nautobot_golden_config/template_content.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +17,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(),
Expand Down Expand Up @@ -52,6 +52,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",
Expand All @@ -72,13 +74,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",
Expand Down Expand Up @@ -108,6 +110,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<th>Config</th>
</tr>
</thead>
{% if matched_config_setting %}
<tbody>
{% if config_features.compliance and golden_config.compliance_config %}
<tr>
Expand Down Expand Up @@ -118,7 +117,6 @@
</tr>
{% endif %}
</tbody>
{% endif %}
</table>
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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", "<[email protected]>"]

Expand Down

0 comments on commit d914934

Please sign in to comment.