ipfabric_netbox 3.2.2__py3-none-any.whl → 3.2.4__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.

@@ -5,7 +5,7 @@ class NetboxIPFabricConfig(PluginConfig):
5
5
  name = "ipfabric_netbox"
6
6
  verbose_name = "NetBox IP Fabric SoT Plugin"
7
7
  description = "Sync IP Fabric into NetBox"
8
- version = "3.2.2"
8
+ version = "3.2.4"
9
9
  base_url = "ipfabric"
10
10
  min_version = "4.2.4"
11
11
 
@@ -10,7 +10,7 @@ if TYPE_CHECKING:
10
10
 
11
11
 
12
12
  items_to_change = {
13
- ("ip_address", "ipam", "ipaddress"): {"fields": [], "relationships": ["vrf"]},
13
+ ("ipaddress", "ipam", "ipaddress"): {"fields": [], "relationships": ["vrf"]},
14
14
  ("device", "dcim", "platform"): {"fields": [], "relationships": ["manufacturer"]},
15
15
  ("device", "dcim", "device"): {
16
16
  "fields": [],
@@ -43,37 +43,46 @@ def add_templates(apps: "apps", schema_editor: "BaseDatabaseSchemaEditor"):
43
43
  if transform_map_id not in items_to_change:
44
44
  continue
45
45
  source_model, app_label, target_model = transform_map_id
46
- transform_map = apps.get_model(
46
+ transform_map, _ = apps.get_model(
47
47
  "ipfabric_netbox", "IPFabricTransformMap"
48
- ).objects.get(
48
+ ).objects.get_or_create(
49
49
  source_model=source_model,
50
50
  target_model=apps.get_model("contenttypes", "ContentType").objects.get(
51
51
  app_label=app_label,
52
52
  model=target_model,
53
53
  ),
54
+ defaults={"name": item["data"]["name"]},
54
55
  )
55
56
 
56
57
  change_data = items_to_change[transform_map_id]
57
58
 
58
59
  for field_map in item["field_maps"]:
59
- if field_map["target_field"] not in change_data["fields"]:
60
+ f_target_field = field_map.pop("target_field", None)
61
+ if f_target_field not in change_data["fields"]:
60
62
  continue
61
- field = apps.get_model(
63
+ field, _ = apps.get_model(
62
64
  "ipfabric_netbox", "IPFabricTransformField"
63
- ).objects.get(
64
- target_field=field_map["target_field"], transform_map=transform_map
65
+ ).objects.get_or_create(
66
+ target_field=f_target_field,
67
+ transform_map=transform_map,
68
+ defaults=field_map,
65
69
  )
66
70
  field.template = field_map["template"]
67
71
  field.save()
68
72
 
69
73
  for relationship_map in item["relationship_maps"]:
70
- if relationship_map["target_field"] not in change_data["relationships"]:
74
+ rel_target_field = relationship_map.pop("target_field", None)
75
+ if rel_target_field not in change_data["relationships"]:
71
76
  continue
72
- relationship = apps.get_model(
77
+ relationship_map["source_model"] = apps.get_model(
78
+ "contenttypes", "ContentType"
79
+ ).objects.get(**relationship_map.pop("source_model"))
80
+ relationship, _ = apps.get_model(
73
81
  "ipfabric_netbox", "IPFabricRelationshipField"
74
- ).objects.get(
75
- target_field=relationship_map["target_field"],
82
+ ).objects.get_or_create(
83
+ target_field=rel_target_field,
76
84
  transform_map=transform_map,
85
+ defaults=relationship_map,
77
86
  )
78
87
  relationship.template = relationship_map["template"]
79
88
  relationship.save()
@@ -334,15 +334,18 @@ class IPFabricSyncRunner(object):
334
334
  snapshot_id=self.settings["snapshot_id"], filters=site_filter
335
335
  )
336
336
 
337
+ inventory_item_filter = {
338
+ "and": [
339
+ {"sn": ["empty", False]},
340
+ {"name": ["empty", False]},
341
+ ]
342
+ }
343
+ if site_filter:
344
+ inventory_item_filter["and"].append(site_filter)
345
+
337
346
  data["inventoryitem"] = self.client.inventory.pn.all(
338
347
  snapshot_id=self.settings["snapshot_id"],
339
- filters={
340
- "and": [
341
- site_filter,
342
- {"sn": ["empty", False]},
343
- {"name": ["empty", False]},
344
- ]
345
- },
348
+ filters=inventory_item_filter,
346
349
  )
347
350
 
348
351
  data["vlan"] = self.client.technology.vlans.site_summary.all(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ipfabric_netbox
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Summary: NetBox plugin to sync IP Fabric data into NetBox
5
5
  License: MIT
6
6
  Keywords: netbox,ipfabric,plugin,sync
@@ -1,4 +1,4 @@
1
- ipfabric_netbox/__init__.py,sha256=Hx79dSbjd4DIMkPCRqBBdEDb9t9MAVvHEk9TZHXAw3c,315
1
+ ipfabric_netbox/__init__.py,sha256=SrkmJ_57W0Je4fMJchMOrcPpCvBL4tNJL7uUbkGEX9w,315
2
2
  ipfabric_netbox/api/__init__.py,sha256=DOkvDAI4BoNgdCiNxfseeExEHyOrK8weG-LvjPRyK8A,101
3
3
  ipfabric_netbox/api/nested_serializers.py,sha256=JwIlFpOHeiMB7F-sC0gx1f6qdNevS8NsXTUEHlVZeRs,2719
4
4
  ipfabric_netbox/api/serializers.py,sha256=bTR3AJ81Q8HZI3iWLPc1tndGqD0erAbAD9hKLI4DTYY,4341
@@ -19,7 +19,7 @@ ipfabric_netbox/migrations/0006_alter_ipfabrictransformmap_target_model.py,sha25
19
19
  ipfabric_netbox/migrations/0007_prepare_custom_fields.py,sha256=ohnNcbQn4CMkbh3XHtvmkctThUdYhN-ywN5xerOSmdE,3898
20
20
  ipfabric_netbox/migrations/0008_prepare_transform_maps.py,sha256=Jwr-P9MQQv9N-Yx_19V4q6lmZpeIkjoUW1gh4s-lDnI,1541
21
21
  ipfabric_netbox/migrations/0009_transformmap_changes_for_netbox_v4_2.py,sha256=rEqa3OC8UpbdiZKOHBqnrjEgZXYxl8UFCDXHRl_Lnhk,9256
22
- ipfabric_netbox/migrations/0010_remove_uuid_from_get_or_create.py,sha256=Sdmyms5sbuuTH0LkF4k4A9JVS00-N41tY11eaqceJSw,3511
22
+ ipfabric_netbox/migrations/0010_remove_uuid_from_get_or_create.py,sha256=K1oF-B32Ei60XbQdntmjksx1o7rpnpgXCVKFT1dOU1Q,3958
23
23
  ipfabric_netbox/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  ipfabric_netbox/models.py,sha256=krbTm99p7Tj1UHSo0OP5f6RFFdl5RggVG4vp-gkckUU,30725
25
25
  ipfabric_netbox/navigation.py,sha256=2kZs341nAB7G76qnZT6mFxsYo68IPy-bmPMkSLA-Nk0,1735
@@ -55,11 +55,11 @@ ipfabric_netbox/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
55
55
  ipfabric_netbox/tests/test_models.py,sha256=syndh1M3uiZIokn_MJUHfU5jNNMUDPQ5sm8iK-gu1Is,15192
56
56
  ipfabric_netbox/urls.py,sha256=V98K_JxHaJAgDbo-DiMj-5FQIIposLMLJCPw3dtREWU,4430
57
57
  ipfabric_netbox/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- ipfabric_netbox/utilities/ipfutils.py,sha256=c9a_3mQ_GVksYqsCIGJSBnzOVKX1V21Jb9lrU2ASadE,27306
58
+ ipfabric_netbox/utilities/ipfutils.py,sha256=v-9GUfvK0SEeyl7PBHzMqIKl1_wWmy38y_KoBS9K-9o,27409
59
59
  ipfabric_netbox/utilities/logging.py,sha256=GYknjocMN6LQ2873_az3y0RKm29TCXaWviUIIneH-x0,3445
60
60
  ipfabric_netbox/utilities/nbutils.py,sha256=kFBEiJOGvr_49hJWCS2duXojx2-A9kVk0Xp_vj0ohfs,2641
61
61
  ipfabric_netbox/utilities/transform_map.py,sha256=g0elxtwSRJvu0ZRZHyMf4Y9R4wiQ-h2o9Er8gxUQ-Bs,2108
62
62
  ipfabric_netbox/views.py,sha256=K2iKh6i8kv88c7gVh6wW7d8Adcso24ZE8m6gVUiNZSw,28285
63
- ipfabric_netbox-3.2.2.dist-info/METADATA,sha256=sFnkbdFcINTc3j0ZYZdTWqQVPzFdfnPXyGEvVhf5-3Y,4947
64
- ipfabric_netbox-3.2.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
65
- ipfabric_netbox-3.2.2.dist-info/RECORD,,
63
+ ipfabric_netbox-3.2.4.dist-info/METADATA,sha256=6QVcK8HDuEAQ6kFiulmkk_LaIvYcb58gQFrhw3i9sZI,4947
64
+ ipfabric_netbox-3.2.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
65
+ ipfabric_netbox-3.2.4.dist-info/RECORD,,