Skip to content

Commit e262ba8

Browse files
authored
Merge pull request #214 from netbox-community/feat/netbox-4-1
Release 0.7.0
2 parents 026c591 + 02f428a commit e262ba8

File tree

9 files changed

+58
-73
lines changed

9 files changed

+58
-73
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
ARG NETBOX_VARIANT=v4.0
1+
ARG NETBOX_VARIANT=v4.1
22

33
FROM netboxcommunity/netbox:${NETBOX_VARIANT}
44

55
RUN mkdir -pv /plugins/netbox-acls
66
COPY . /plugins/netbox-acls
77

88
RUN /opt/netbox/venv/bin/python3 /plugins/netbox-acls/setup.py develop && \
9-
cp -rf /plugins/netbox-acls/netbox_acls/ /opt/netbox/venv/lib/python3.11/site-packages/netbox_acls
9+
cp -rf /plugins/netbox-acls/netbox_acls/ /opt/netbox/venv/lib/python3.12/site-packages/netbox_acls

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ See the [CONTRIBUTING](CONTRIBUTING.md) for more information.
3636

3737
Each Plugin Version listed below has been tested with its corresponding NetBox Version.
3838

39-
| NetBox Version | Plugin Version |
39+
| NetBox Version | Plugin Version |
4040
|:-------------------:|:--------------:|
41+
| 4.1.x | 1.7.0 |
4142
| >= 4.0.2 < 4.1.0 | 1.6.1 |
42-
| 3.7 | 1.5.0 |
43-
| 3.6 | 1.4.0 |
44-
| 3.5 | 1.3.0 |
45-
| 3.4 | 1.2.2 |
46-
| 3.3 | 1.1.0 |
47-
| 3.2 | 1.0.1 |
43+
| 3.7.x | 1.5.0 |
44+
| 3.6.x | 1.4.0 |
45+
| 3.5.x | 1.3.0 |
46+
| 3.4.x | 1.2.2 |
47+
| 3.3.x | 1.1.0 |
48+
| 3.2.x | 1.0.1 |
4849

4950
## Installing
5051

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
version: '3.4'
32

43
services:
54
netbox:

netbox_acls/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class NetBoxACLsConfig(PluginConfig):
1717
version = __version__
1818
description = "Manage simple ACLs in NetBox"
1919
base_url = "access-lists"
20-
min_version = "4.0.2"
21-
max_version = "4.0.99"
20+
min_version = "4.1.0"
21+
max_version = "4.1.99"
2222

2323

2424
config = NetBoxACLsConfig

netbox_acls/api/serializers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
from django.contrib.contenttypes.models import ContentType
77
from drf_spectacular.utils import extend_schema_field
8-
from ipam.api.serializers import NestedPrefixSerializer
8+
from ipam.api.serializers import PrefixSerializer
99
from netbox.api.fields import ContentTypeField
1010
from netbox.api.serializers import NetBoxModelSerializer
11-
from netbox.constants import NESTED_SERIALIZER_PREFIX
1211
from rest_framework import serializers
1312
from utilities.api import get_serializer_for_model
1413

@@ -81,10 +80,9 @@ class Meta:
8180
def get_assigned_object(self, obj):
8281
serializer = get_serializer_for_model(
8382
obj.assigned_object,
84-
prefix=NESTED_SERIALIZER_PREFIX,
8583
)
8684
context = {"request": self.context["request"]}
87-
return serializer(obj.assigned_object, context=context).data
85+
return serializer(obj.assigned_object, nested=True, context=context).data
8886

