ipfabric_netbox 4.2.2__py3-none-any.whl → 4.2.2b2__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/api/__init__.py +0 -1
- ipfabric_netbox/api/serializers.py +147 -90
- ipfabric_netbox/api/urls.py +4 -4
- ipfabric_netbox/api/views.py +18 -19
- ipfabric_netbox/choices.py +0 -12
- ipfabric_netbox/filtersets.py +67 -4
- ipfabric_netbox/forms.py +99 -140
- ipfabric_netbox/graphql/__init__.py +23 -0
- ipfabric_netbox/graphql/enums.py +35 -0
- ipfabric_netbox/graphql/filters.py +317 -0
- ipfabric_netbox/graphql/schema.py +101 -0
- ipfabric_netbox/graphql/types.py +216 -0
- ipfabric_netbox/migrations/0016_tags_and_changelog_for_snapshots.py +31 -0
- ipfabric_netbox/migrations/0017_ipfabricsync_update_custom_fields.py +17 -0
- ipfabric_netbox/migrations/0018_remove_type_field.py +17 -0
- ipfabric_netbox/models.py +10 -10
- ipfabric_netbox/tables.py +30 -9
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricsource.html +1 -1
- ipfabric_netbox/tests/api/__init__.py +0 -0
- ipfabric_netbox/tests/api/test_api.py +879 -0
- ipfabric_netbox/tests/test_forms.py +1440 -0
- ipfabric_netbox/tests/test_models.py +47 -11
- ipfabric_netbox/utilities/ipfutils.py +43 -23
- ipfabric_netbox/views.py +6 -8
- {ipfabric_netbox-4.2.2.dist-info → ipfabric_netbox-4.2.2b2.dist-info}/METADATA +8 -7
- {ipfabric_netbox-4.2.2.dist-info → ipfabric_netbox-4.2.2b2.dist-info}/RECORD +28 -19
- {ipfabric_netbox-4.2.2.dist-info → ipfabric_netbox-4.2.2b2.dist-info}/WHEEL +1 -1
- ipfabric_netbox/api/nested_serializers.py +0 -78
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricsync_list.html +0 -71
ipfabric_netbox/models.py
CHANGED
|
@@ -44,7 +44,6 @@ from utilities.request import NetBoxFakeRequest
|
|
|
44
44
|
from .choices import IPFabricRawDataTypeChoices
|
|
45
45
|
from .choices import IPFabricSnapshotStatusModelChoices
|
|
46
46
|
from .choices import IPFabricSourceTypeChoices
|
|
47
|
-
from .choices import IPFabricSyncTypeChoices
|
|
48
47
|
from .choices import IPFabricTransformMapSourceModelChoices
|
|
49
48
|
from .choices import required_transform_map_contenttypes
|
|
50
49
|
from .signals import clear_other_primary_ip
|
|
@@ -545,9 +544,7 @@ class IPFabricSource(IPFabricClient, JobsMixin, PrimaryModel):
|
|
|
545
544
|
# post_sync.send(sender=self.__class__, instance=self)
|
|
546
545
|
|
|
547
546
|
|
|
548
|
-
class IPFabricSnapshot(
|
|
549
|
-
created = models.DateTimeField(auto_now_add=True)
|
|
550
|
-
last_updated = models.DateTimeField(editable=False)
|
|
547
|
+
class IPFabricSnapshot(TagsMixin, ChangeLoggedModel):
|
|
551
548
|
source = models.ForeignKey(
|
|
552
549
|
to=IPFabricSource,
|
|
553
550
|
on_delete=models.CASCADE,
|
|
@@ -600,11 +597,6 @@ class IPFabricSync(IPFabricClient, JobsMixin, TagsMixin, ChangeLoggedModel):
|
|
|
600
597
|
on_delete=models.CASCADE,
|
|
601
598
|
related_name="snapshots",
|
|
602
599
|
)
|
|
603
|
-
type = models.CharField(
|
|
604
|
-
max_length=50,
|
|
605
|
-
choices=IPFabricSyncTypeChoices,
|
|
606
|
-
default=IPFabricSyncTypeChoices.DCIM,
|
|
607
|
-
)
|
|
608
600
|
status = models.CharField(
|
|
609
601
|
max_length=50,
|
|
610
602
|
choices=DataSourceStatusChoices,
|
|
@@ -613,6 +605,7 @@ class IPFabricSync(IPFabricClient, JobsMixin, TagsMixin, ChangeLoggedModel):
|
|
|
613
605
|
)
|
|
614
606
|
parameters = models.JSONField(blank=True, null=True)
|
|
615
607
|
auto_merge = models.BooleanField(default=False)
|
|
608
|
+
update_custom_fields = models.BooleanField(default=True)
|
|
616
609
|
last_synced = models.DateTimeField(blank=True, null=True, editable=False)
|
|
617
610
|
scheduled = models.DateTimeField(null=True, blank=True)
|
|
618
611
|
interval = models.PositiveIntegerField(
|
|
@@ -668,6 +661,10 @@ class IPFabricSync(IPFabricClient, JobsMixin, TagsMixin, ChangeLoggedModel):
|
|
|
668
661
|
else:
|
|
669
662
|
return False
|
|
670
663
|
|
|
664
|
+
@property
|
|
665
|
+
def last_ingestion(self):
|
|
666
|
+
return self.ipfabricingestion_set.last()
|
|
667
|
+
|
|
671
668
|
@staticmethod
|
|
672
669
|
def get_transform_maps(group_ids=None):
|
|
673
670
|
"""
|
|
@@ -889,7 +886,10 @@ class IPFabricIngestion(JobsMixin, models.Model):
|
|
|
889
886
|
def name(self):
|
|
890
887
|
if self.branch:
|
|
891
888
|
return self.branch.name
|
|
892
|
-
|
|
889
|
+
try:
|
|
890
|
+
return f"{self.sync.name} (Ingestion {self.pk})"
|
|
891
|
+
except IPFabricIngestion.sync.RelatedObjectDoesNotExist:
|
|
892
|
+
return f"Ingestion {self.pk} (No Sync)"
|
|
893
893
|
|
|
894
894
|
def get_absolute_url(self):
|
|
895
895
|
return reverse("plugins:ipfabric_netbox:ipfabricingestion", args=[self.pk])
|
ipfabric_netbox/tables.py
CHANGED
|
@@ -142,20 +142,41 @@ class IPFabricSourceTable(NetBoxTable):
|
|
|
142
142
|
default_columns = ("pk", "name", "status", "description", "snapshot_count")
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
class
|
|
146
|
-
|
|
145
|
+
class IPFabricSyncTable(NetBoxTable):
|
|
146
|
+
name = tables.Column(linkify=True)
|
|
147
147
|
status = columns.ChoiceFieldColumn()
|
|
148
148
|
snapshot_name = tables.Column(
|
|
149
|
-
verbose_name="Snapshot Name",
|
|
149
|
+
verbose_name="Snapshot Name",
|
|
150
|
+
accessor="snapshot_data",
|
|
151
|
+
linkify=True,
|
|
152
|
+
)
|
|
153
|
+
last_ingestion = tables.Column(
|
|
154
|
+
accessor="last_ingestion",
|
|
155
|
+
verbose_name="Last Ingestion",
|
|
156
|
+
linkify=True,
|
|
150
157
|
)
|
|
151
158
|
|
|
152
|
-
def
|
|
153
|
-
return value
|
|
159
|
+
def render_last_ingestion(self, value: IPFabricIngestion):
|
|
160
|
+
return getattr(value, "name", "---") if value else "---"
|
|
161
|
+
|
|
162
|
+
def render_snapshot_name(self, value: IPFabricSnapshot):
|
|
163
|
+
return getattr(value, "name", "---") if value else "---"
|
|
154
164
|
|
|
155
165
|
class Meta(NetBoxTable.Meta):
|
|
156
166
|
model = IPFabricSync
|
|
157
|
-
fields = (
|
|
158
|
-
|
|
167
|
+
fields = (
|
|
168
|
+
"auto_merge",
|
|
169
|
+
"id",
|
|
170
|
+
"interval",
|
|
171
|
+
"last_synced",
|
|
172
|
+
"last_ingestion",
|
|
173
|
+
"name",
|
|
174
|
+
"scheduled",
|
|
175
|
+
"status",
|
|
176
|
+
"snapshot_name",
|
|
177
|
+
"user",
|
|
178
|
+
)
|
|
179
|
+
default_columns = ("name", "status", "last_ingestion", "snapshot_name")
|
|
159
180
|
|
|
160
181
|
|
|
161
182
|
class IPFabricIngestionChangesTable(NetBoxTable):
|
|
@@ -241,5 +262,5 @@ class IPFabricDataTable(NetBoxTable):
|
|
|
241
262
|
|
|
242
263
|
class Meta(NetBoxTable.Meta):
|
|
243
264
|
model = IPFabricData
|
|
244
|
-
fields = ("snapshot_data", "
|
|
245
|
-
default_columns = ("snapshot_data", "
|
|
265
|
+
fields = ("snapshot_data", "JSON")
|
|
266
|
+
default_columns = ("snapshot_data", "JSON")
|
|
File without changes
|