ipfabric_netbox 4.2.2b2__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.

@@ -6,7 +6,7 @@ class NetboxIPFabricConfig(PluginConfig):
6
6
  name = "ipfabric_netbox"
7
7
  verbose_name = "NetBox IP Fabric SoT Plugin"
8
8
  description = "Sync IP Fabric into NetBox"
9
- version = "4.2.2b2"
9
+ version = "4.2.2b3"
10
10
  base_url = "ipfabric"
11
11
  min_version = "4.2.4"
12
12
 
ipfabric_netbox/forms.py CHANGED
@@ -263,13 +263,13 @@ class IPFabricTransformFieldForm(NetBoxModelForm):
263
263
  )
264
264
 
265
265
 
266
- class IPFabricTransformMapGroupForm(forms.ModelForm):
266
+ class IPFabricTransformMapGroupForm(NetBoxModelForm):
267
267
  class Meta:
268
268
  model = IPFabricTransformMapGroup
269
269
  fields = ("name", "description")
270
270
 
271
271
 
272
- class IPFabricTransformMapForm(forms.ModelForm):
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 IPFabricSnapshot
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
- for snapshot in IPFabricSnapshot.objects.all():
18
- # `Site.name` is unique in DB, so we can use it to match against IPF snapshots
19
- if site.name in snapshot.sites:
20
- source = snapshot.source
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
- Device does not have a IP Fabric source configured in the custom fields. The source is used to match devices between NetBox and IP Fabric instance.
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 from GitLab and will overwrite any changes made in NetBox.
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 %}