8987
def validate(self, data):
9088
"""
@@ -145,11 +143,10 @@ class Meta:
145143
@extend_schema_field(serializers.DictField())
146144
def get_assigned_object(self, obj):
147145
serializer = get_serializer_for_model(
148-
obj.assigned_object,
149-
prefix=NESTED_SERIALIZER_PREFIX,
146+
obj.assigned_object
150147
)
151148
context = {"request": self.context["request"]}
152-
return serializer(obj.assigned_object, context=context).data
149+
return serializer(obj.assigned_object, nested=True, context=context).data
153150

154151
def validate(self, data):
155152
"""
@@ -187,10 +184,11 @@ class ACLStandardRuleSerializer(NetBoxModelSerializer):
187184
view_name="plugins-api:netbox_acls-api:aclstandardrule-detail",
188185
)
189186
access_list = NestedAccessListSerializer()
190-
source_prefix = NestedPrefixSerializer(
187+
source_prefix = PrefixSerializer(
191188
required=False,
192189
allow_null=True,
193190
default=None,
191+
nested=True
194192
)
195193

196194
class Meta:
@@ -251,15 +249,17 @@ class ACLExtendedRuleSerializer(NetBoxModelSerializer):
251249
view_name="plugins-api:netbox_acls-api:aclextendedrule-detail",
252250
)
253251
access_list = NestedAccessListSerializer()
254-
source_prefix = NestedPrefixSerializer(
252+
source_prefix = PrefixSerializer(
255253
required=False,
256254
allow_null=True,
257255
default=None,
256+
nested=True
258257
)
259-
destination_prefix = NestedPrefixSerializer(
258+
destination_prefix = PrefixSerializer(
260259
required=False,
261260
allow_null=True,
262261
default=None,
262+
nested=True
263263
)
264264

265265
class Meta:

netbox_acls/forms/filtersets.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""
22
Defines each django model's GUI filter/search options.
33
"""
4-
4+
from django.utils.translation import gettext_lazy as _
55
from dcim.models import Device, Interface, Region, Site, SiteGroup, VirtualChassis
66
from django import forms
77
from django.utils.translation import gettext as _
88
from ipam.models import Prefix
99
from netbox.forms import NetBoxModelFilterSetForm
10+
from utilities.forms.rendering import FieldSet
1011
from utilities.forms.fields import (
1112
DynamicModelChoiceField,
1213
DynamicModelMultipleChoiceField,
@@ -90,22 +91,11 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
9091
tag = TagFilterField(model)
9192

9293
fieldsets = (
93-
(None, ("q", "tag")),
94-
(
95-
"Host Details",
96-
(
97-
"region",
98-
"site_group",
99-
"site",
100-
"device_id",
101-
"virtual_chassis_id",
102-
"virtual_machine_id",
103-
),
104-
),
105-
("ACL Details", ("type", "default_action")),
94+
FieldSet("region", "site_group", "site", "device_id", "virtual_chassis_id", "virtual_machine_id", name=_("Host Details")),
95+
FieldSet("type", "default_action", name=_('ACL Details')),
96+
FieldSet("q", "tag",name=None)
10697
)
10798

108-
10999
class ACLInterfaceAssignmentFilterForm(NetBoxModelFilterSetForm):
110100
"""
111101
GUI filter form to search the django AccessList model.
@@ -195,12 +185,11 @@ class ACLStandardRuleFilterForm(NetBoxModelFilterSetForm):
195185
choices=add_blank_choice(ACLRuleActionChoices),
196186
required=False,
197187
)
188+
198189
fieldsets = (
199-
(None, ("q", "tag")),
200-
("Rule Details", ("access_list", "action", "source_prefix")),
190+
FieldSet("access_list", "action", "source_prefix", name=_('Rule Details')),
191+
FieldSet("q", "tag",name=None)
201192
)
202-
203-
204193
class ACLExtendedRuleFilterForm(NetBoxModelFilterSetForm):
205194
"""
206195
GUI filter form to search the django ACLExtendedRule model.
@@ -235,15 +224,6 @@ class ACLExtendedRuleFilterForm(NetBoxModelFilterSetForm):
235224
)
236225

237226
fieldsets = (
238-
(None, ("q", "tag")),
239-
(
240-
"Rule Details",
241-
(
242-
"access_list",
243-
"action",
244-
"source_prefix",
245-
"desintation_prefix",
246-
"protocol",
247-
),
248-
),
227+
FieldSet("access_list", "action", "source_prefix", "desintation_prefix", "protocol", name=_('Rule Details')),
228+
FieldSet("q", "tag",name=None)
249229
)

netbox_acls/forms/models.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""
22
Defines each django model's GUI form to add or edit objects for each django model.
33
"""
4-
4+
from django.utils.translation import gettext_lazy as _
55
from dcim.models import Device, Interface, Region, Site, SiteGroup, VirtualChassis
66
from django.contrib.contenttypes.models import ContentType
77
from django.core.exceptions import ValidationError
88
from django.utils.safestring import mark_safe
99
from ipam.models import Prefix
1010
from netbox.forms import NetBoxModelForm
11+
from utilities.forms.rendering import FieldSet
1112
from utilities.forms.fields import CommentField, DynamicModelChoiceField
1213
from virtualization.models import (
1314
Cluster,
@@ -118,7 +119,12 @@ class AccessListForm(NetBoxModelForm):
118119
)
119120

120121
comments = CommentField()
121-
122+
fieldsets = (
123+
FieldSet('region', 'site_group', 'site', 'virtual_machine', 'virtual_chassis', 'device', name=_('Assignment')),
124+
FieldSet('name', 'type', 'default_action', name=_('Access List')),
125+
FieldSet('comments', 'tags', name=_('')),
126+
)
127+
122128
class Meta:
123129
model = AccessList
124130
fields = (
@@ -134,6 +140,7 @@ class Meta:
134140
"comments",
135141
"tags",
136142
)
143+
137144
help_texts = {
138145
"default_action": "The default behavior of the ACL.",
139146
"name": "The name uniqueness per device is case insensitive.",
@@ -285,6 +292,11 @@ class ACLInterfaceAssignmentForm(NetBoxModelForm):
285292
),
286293
)
287294
comments = CommentField()
295+
fieldsets = (
296+
FieldSet('device', 'interface', 'virtual_machine', 'vminterface', name=_('Assignment')),
297+
FieldSet('access_list', 'direction', name=_('Access List Details')),
298+
FieldSet('comments', 'tags', name=_('')),
299+
)
288300

