Skip to content

Commit

Permalink
Merge pull request #783 from nautobot/develop
Browse files Browse the repository at this point in the history
Release 2.1.1
  • Loading branch information
itdependsnetworks authored Jul 17, 2024
2 parents 13efb79 + c016b4d commit a37c60b
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ jobs:
- name: "Run Tests"
run: "poetry run invoke unittest"
changelog:
if: |
if: >
contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
(github.head_ref != 'main')
(github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository code"
Expand Down
21 changes: 21 additions & 0 deletions docs/admin/release_notes/version_2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,24 @@
### Fixed

- [#723](https://github.com/nautobot/nautobot-app-golden-config/issues/723) - Hide compliance tab in device view if no compliance results exist.


## v2.1.1

### Fixed

- [#773](https://github.com/nautobot/nautobot-app-golden-config/issues/773) - Fixed deepdiff dependency range.

### Dependencies

- [#769](https://github.com/nautobot/nautobot-app-golden-config/issues/769) - Updated django-pivot to ~1.9.0.

### Documentation

- [#771](https://github.com/nautobot/nautobot-app-golden-config/issues/771) - Updated navigation tree for documentation updates for 2.1 release notes and XML compliance.
- [#775](https://github.com/nautobot/nautobot-app-golden-config/issues/775) - Add FAQ for deepdiff and numpy dependency issue.
- [#776](https://github.com/nautobot/nautobot-app-golden-config/issues/776) - Updated app config and urls config for providing link to documentation.

### Housekeeping

- [#769](https://github.com/nautobot/nautobot-app-golden-config/issues/769) - Added view tests for ConfigComplianceUIViewSet.
6 changes: 5 additions & 1 deletion docs/user/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,8 @@ There is an ongoing effort to better document each [troubleshooting case](../adm
## _Why is the `_isnull` on DateTime filters considered experimental?_
There are various ways we can create a programmatic interface, which may change the behavior or name, for now it should be considered experimental as we may update this strategy.
There are various ways we can create a programmatic interface, which may change the behavior or name, for now it should be considered experimental as we may update this strategy.
## _I received an error `AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.` what should I do?_
Due to an incompatiblitly between DeepDiff and numPy, you must find a version of those two that are compatible with each other. See [here](https://github.com/seperman/deepdiff/issues/464) for more information. The easiest thing to do is upgrade them both.
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ nav:
- Navigate Compliance: "user/app_feature_compliance.md"
- Navigate Compliance CLI: "user/app_feature_compliancecli.md"
- Navigate Compliance JSON: "user/app_feature_compliancejson.md"
- Navigate Compliance XML: "user/app_feature_compliancexml.md"
- Navigate Compliance Custom: "user/app_feature_compliancecustom.md"
- Navigate Intended: "user/app_feature_intended.md"
- Navigate SoT Agg: "user/app_feature_sotagg.md"
Expand Down Expand Up @@ -163,6 +164,7 @@ nav:
- Migrating To v2: "admin/migrating_to_v2.md"
- Release Notes:
- "admin/release_notes/index.md"
- v2.1: "admin/release_notes/version_2.1.md"
- v2.0: "admin/release_notes/version_2.0.md"
- v1.6: "admin/release_notes/version_1.6.md"
- v1.5: "admin/release_notes/version_1.5.md"
Expand Down
1 change: 1 addition & 0 deletions nautobot_golden_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GoldenConfig(NautobotAppConfig):
author_email = "[email protected]"
description = "Nautobot Apps that embraces NetDevOps and automates configuration backups, performs configuration compliance, generates intended configurations, and has config remediation and deployment features. Includes native Git integration and gives users the flexibility to mix and match the supported features."
base_url = "golden-config"
docs_view_name = "plugins:nautobot_golden_config:docs"
default_settings = {
"enable_backup": True,
"enable_compliance": True,
Expand Down
3 changes: 2 additions & 1 deletion nautobot_golden_config/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""REST API serializer capabilities for graphql app."""

# pylint: disable=too-many-ancestors
from rest_framework import serializers

Expand Down Expand Up @@ -93,7 +94,7 @@ class ConfigToPushSerializer(DeviceSerializer):

config = serializers.SerializerMethodField()

class Meta(DeviceSerializer):
class Meta(DeviceSerializer.Meta):
"""Extend the Device serializer with the configuration after postprocessing."""

fields = "__all__"
Expand Down
2 changes: 1 addition & 1 deletion nautobot_golden_config/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def _generate_config_plan_from_feature(self):
def _generate_config_plan_from_manual(self):
"""Generate config plans from manual."""
default_context = {
"request": self.request,
"request": self.request, # pylint: disable=no-member
"user": self.user,
}
for device in self._device_qs:
Expand Down
3 changes: 1 addition & 2 deletions nautobot_golden_config/nornir_plays/config_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def diff_files(backup_file, intended_file):
with open(intended_file, encoding="utf-8") as file:
intended = file.readlines()

for line in difflib.unified_diff(backup, intended, lineterm=""):
yield line
yield from difflib.unified_diff(backup, intended, lineterm="")


@close_threaded_db_connections
Expand Down
69 changes: 68 additions & 1 deletion nautobot_golden_config/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.test import override_settings, RequestFactory, TestCase
from django.urls import reverse

from nautobot.core.models.querysets import RestrictedQuerySet
from nautobot.dcim.models import Device
from nautobot.extras.models import Relationship, RelationshipAssociation, Status
from nautobot.core.testing import ViewTestCases
Expand Down Expand Up @@ -350,3 +351,69 @@ def setUpTestData(cls):
@skip("TODO: 2.0 Figure out how to have pass.")
def test_list_objects_with_constrained_permission(self):
pass


@override_settings(EXEMPT_VIEW_PERMISSIONS=["*"])
class ConfigComplianceUIViewSetTestCase(
ViewTestCases.BulkDeleteObjectsViewTestCase,
# ViewTestCases.ListObjectsViewTestCase, # generic list view tests won't work for this view since the queryset is pivoted
):
"""Test ConfigComplianceUIViewSet views."""

model = models.ConfigCompliance

@classmethod
def setUpTestData(cls):
create_device_data()
dev01 = Device.objects.get(name="Device 1")
dev02 = Device.objects.get(name="Device 2")
dev03 = Device.objects.get(name="Device 3")
dev04 = Device.objects.get(name="Device 4")

for iterator_i in range(4):
feature_dev01 = create_feature_rule_json(dev01, feature=f"TestFeature{iterator_i}")
feature_dev02 = create_feature_rule_json(dev02, feature=f"TestFeature{iterator_i}")
feature_dev03 = create_feature_rule_json(dev03, feature=f"TestFeature{iterator_i}")

updates = [
{"device": dev01, "feature": feature_dev01},
{"device": dev02, "feature": feature_dev02},
{"device": dev03, "feature": feature_dev03},
{"device": dev04, "feature": feature_dev01},
]
for iterator_j, update in enumerate(updates):
compliance_int = iterator_j % 2
models.ConfigCompliance.objects.create(
device=update["device"],
rule=update["feature"],
actual={"foo": {"bar-1": "baz"}},
intended={"foo": {f"bar-{compliance_int}": "baz"}},
compliance=bool(compliance_int),
compliance_int=compliance_int,
)

def test_alter_queryset(self):
"""Test alter_queryset method returns the expected pivoted queryset."""

unused_features = (
models.ComplianceFeature.objects.create(slug="unused-feature-1", name="Unused Feature 1"),
models.ComplianceFeature.objects.create(slug="unused-feature-2", name="Unused Feature 2"),
)
request = RequestFactory(SERVER_NAME="nautobot.example.com").get(
reverse("plugins:nautobot_golden_config:configcompliance_list")
)
request.user = self.user
queryset = views.ConfigComplianceUIViewSet(request=request).alter_queryset(request)
features = (
models.ComplianceFeature.objects.filter(feature__rule__isnull=False)
.values_list("slug", flat=True)
.distinct()
)
self.assertNotIn(unused_features[0].slug, features)
self.assertNotIn(unused_features[1].slug, features)
self.assertGreater(len(features), 0)
self.assertIsInstance(queryset, RestrictedQuerySet)
for device in queryset:
self.assertSequenceEqual(list(device.keys()), ["device", "device__name", *features])
for feature in features:
self.assertIn(device[feature], [0, 1])
3 changes: 3 additions & 0 deletions nautobot_golden_config/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Django urlpatterns declaration for config compliance app."""
from django.urls import path
from django.templatetags.static import static
from django.views.generic import RedirectView

from nautobot.core.views.routers import NautobotUIViewSetRouter
from nautobot_golden_config import views
Expand All @@ -20,4 +22,5 @@
urlpatterns = [
path("config-compliance/overview/", views.ConfigComplianceOverview.as_view(), name="configcompliance_overview"),
path("config-plan/bulk_deploy/", views.ConfigPlanBulkDeploy.as_view(), name="configplan_bulk-deploy"),
path("docs/", RedirectView.as_view(url=static("nautobot_golden_config/docs/index.html")), name="docs"),
] + router.urls
Loading

0 comments on commit a37c60b

Please sign in to comment.