From 41ee743877d6dbbc6468ffe38fbe8d2279136e8f Mon Sep 17 00:00:00 2001 From: Glenn Matthews Date: Wed, 21 Sep 2022 13:36:29 -0400 Subject: [PATCH 1/5] Fix nested serializer quirks --- nautobot_firewall_models/api/nested_serializers.py | 4 +++- nautobot_firewall_models/api/serializers.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nautobot_firewall_models/api/nested_serializers.py b/nautobot_firewall_models/api/nested_serializers.py index 45078897..4342668d 100644 --- a/nautobot_firewall_models/api/nested_serializers.py +++ b/nautobot_firewall_models/api/nested_serializers.py @@ -1,6 +1,6 @@ """Nested serializers.""" from nautobot.core.api import WritableNestedSerializer -from rest_framework.serializers import HyperlinkedIdentityField +from rest_framework.serializers import CharField, HyperlinkedIdentityField from nautobot_firewall_models import models @@ -21,6 +21,8 @@ class NestedIPRangeSerializer(WritableNestedSerializer): """Nested serializer for IPRange.""" url = HyperlinkedIdentityField(view_name="plugins-api:nautobot_firewall_models-api:fqdn-detail") + start_address = CharField() + end_address = CharField() class Meta: """Meta attributes.""" diff --git a/nautobot_firewall_models/api/serializers.py b/nautobot_firewall_models/api/serializers.py index e03efd5d..1e44c716 100644 --- a/nautobot_firewall_models/api/serializers.py +++ b/nautobot_firewall_models/api/serializers.py @@ -18,7 +18,7 @@ from nautobot_firewall_models import models -from nautobot_firewall_models.api import nested_serializers +from nautobot_firewall_models.api.nested_serializers import NestedFQDNSerializer, NestedIPRangeSerializer class StatusModelSerializerMixin(_StatusModelSerializerMixin): # pylint: disable=abstract-method @@ -66,8 +66,8 @@ class AddressObjectSerializer(TaggedObjectSerializer, StatusModelSerializerMixin url = serializers.HyperlinkedIdentityField( view_name="plugins-api:nautobot_firewall_models-api:addressobject-detail" ) - ip_range = nested_serializers.NestedIPRangeSerializer(required=False) - fqdn = nested_serializers.NestedFQDNSerializer(required=False) + ip_range = NestedIPRangeSerializer(required=False) + fqdn = NestedFQDNSerializer(required=False) ip_address = NestedIPAddressSerializer(required=False) prefix = NestedPrefixSerializer(required=False) From 4a0ab84ea8a3341b963a4bc37f09d296dc5d9889 Mon Sep 17 00:00:00 2001 From: Ken Celenza Date: Thu, 22 Sep 2022 00:54:09 -0400 Subject: [PATCH 2/5] update docs --- docs/capirca.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/capirca.md b/docs/capirca.md index f1759c1a..4bc41996 100644 --- a/docs/capirca.md +++ b/docs/capirca.md @@ -49,7 +49,7 @@ The process is to create a custom field, such as `ctd_pan-application`, this wil capirca_allow = ['ctd_pan-application', 'ctd_expiration'] ``` -> Note: This is pseudo-code and is technically the custom_field called `capirca_allow` that has the dat `['ctd_pan-application', 'ctd_expiration']` in this example. +> Note: This is pseudo-code and is technically the custom_field called `capirca_allow` that has the data `["ctd_pan-application", "ctd_expiration"]` in this example. As previously mentioned, there is only a small opinion that is applied from the translation between the model and Capirca. That being said, Capirca has an opinion on how rules and objects are deployed, and within this project there is no consideration for how that may not align with anyone's intention on how Capirca should work. All such considerations should be referred to the Capirca project. There is no intention to modify the output that Capirca creates **in any situation** within this plugin. From 6df4a66263c2cc5bcb32df7de0a3ced8b54b61c0 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 22 Sep 2022 08:39:30 -0500 Subject: [PATCH 3/5] proper ordering: --- .../0009_proper_ordering_on_through.py | 17 +++++++++++++++++ .../models/through_models.py | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py diff --git a/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py b/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py new file mode 100644 index 00000000..a77252a6 --- /dev/null +++ b/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.15 on 2022-09-22 13:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("nautobot_firewall_models", "0008_renaming_part3"), + ] + + operations = [ + migrations.AlterModelOptions( + name="policyrulem2m", + options={"ordering": ["rule__index"]}, + ), + ] diff --git a/nautobot_firewall_models/models/through_models.py b/nautobot_firewall_models/models/through_models.py index 2a7edb1a..9ccfb7de 100644 --- a/nautobot_firewall_models/models/through_models.py +++ b/nautobot_firewall_models/models/through_models.py @@ -66,6 +66,11 @@ class PolicyRuleM2M(BaseModel): policy = models.ForeignKey("nautobot_firewall_models.Policy", on_delete=models.CASCADE) rule = models.ForeignKey("nautobot_firewall_models.PolicyRule", on_delete=models.PROTECT) + class Meta: + """Meta class.""" + + ordering = ["rule__index"] + class ServiceObjectGroupM2M(BaseModel): """Custom through model to on_delete=models.PROTECT to prevent deleting associated ServiceGroup if assigned to a PolicyRule.""" From ac0f505d3253cf6df9779ebc4a56074b74fac2a5 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 22 Sep 2022 08:55:25 -0500 Subject: [PATCH 4/5] v1.0.2 prep --- CHANGELOG.md | 8 ++++++++ mkdocs.yml | 2 ++ pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 421c6e1a..a39827a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## v1.0.1 - 2022-09-22 + +### Fixed + +- #87 NestedWritabeSerializer fix for schema generation on VarBinaryField +- #88 Docs fix +- #89 Ressolve ordering when viewing PolicyRules via a Policy view. + ## v1.0.1 - 2022-09-18 ### Fixed diff --git a/mkdocs.yml b/mkdocs.yml index 389cc4ea..caed4fd8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -25,3 +25,5 @@ nav: - Examples: "example.md" - Development Environment: "development.md" - Models: "models.md" + - Capirca Usage: "capirca.md" + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6a18095a..0208f73d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-firewall-models" -version = "1.0.1" +version = "1.0.2" description = "Nautobot plugin to model firewall objects." authors = ["Network to Code, LLC "] license = "Apache-2.0" From 8cdfad935f00bc1993e542fc486986e4e875c93c Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 22 Sep 2022 08:57:35 -0500 Subject: [PATCH 5/5] yamllint fix --- CHANGELOG.md | 2 +- mkdocs.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a39827a7..0723783f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## v1.0.1 - 2022-09-22 +## v1.0.2 - 2022-09-22 ### Fixed diff --git a/mkdocs.yml b/mkdocs.yml index caed4fd8..b595c06a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -26,4 +26,3 @@ nav: - Development Environment: "development.md" - Models: "models.md" - Capirca Usage: "capirca.md" - \ No newline at end of file