289301
def __init__(self, *args, **kwargs):
290302
# Initialize helper selectors
@@ -313,6 +325,7 @@ class Meta:
313325
"comments",
314326
"tags",
315327
)
328+
316329
help_texts = {
317330
"direction": mark_safe(
318331
"<b>*Note:</b> CANNOT assign 2 ACLs to the same interface & direction.",
@@ -440,10 +453,9 @@ class ACLStandardRuleForm(NetBoxModelForm):
440453
)
441454

442455
fieldsets = (
443-
("Access List Details", ("access_list", "description", "tags")),
444-
("Rule Definition", ("index", "action", "remark", "source_prefix")),
456+
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
457+
FieldSet("index", "action", "remark", "source_prefix", name=_('Rule Definition'))
445458
)
446-
447459
class Meta:
448460
model = ACLStandardRule
449461
fields = (
@@ -455,6 +467,10 @@ class Meta:
455467
"tags",
456468
"description",
457469
)
470+
471+
472+
473+
458474
help_texts = {
459475
"index": help_text_acl_rule_index,
460476
"action": help_text_acl_action,
@@ -524,22 +540,9 @@ class ACLExtendedRuleForm(NetBoxModelForm):
524540
label="Destination Prefix",
525541
)
526542
fieldsets = (
527-
("Access List Details", ("access_list", "description", "tags")),
528-
(
529-
"Rule Definition",
530-
(
531-
"index",
532-
"action",
533-
"remark",
534-
"source_prefix",
535-
"source_ports",
536-
"destination_prefix",
537-
"destination_ports",
538-
"protocol",
539-
),
540-
),
543+
FieldSet("access_list", "description", "tags", name=_('Access List Details')),
544+
FieldSet("index", "action", "remark", "source_prefix", "source_ports", "destination_prefix", "destination_ports", "protocol", name=_('Rule Definition'))
541545
)
542-
543546
class Meta:
544547
model = ACLExtendedRule
545548
fields = (
@@ -555,6 +558,7 @@ class Meta:
555558
"tags",
556559
"description",
557560
)
561+
558562
help_texts = {
559563
"action": help_text_acl_action,
560564
"destination_ports": help_text_acl_rule_logic,

netbox_acls/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.6.1"
1+
__version__ = "1.7.0"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def get_version(relative_path):
5454
"Programming Language :: Python :: 3 :: Only",
5555
"Programming Language :: Python :: 3.10",
5656
"Programming Language :: Python :: 3.11",
57+
"Programming Language :: Python :: 3.12",
5758
"Intended Audience :: System Administrators",
5859
"Intended Audience :: Telecommunications Industry",
5960
"Framework :: Django",

0 commit comments

Comments
 (0)