Skip to content

Commit

Permalink
Merge pull request #275 from nautobot/stable-1.0
Browse files Browse the repository at this point in the history
v1.0.3 release prep
  • Loading branch information
itdependsnetworks authored Jun 21, 2022
2 parents f4cea3c + a629499 commit bfc2e5f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 39 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.0.3 - 2022-06

### Fixed

- #257 Resolved template_content displaying SoT AGG link on Device detail page if Device not in scope of GoldenConfigSetting
- Change to pull version from package instead of static variable

## v1.0.2 - 2022-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Nautobot Golden Config has currently no intended scheduled release schedule, and
When a new release of any kind (e.g. from develop to main, or a release of a `stable-<major>.<minor>`) is created the following should happen.
- A release PR is created with:
- Update to the CHANGELOG.md file to reflect the changes.
- Change the version from `<major>.<minor>.<patch>-beta` to `<major>.<minor>.<patch>` in both pyproject.toml and `nautobot.__init__.__version__`.
- Change the version from `<major>.<minor>.<patch>-beta` to `<major>.<minor>.<patch>` in pyproject.toml.
- Set the PR to the proper branch, e.g. either `main` or `stable-<major>.<minor>`.
- Ensure the tests for the PR pass.
- Merge the PR.
Expand Down
8 changes: 7 additions & 1 deletion nautobot_golden_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Plugin declaration for nautobot_golden_config."""
# Metadata is inherited from Nautobot. If not including Nautobot in the environment, this should be added
try:
from importlib import metadata
except ImportError:
# Python version < 3.8
import importlib_metadata as metadata

__version__ = "1.0.2"
__version__ = metadata.version(__name__)

from nautobot.extras.plugins import PluginConfig

Expand Down
7 changes: 6 additions & 1 deletion nautobot_golden_config/template_content.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""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 ENABLE_COMPLIANCE, CONFIG_FEATURES
from nautobot_golden_config.utilities.helper import get_device_to_settings_map


class ConfigComplianceDeviceCheck(PluginTemplateExtension): # pylint: disable=abstract-method
Expand Down Expand Up @@ -69,12 +71,15 @@ def get_device(self):

def right_page(self):
"""Content to add to the configuration compliance."""
golden_config = GoldenConfig.objects.filter(device=self.get_device()).first()
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))
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,40 +64,42 @@
<th>Config</th>
</tr>
</thead>
<tbody>
{% if config_features.compliance and golden_config.compliance_config %}
<tr>
<td>Compliance</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='compliance' %}"><i class="mdi mdi-file-compare"></i></a>
</td>
</tr>
{% if matched_config_setting %}
<tbody>
{% if config_features.compliance and golden_config.compliance_config %}
<tr>
<td>Compliance</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='compliance' %}"><i class="mdi mdi-file-compare"></i></a>
</td>
</tr>
{% endif %}
{% if config_features.intended and golden_config.intended_config %}
<tr>
<td>Intended</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='intended' %}"><i class="mdi mdi-text-box-check-outline"></i></a>
</td>
</tr>
{% endif %}
{% if config_features.backup and golden_config.backup_config %}
<tr>
<td>Actual</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='backup' %}"><i class="mdi mdi-file-document-outline"></i></a>
</td>
</tr>
{% endif %}
{% if config_features.sotagg %}
<tr>
<td>SoT Aggregation Data</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='sotagg' %}"><i class="mdi mdi-code-json"></i></a>
</td>
</tr>
{% endif %}
</tbody>
{% endif %}
{% if config_features.intended and golden_config.intended_config %}
<tr>
<td>Intended</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='intended' %}"><i class="mdi mdi-text-box-check-outline"></i></a>
</td>
</tr>
{% endif %}
{% if config_features.backup and golden_config.backup_config %}
<tr>
<td>Actual</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='backup' %}"><i class="mdi mdi-file-document-outline"></i></a>
</td>
</tr>
{% endif %}
{% if config_features.sotagg %}
<tr>
<td>SoT Aggregation Data</td>
<td>
<a href="{% url 'plugins:nautobot_golden_config:configcompliance_details' pk=device.pk config_type='sotagg' %}"><i class="mdi mdi-code-json"></i></a>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
{% endif %}
Expand Down
8 changes: 6 additions & 2 deletions nautobot_golden_config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np
import yaml
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Count, ExpressionWrapper, F, FloatField, Max, ProtectedError, Q
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput
from django.shortcuts import redirect, render
Expand Down Expand Up @@ -393,8 +394,11 @@ def diff_structured_data(backup_data, intended_data):
if request.GET.get("format") in ["json", "yaml"]:
structure_format = request.GET.get("format")

settings = get_device_to_settings_map(queryset=Device.objects.filter(pk=device.pk))[device.id]
_, output = graph_ql_query(request, device, settings.sot_agg_query.query)
settings = get_device_to_settings_map(queryset=Device.objects.filter(pk=device.pk))
if device.id in settings:
_, output = graph_ql_query(request, device, settings[device.id].sot_agg_query.query)
else:
raise ObjectDoesNotExist(f"{device.name} does not map to a Golden Config Setting.")

if structure_format == "yaml":
output = yaml.dump(json.loads(json.dumps(output)), default_flow_style=False)
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.0.2"
version = "1.0.3"
description = "A plugin for configuration on nautobot"
authors = ["Network to Code, LLC", "<[email protected]>"]

Expand Down

0 comments on commit bfc2e5f

Please sign in to comment.