ipfabric_netbox 4.2.2b1__py3-none-any.whl → 4.2.2b3__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/forms.py +9 -9
- ipfabric_netbox/models.py +13 -0
- ipfabric_netbox/template_content.py +8 -5
- ipfabric_netbox/templates/ipfabric_netbox/ipfabric_table.html +1 -1
- ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap_restore.html +1 -1
- ipfabric_netbox/tests/test_views.py +2153 -0
- ipfabric_netbox/urls.py +15 -14
- ipfabric_netbox/views.py +100 -70
- {ipfabric_netbox-4.2.2b1.dist-info → ipfabric_netbox-4.2.2b3.dist-info}/METADATA +1 -1
- {ipfabric_netbox-4.2.2b1.dist-info → ipfabric_netbox-4.2.2b3.dist-info}/RECORD +12 -11
- {ipfabric_netbox-4.2.2b1.dist-info → ipfabric_netbox-4.2.2b3.dist-info}/WHEEL +0 -0
ipfabric_netbox/__init__.py
CHANGED
ipfabric_netbox/forms.py
CHANGED
|
@@ -63,21 +63,21 @@ dcim_parameters = {
|
|
|
63
63
|
required=False, label=_("Virtual Chassis"), initial=True
|
|
64
64
|
),
|
|
65
65
|
"interface": forms.BooleanField(
|
|
66
|
-
required=False, label=_("Interfaces"), initial=
|
|
66
|
+
required=False, label=_("Interfaces"), initial=True
|
|
67
67
|
),
|
|
68
68
|
"macaddress": forms.BooleanField(
|
|
69
|
-
required=False, label=_("MAC Addresses"), initial=
|
|
69
|
+
required=False, label=_("MAC Addresses"), initial=True
|
|
70
70
|
),
|
|
71
71
|
"inventoryitem": forms.BooleanField(
|
|
72
|
-
required=False, label=_("Part Numbers"), initial=
|
|
72
|
+
required=False, label=_("Part Numbers"), initial=True
|
|
73
73
|
),
|
|
74
74
|
}
|
|
75
75
|
ipam_parameters = {
|
|
76
|
-
"vlan": forms.BooleanField(required=False, label=_("VLANs"), initial=
|
|
77
|
-
"vrf": forms.BooleanField(required=False, label=_("VRFs"), initial=
|
|
78
|
-
"prefix": forms.BooleanField(required=False, label=_("Prefixes"), initial=
|
|
76
|
+
"vlan": forms.BooleanField(required=False, label=_("VLANs"), initial=True),
|
|
77
|
+
"vrf": forms.BooleanField(required=False, label=_("VRFs"), initial=True),
|
|
78
|
+
"prefix": forms.BooleanField(required=False, label=_("Prefixes"), initial=True),
|
|
79
79
|
"ipaddress": forms.BooleanField(
|
|
80
|
-
required=False, label=_("IP Addresses"), initial=
|
|
80
|
+
required=False, label=_("IP Addresses"), initial=True
|
|
81
81
|
),
|
|
82
82
|
}
|
|
83
83
|
sync_parameters = {"dcim": dcim_parameters, "ipam": ipam_parameters}
|
|
@@ -263,13 +263,13 @@ class IPFabricTransformFieldForm(NetBoxModelForm):
|
|
|
263
263
|
)
|
|
264
264
|
|
|
265
265
|
|
|
266
|
-
class IPFabricTransformMapGroupForm(
|
|
266
|
+
class IPFabricTransformMapGroupForm(NetBoxModelForm):
|
|
267
267
|
class Meta:
|
|
268
268
|
model = IPFabricTransformMapGroup
|
|
269
269
|
fields = ("name", "description")
|
|
270
270
|
|
|
271
271
|
|
|
272
|
-
class IPFabricTransformMapForm(
|
|
272
|
+
class IPFabricTransformMapForm(NetBoxModelForm):
|
|
273
273
|
class Meta:
|
|
274
274
|
model = IPFabricTransformMap
|
|
275
275
|
fields = ("name", "group", "source_model", "target_model")
|
ipfabric_netbox/models.py
CHANGED
|
@@ -12,6 +12,7 @@ from core.models import Job
|
|
|
12
12
|
from core.models import ObjectType
|
|
13
13
|
from core.signals import pre_sync
|
|
14
14
|
from dcim.models import Device
|
|
15
|
+
from dcim.models import Site
|
|
15
16
|
from dcim.models import VirtualChassis
|
|
16
17
|
from dcim.signals import assign_virtualchassis_master
|
|
17
18
|
from django.apps import apps
|
|
@@ -100,6 +101,7 @@ class IPFabricTransformMapGroup(NetBoxModel):
|
|
|
100
101
|
description = models.TextField(blank=True, null=True)
|
|
101
102
|
|
|
102
103
|
class Meta:
|
|
104
|
+
ordering = ("pk",)
|
|
103
105
|
verbose_name = "IP Fabric Transform Map Group"
|
|
104
106
|
verbose_name_plural = "IP Fabric Transform Map Groups"
|
|
105
107
|
|
|
@@ -136,6 +138,7 @@ class IPFabricTransformMap(NetBoxModel):
|
|
|
136
138
|
)
|
|
137
139
|
|
|
138
140
|
class Meta:
|
|
141
|
+
ordering = ("pk",)
|
|
139
142
|
verbose_name = "IP Fabric Transform Map"
|
|
140
143
|
verbose_name_plural = "IP Fabric Transform Maps"
|
|
141
144
|
|
|
@@ -543,6 +546,13 @@ class IPFabricSource(IPFabricClient, JobsMixin, PrimaryModel):
|
|
|
543
546
|
# Emit the post_sync signal
|
|
544
547
|
# post_sync.send(sender=self.__class__, instance=self)
|
|
545
548
|
|
|
549
|
+
@classmethod
|
|
550
|
+
def get_for_site(cls, site: Site):
|
|
551
|
+
"""Get all snapshots containing the given site."""
|
|
552
|
+
return cls.objects.filter(
|
|
553
|
+
Q(snapshots__data__sites__contains=[site.name])
|
|
554
|
+
).distinct()
|
|
555
|
+
|
|
546
556
|
|
|
547
557
|
class IPFabricSnapshot(TagsMixin, ChangeLoggedModel):
|
|
548
558
|
source = models.ForeignKey(
|
|
@@ -1004,3 +1014,6 @@ class IPFabricData(models.Model):
|
|
|
1004
1014
|
choices=IPFabricRawDataTypeChoices,
|
|
1005
1015
|
)
|
|
1006
1016
|
objects = RestrictedQuerySet.as_manager()
|
|
1017
|
+
|
|
1018
|
+
def get_absolute_url(self):
|
|
1019
|
+
return reverse("plugins:ipfabric_netbox:ipfabricdata_data", args=[self.pk])
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
from dcim.models import Site
|
|
3
4
|
from netbox.plugins import PluginTemplateExtension
|
|
4
5
|
|
|
5
|
-
from ipfabric_netbox.models import
|
|
6
|
+
from ipfabric_netbox.models import IPFabricSource
|
|
6
7
|
|
|
7
8
|
logger = logging.getLogger("ipfabric_netbox.template_content")
|
|
8
9
|
|
|
@@ -14,10 +15,12 @@ class SiteTopologyButtons(PluginTemplateExtension):
|
|
|
14
15
|
try:
|
|
15
16
|
site = self.context.get("object")
|
|
16
17
|
source = None
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if isinstance(site, Site) and (
|
|
19
|
+
source_id := site.custom_field_data.get("ipfabric_source")
|
|
20
|
+
):
|
|
21
|
+
source = IPFabricSource.objects.filter(id=source_id).first()
|
|
22
|
+
# `source_id` saved in CF might be obsolete, so always fall back to search by site
|
|
23
|
+
source = source or IPFabricSource.get_for_site(site).first()
|
|
21
24
|
return self.render(
|
|
22
25
|
"ipfabric_netbox/inc/site_topology_button.html",
|
|
23
26
|
extra_context={"source": source},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<div class="row px-3">
|
|
48
48
|
<div class="card">
|
|
49
49
|
<div class="card-body">
|
|
50
|
-
|
|
50
|
+
Could not find an IP Fabric Source that could have synced this Device. The source is used to match devices between NetBox and IP Fabric instance.
|
|
51
51
|
</div>
|
|
52
52
|
</div>
|
|
53
53
|
</div>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<div class="modal-body">
|
|
10
10
|
<p>
|
|
11
11
|
{% blocktrans trimmed %}
|
|
12
|
-
Are you sure you want to <strong class="text-danger">restore</strong> the Transform Maps? This restores
|
|
12
|
+
Are you sure you want to <strong class="text-danger">restore</strong> the Transform Maps? This restores will overwrite any changes made in NetBox to Transform Maps without a group.
|
|
13
13
|
{% endblocktrans %}
|
|
14
14
|
</p>
|
|
15
15
|
{% if dependent_objects %}
|