ipfabric_netbox 4.3.0b4__py3-none-any.whl → 4.3.0b6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ipfabric_netbox might be problematic. Click here for more details.
- ipfabric_netbox/__init__.py +1 -1
- ipfabric_netbox/choices.py +2 -2
- ipfabric_netbox/forms.py +137 -0
- ipfabric_netbox/models.py +1 -1
- ipfabric_netbox/tables.py +2 -0
- ipfabric_netbox/tests/test_views.py +210 -157
- ipfabric_netbox/urls.py +24 -108
- ipfabric_netbox/views.py +283 -130
- {ipfabric_netbox-4.3.0b4.dist-info → ipfabric_netbox-4.3.0b6.dist-info}/METADATA +1 -1
- {ipfabric_netbox-4.3.0b4.dist-info → ipfabric_netbox-4.3.0b6.dist-info}/RECORD +11 -11
- {ipfabric_netbox-4.3.0b4.dist-info → ipfabric_netbox-4.3.0b6.dist-info}/WHEEL +0 -0
ipfabric_netbox/__init__.py
CHANGED
ipfabric_netbox/choices.py
CHANGED
|
@@ -170,7 +170,7 @@ class IPFabricTransformMapSourceModelChoices(ChoiceSet):
|
|
|
170
170
|
VRF = "vrf"
|
|
171
171
|
PREFIX = "prefix"
|
|
172
172
|
IPADDRESS = "ipaddress"
|
|
173
|
-
|
|
173
|
+
PARTNUMBERS = "part_number"
|
|
174
174
|
|
|
175
175
|
CHOICES = (
|
|
176
176
|
(SITE, "Site", "cyan"),
|
|
@@ -182,7 +182,7 @@ class IPFabricTransformMapSourceModelChoices(ChoiceSet):
|
|
|
182
182
|
(VRF, "VRF", "gray"),
|
|
183
183
|
(PREFIX, "Prefix", "gray"),
|
|
184
184
|
(IPADDRESS, "IP Address", "gray"),
|
|
185
|
-
|
|
185
|
+
(PARTNUMBERS, "Part Number", "gray"),
|
|
186
186
|
)
|
|
187
187
|
|
|
188
188
|
|
ipfabric_netbox/forms.py
CHANGED
|
@@ -7,8 +7,10 @@ from django.contrib.contenttypes.models import ContentType
|
|
|
7
7
|
from django.core.exceptions import ValidationError
|
|
8
8
|
from django.utils import timezone
|
|
9
9
|
from django.utils.translation import gettext_lazy as _
|
|
10
|
+
from netbox.forms import NetBoxModelBulkEditForm
|
|
10
11
|
from netbox.forms import NetBoxModelFilterSetForm
|
|
11
12
|
from netbox.forms import NetBoxModelForm
|
|
13
|
+
from netbox.forms import NetBoxModelImportForm
|
|
12
14
|
from netbox.forms.mixins import SavedFiltersMixin
|
|
13
15
|
from utilities.datetime import local_now
|
|
14
16
|
from utilities.forms import add_blank_choice
|
|
@@ -16,21 +18,28 @@ from utilities.forms import ConfirmationForm
|
|
|
16
18
|
from utilities.forms import FilterForm
|
|
17
19
|
from utilities.forms import get_field_value
|
|
18
20
|
from utilities.forms.fields import CommentField
|
|
21
|
+
from utilities.forms.fields import CSVChoiceField
|
|
22
|
+
from utilities.forms.fields import CSVContentTypeField
|
|
23
|
+
from utilities.forms.fields import CSVModelChoiceField
|
|
19
24
|
from utilities.forms.fields import DynamicModelChoiceField
|
|
20
25
|
from utilities.forms.fields import DynamicModelMultipleChoiceField
|
|
21
26
|
from utilities.forms.rendering import FieldSet
|
|
22
27
|
from utilities.forms.widgets import APISelectMultiple
|
|
28
|
+
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
|
23
29
|
from utilities.forms.widgets import DateTimePicker
|
|
24
30
|
from utilities.forms.widgets import HTMXSelect
|
|
25
31
|
from utilities.forms.widgets import NumberWithOptions
|
|
26
32
|
|
|
27
33
|
from .choices import IPFabricSnapshotStatusModelChoices
|
|
34
|
+
from .choices import IPFabricSourceTypeChoices
|
|
35
|
+
from .choices import IPFabricTransformMapSourceModelChoices
|
|
28
36
|
from .choices import required_transform_map_contenttypes
|
|
29
37
|
from .choices import transform_field_source_columns
|
|
30
38
|
from .models import IPFabricIngestion
|
|
31
39
|
from .models import IPFabricRelationshipField
|
|
32
40
|
from .models import IPFabricSnapshot
|
|
33
41
|
from .models import IPFabricSource
|
|
42
|
+
from .models import IPFabricSupportedSyncModels
|
|
34
43
|
from .models import IPFabricSync
|
|
35
44
|
from .models import IPFabricTransformField
|
|
36
45
|
from .models import IPFabricTransformMap
|
|
@@ -269,6 +278,20 @@ class IPFabricTransformMapGroupForm(NetBoxModelForm):
|
|
|
269
278
|
fields = ("name", "description")
|
|
270
279
|
|
|
271
280
|
|
|
281
|
+
class IPFabricTransformMapGroupBulkEditForm(NetBoxModelBulkEditForm):
|
|
282
|
+
description = forms.CharField(
|
|
283
|
+
label=_("Description"), max_length=200, required=False
|
|
284
|
+
)
|
|
285
|
+
model = IPFabricTransformMapGroup
|
|
286
|
+
fields = ("description",)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class IPFabricTransformMapGroupBulkImportForm(NetBoxModelImportForm):
|
|
290
|
+
class Meta:
|
|
291
|
+
model = IPFabricTransformMapGroup
|
|
292
|
+
fields = ("name", "description")
|
|
293
|
+
|
|
294
|
+
|
|
272
295
|
class IPFabricTransformMapForm(NetBoxModelForm):
|
|
273
296
|
class Meta:
|
|
274
297
|
model = IPFabricTransformMap
|
|
@@ -278,6 +301,44 @@ class IPFabricTransformMapForm(NetBoxModelForm):
|
|
|
278
301
|
}
|
|
279
302
|
|
|
280
303
|
|
|
304
|
+
class IPFabricTransformMapBulkEditForm(NetBoxModelBulkEditForm):
|
|
305
|
+
group = forms.ModelChoiceField(
|
|
306
|
+
queryset=IPFabricTransformMapGroup.objects.all(),
|
|
307
|
+
required=False,
|
|
308
|
+
label="Target Group",
|
|
309
|
+
)
|
|
310
|
+
model = IPFabricTransformMap
|
|
311
|
+
fields = ("group",)
|
|
312
|
+
nullable_fields = ("group",)
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class IPFabricTransformMapBulkImportForm(NetBoxModelImportForm):
|
|
316
|
+
source_model = CSVChoiceField(
|
|
317
|
+
label=_("Source model"),
|
|
318
|
+
choices=IPFabricTransformMapSourceModelChoices,
|
|
319
|
+
help_text=_("Models available in IP Fabric to source data from"),
|
|
320
|
+
)
|
|
321
|
+
target_model = CSVContentTypeField(
|
|
322
|
+
queryset=ContentType.objects.filter(IPFabricSupportedSyncModels),
|
|
323
|
+
required=True,
|
|
324
|
+
label=_("Target model"),
|
|
325
|
+
help_text=_(
|
|
326
|
+
"Target model to apply this transform map to (use format 'app_label.model', e.g., 'dcim.device')"
|
|
327
|
+
),
|
|
328
|
+
)
|
|
329
|
+
group = CSVModelChoiceField(
|
|
330
|
+
label=_("Group"),
|
|
331
|
+
queryset=IPFabricTransformMapGroup.objects.all(),
|
|
332
|
+
required=False,
|
|
333
|
+
to_field_name="name",
|
|
334
|
+
help_text=_("Name of assigned transform map group"),
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
class Meta:
|
|
338
|
+
model = IPFabricTransformMap
|
|
339
|
+
fields = ("name", "source_model", "target_model", "group")
|
|
340
|
+
|
|
341
|
+
|
|
281
342
|
class IPFabricTransformMapCloneForm(forms.Form):
|
|
282
343
|
name = forms.CharField(
|
|
283
344
|
required=True, label="Name", help_text="Name for the cloned transform map."
|
|
@@ -439,6 +500,23 @@ class IPFabricSourceForm(NetBoxModelForm):
|
|
|
439
500
|
return instance
|
|
440
501
|
|
|
441
502
|
|
|
503
|
+
class IPFabricSourceBulkEditForm(NetBoxModelBulkEditForm):
|
|
504
|
+
comments = CommentField()
|
|
505
|
+
type = forms.ChoiceField(
|
|
506
|
+
choices=add_blank_choice(IPFabricSourceTypeChoices),
|
|
507
|
+
required=False,
|
|
508
|
+
initial="",
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
model = IPFabricSource
|
|
512
|
+
fields = (
|
|
513
|
+
"type",
|
|
514
|
+
"url",
|
|
515
|
+
"description",
|
|
516
|
+
"comments",
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
|
|
442
520
|
class OrderedModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
|
443
521
|
"""A ModelMultipleChoiceField that preserves the order of the selected items."""
|
|
444
522
|
|
|
@@ -731,6 +809,65 @@ class IPFabricSyncForm(NetBoxModelForm):
|
|
|
731
809
|
return object
|
|
732
810
|
|
|
733
811
|
|
|
812
|
+
class IPFabricSyncBulkEditForm(NetBoxModelBulkEditForm):
|
|
813
|
+
source = forms.ModelChoiceField(
|
|
814
|
+
queryset=IPFabricSource.objects.all(),
|
|
815
|
+
required=False,
|
|
816
|
+
label=_("IP Fabric Source"),
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
snapshot_data = DynamicModelChoiceField(
|
|
820
|
+
queryset=IPFabricSnapshot.objects.filter(status="loaded"),
|
|
821
|
+
required=False,
|
|
822
|
+
label=_("Snapshot"),
|
|
823
|
+
query_params={
|
|
824
|
+
"source_id": "$source",
|
|
825
|
+
"status": "loaded",
|
|
826
|
+
},
|
|
827
|
+
)
|
|
828
|
+
|
|
829
|
+
update_custom_fields = forms.NullBooleanField(
|
|
830
|
+
required=False,
|
|
831
|
+
label=_("Custom Fields Updating"),
|
|
832
|
+
help_text=_("Update object custom fields where applicable."),
|
|
833
|
+
widget=BulkEditNullBooleanSelect,
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
scheduled = forms.DateTimeField(
|
|
837
|
+
required=False,
|
|
838
|
+
widget=DateTimePicker(),
|
|
839
|
+
label=_("Schedule at"),
|
|
840
|
+
help_text=_("Schedule execution of sync to a set time"),
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
interval = forms.IntegerField(
|
|
844
|
+
required=False,
|
|
845
|
+
min_value=1,
|
|
846
|
+
label=_("Recurs every"),
|
|
847
|
+
widget=NumberWithOptions(options=JobIntervalChoices),
|
|
848
|
+
help_text=_("Interval at which this sync is re-run (in minutes)"),
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
auto_merge = forms.NullBooleanField(
|
|
852
|
+
required=False,
|
|
853
|
+
label=_("Auto Merge"),
|
|
854
|
+
help_text=_("Automatically merge staged changes into NetBox"),
|
|
855
|
+
widget=BulkEditNullBooleanSelect,
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
model = IPFabricSync
|
|
859
|
+
fields = (
|
|
860
|
+
"name",
|
|
861
|
+
"source",
|
|
862
|
+
"snapshot_data",
|
|
863
|
+
"auto_merge",
|
|
864
|
+
"update_custom_fields",
|
|
865
|
+
"tags",
|
|
866
|
+
"scheduled",
|
|
867
|
+
"interval",
|
|
868
|
+
)
|
|
869
|
+
|
|
870
|
+
|
|
734
871
|
tableChoices = [
|
|
735
872
|
("eol_details", "Inventory - EOL_DETAILS"),
|
|
736
873
|
("fans", "Inventory - FANS"),
|
ipfabric_netbox/models.py
CHANGED
|
@@ -167,7 +167,7 @@ class IPFabricTransformMap(NetBoxModel):
|
|
|
167
167
|
qs = qs.exclude(pk=self.pk)
|
|
168
168
|
if qs.exists():
|
|
169
169
|
err_msg = _(
|
|
170
|
-
"A transform map with
|
|
170
|
+
f"A transform map with group '{self.group}' and target model '{self.target_model}' already exists."
|
|
171
171
|
)
|
|
172
172
|
raise ValidationError(
|
|
173
173
|
{
|
ipfabric_netbox/tables.py
CHANGED
|
@@ -45,6 +45,7 @@ DATA_BUTTON = """
|
|
|
45
45
|
|
|
46
46
|
class IPFabricRelationshipFieldTable(NetBoxTable):
|
|
47
47
|
actions = columns.ActionsColumn(actions=("edit", "delete"))
|
|
48
|
+
source_model = columns.ContentTypeColumn(verbose_name=_("Source Model"))
|
|
48
49
|
|
|
49
50
|
class Meta(NetBoxTable.Meta):
|
|
50
51
|
model = IPFabricRelationshipField
|
|
@@ -79,6 +80,7 @@ class IPFabricTransformMapGroupTable(NetBoxTable):
|
|
|
79
80
|
class IPFabricTransformMapTable(NetBoxTable):
|
|
80
81
|
name = tables.Column(linkify=True)
|
|
81
82
|
group = tables.Column(linkify=True)
|
|
83
|
+
target_model = columns.ContentTypeColumn(verbose_name=_("Target Model"))
|
|
82
84
|
|
|
83
85
|
class Meta(NetBoxTable.Meta):
|
|
84
86
|
model = IPFabricTransformMap
|