ipfabric_netbox 3.1.3__py3-none-any.whl → 3.2.1__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 +2 -31
- ipfabric_netbox/data/transform_map.json +625 -0
- ipfabric_netbox/exceptions.py +24 -0
- ipfabric_netbox/forms.py +4 -10
- ipfabric_netbox/migrations/0007_prepare_custom_fields.py +102 -0
- ipfabric_netbox/migrations/0008_prepare_transform_maps.py +42 -0
- ipfabric_netbox/migrations/0009_transformmap_changes_for_netbox_v4_2.py +224 -0
- ipfabric_netbox/migrations/0010_remove_uuid_from_get_or_create.py +95 -0
- ipfabric_netbox/models.py +67 -63
- ipfabric_netbox/signals.py +27 -66
- ipfabric_netbox/tables.py +4 -0
- ipfabric_netbox/tests/test_models.py +26 -975
- ipfabric_netbox/utilities/ipfutils.py +327 -200
- ipfabric_netbox/utilities/logging.py +12 -7
- ipfabric_netbox/utilities/nbutils.py +0 -26
- ipfabric_netbox/utilities/transform_map.py +37 -15
- ipfabric_netbox/views.py +3 -9
- {ipfabric_netbox-3.1.3.dist-info → ipfabric_netbox-3.2.1.dist-info}/METADATA +19 -11
- {ipfabric_netbox-3.1.3.dist-info → ipfabric_netbox-3.2.1.dist-info}/RECORD +20 -14
- {ipfabric_netbox-3.1.3.dist-info → ipfabric_netbox-3.2.1.dist-info}/WHEEL +1 -1
|
@@ -53,32 +53,6 @@ def order_devices(devices, members):
|
|
|
53
53
|
return devices
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def order_vrf(vrfs):
|
|
57
|
-
vrf_dict = {}
|
|
58
|
-
|
|
59
|
-
for vrf in vrfs:
|
|
60
|
-
sn = vrf["sn"]
|
|
61
|
-
if sn in vrf_dict:
|
|
62
|
-
vrf_dict[sn].append(vrf)
|
|
63
|
-
else:
|
|
64
|
-
vrf_dict[sn] = [vrf]
|
|
65
|
-
|
|
66
|
-
return vrf_dict
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def order_pn(part_numbers):
|
|
70
|
-
pn_dict = {}
|
|
71
|
-
|
|
72
|
-
for pn in part_numbers:
|
|
73
|
-
device_sn = pn["deviceSn"]
|
|
74
|
-
if device_sn in pn_dict:
|
|
75
|
-
pn_dict[device_sn].append(pn)
|
|
76
|
-
else:
|
|
77
|
-
pn_dict[device_sn] = [pn]
|
|
78
|
-
|
|
79
|
-
return pn_dict
|
|
80
|
-
|
|
81
|
-
|
|
82
56
|
def create_inventory_items(device: Device, parts: list, manufacturer: Manufacturer):
|
|
83
57
|
for part in parts:
|
|
84
58
|
name = part.get("name", "")
|
|
@@ -1,35 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import importlib.resources
|
|
2
|
+
import json
|
|
2
3
|
|
|
3
|
-
from
|
|
4
|
-
from ipfabric_netbox.models import IPFabricTransformField
|
|
5
|
-
from ipfabric_netbox.models import IPFabricTransformMap
|
|
4
|
+
from django.apps import apps
|
|
6
5
|
|
|
6
|
+
# These functions are used in the migration file to prepare the transform maps
|
|
7
|
+
# Because of this we have to use historical models
|
|
8
|
+
# see https://docs.djangoproject.com/en/5.1/topics/migrations/#historical-models
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
|
|
11
|
+
def build_fields(data):
|
|
12
|
+
ContentType = apps.get_model("contenttypes", "ContentType")
|
|
9
13
|
if "target_model" in data:
|
|
10
|
-
ct = ContentType.objects.
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
ct = ContentType.objects.get_for_model(
|
|
15
|
+
apps.get_model(
|
|
16
|
+
data["target_model"]["app_label"],
|
|
17
|
+
data["target_model"]["model"],
|
|
18
|
+
)
|
|
13
19
|
)
|
|
14
20
|
data["target_model"] = ct
|
|
15
21
|
elif "source_model" in data:
|
|
16
|
-
ct = ContentType.objects.
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
ct = ContentType.objects.get_for_model(
|
|
23
|
+
apps.get_model(
|
|
24
|
+
data["source_model"]["app_label"],
|
|
25
|
+
data["source_model"]["model"],
|
|
26
|
+
)
|
|
19
27
|
)
|
|
20
28
|
data["source_model"] = ct
|
|
21
29
|
return data
|
|
22
30
|
|
|
23
31
|
|
|
24
|
-
def
|
|
32
|
+
def build_transform_maps(data):
|
|
33
|
+
IPFabricTransformMap = apps.get_model("ipfabric_netbox", "IPFabricTransformMap")
|
|
34
|
+
IPFabricTransformField = apps.get_model("ipfabric_netbox", "IPFabricTransformField")
|
|
35
|
+
IPFabricRelationshipField = apps.get_model(
|
|
36
|
+
"ipfabric_netbox", "IPFabricRelationshipField"
|
|
37
|
+
)
|
|
25
38
|
for tm in data:
|
|
26
|
-
field_data =
|
|
39
|
+
field_data = build_fields(tm["data"])
|
|
27
40
|
tm_obj = IPFabricTransformMap.objects.create(**field_data)
|
|
28
41
|
for fm in tm["field_maps"]:
|
|
29
|
-
field_data =
|
|
42
|
+
field_data = build_fields(fm)
|
|
30
43
|
IPFabricTransformField.objects.create(transform_map=tm_obj, **field_data)
|
|
31
44
|
for rm in tm["relationship_maps"]:
|
|
32
|
-
relationship_data =
|
|
45
|
+
relationship_data = build_fields(rm)
|
|
33
46
|
IPFabricRelationshipField.objects.create(
|
|
34
47
|
transform_map=tm_obj, **relationship_data
|
|
35
48
|
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def get_transform_map() -> dict:
|
|
52
|
+
for data_file in importlib.resources.files("ipfabric_netbox.data").iterdir():
|
|
53
|
+
if data_file.name != "transform_map.json":
|
|
54
|
+
continue
|
|
55
|
+
with open(data_file, "rb") as data_file:
|
|
56
|
+
return json.load(data_file)
|
|
57
|
+
raise FileNotFoundError("'transform_map.json' not found in installed package")
|
ipfabric_netbox/views.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import requests
|
|
2
1
|
from dcim.models import Device
|
|
3
2
|
from dcim.models import Site
|
|
4
3
|
from django.contrib import messages
|
|
@@ -60,7 +59,8 @@ from .tables import IPFabricTransformFieldTable
|
|
|
60
59
|
from .tables import IPFabricTransformMapTable
|
|
61
60
|
from .tables import StagedChangesTable
|
|
62
61
|
from .utilities.ipfutils import IPFabric
|
|
63
|
-
from .utilities.transform_map import
|
|
62
|
+
from .utilities.transform_map import build_transform_maps
|
|
63
|
+
from .utilities.transform_map import get_transform_map
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
# Transform Map Relationship Field
|
|
@@ -140,13 +140,7 @@ class IPFabricTransformMapRestoreView(generic.ObjectListView):
|
|
|
140
140
|
|
|
141
141
|
def post(self, request):
|
|
142
142
|
IPFabricTransformMap.objects.all().delete()
|
|
143
|
-
|
|
144
|
-
data = requests.get(
|
|
145
|
-
"https://gitlab.com/ip-fabric/integrations/ipfabric-netbox/-/raw/main/scripts/transform_map.json", timeout=30
|
|
146
|
-
).json()
|
|
147
|
-
except Exception as e:
|
|
148
|
-
messages.error(request, e)
|
|
149
|
-
BuildTransformMaps(data=data)
|
|
143
|
+
build_transform_maps(data=get_transform_map())
|
|
150
144
|
return redirect("plugins:ipfabric_netbox:ipfabrictransformmap_list")
|
|
151
145
|
|
|
152
146
|
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: ipfabric_netbox
|
|
3
|
-
Version: 3.1
|
|
3
|
+
Version: 3.2.1
|
|
4
4
|
Summary: NetBox plugin to sync IP Fabric data into NetBox
|
|
5
|
-
Home-page: https://gitlab.com/ip-fabric/integrations/ipfabric-netbox-sync
|
|
6
5
|
License: MIT
|
|
7
6
|
Keywords: netbox,ipfabric,plugin,sync
|
|
8
7
|
Author: Solution Architecture
|
|
9
8
|
Author-email: solution.architecture@ipfabric.io
|
|
10
9
|
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Provides-Extra: ipfabric-6-10
|
|
14
|
+
Provides-Extra: ipfabric-6-6
|
|
15
|
+
Provides-Extra: ipfabric-6-7
|
|
16
|
+
Provides-Extra: ipfabric-6-8
|
|
17
|
+
Provides-Extra: ipfabric-6-9
|
|
18
|
+
Provides-Extra: ipfabric-7-0
|
|
19
|
+
Requires-Dist: ipfabric (>=6.10.0,<6.11.0) ; extra != "ipfabric_6_6" and extra != "ipfabric_6_7" and extra != "ipfabric_6_8" and extra != "ipfabric_6_9" and extra == "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
20
|
+
Requires-Dist: ipfabric (>=6.6.0,<6.7.0) ; extra == "ipfabric_6_6" and extra != "ipfabric_6_7" and extra != "ipfabric_6_8" and extra != "ipfabric_6_9" and extra != "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
21
|
+
Requires-Dist: ipfabric (>=6.6.4) ; extra != "ipfabric_6_6" and extra != "ipfabric_6_7" and extra != "ipfabric_6_8" and extra != "ipfabric_6_9" and extra != "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
22
|
+
Requires-Dist: ipfabric (>=6.7.0,<6.8.0) ; extra != "ipfabric_6_6" and extra == "ipfabric_6_7" and extra != "ipfabric_6_8" and extra != "ipfabric_6_9" and extra != "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
23
|
+
Requires-Dist: ipfabric (>=6.8.0,<6.9.0) ; extra != "ipfabric_6_6" and extra != "ipfabric_6_7" and extra == "ipfabric_6_8" and extra != "ipfabric_6_9" and extra != "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
24
|
+
Requires-Dist: ipfabric (>=6.9.0,<6.10.0) ; extra != "ipfabric_6_6" and extra != "ipfabric_6_7" and extra != "ipfabric_6_8" and extra == "ipfabric_6_9" and extra != "ipfabric_6_10" and extra != "ipfabric_7_0"
|
|
25
|
+
Requires-Dist: ipfabric (>=7.0.0,<7.1.0) ; extra != "ipfabric_6_6" and extra != "ipfabric_6_7" and extra != "ipfabric_6_8" and extra != "ipfabric_6_9" and extra != "ipfabric_6_10" and extra == "ipfabric_7_0"
|
|
19
26
|
Requires-Dist: netutils
|
|
20
27
|
Project-URL: Bug Tracker, https://gitlab.com/ip-fabric/integrations/ipfabric-netbox-sync/-/issues
|
|
21
|
-
Project-URL: Repository, https://gitlab.com/ip-fabric/integrations/ipfabric-netbox-sync
|
|
22
28
|
Description-Content-Type: text/markdown
|
|
23
29
|
|
|
24
30
|
# IP Fabric Netbox Plugin
|
|
@@ -51,9 +57,10 @@ The plugin uses IP Fabric collect network data utilizing the [IP Fabric Python S
|
|
|
51
57
|
- Diff Visualization
|
|
52
58
|
|
|
53
59
|
## NetBox Compatibility
|
|
60
|
+
These are the minimum NetBox versions for corresponding plugin version. Following minor versions should work too, but they are not tested.
|
|
54
61
|
|
|
55
62
|
| Netbox Version | Plugin Version |
|
|
56
|
-
|
|
63
|
+
|----------------|----------------|
|
|
57
64
|
| 3.4 | <=1.0.11 |
|
|
58
65
|
| 3.5 | <=1.0.11 |
|
|
59
66
|
| 3.6 | <=1.0.11 |
|
|
@@ -62,6 +69,7 @@ The plugin uses IP Fabric collect network data utilizing the [IP Fabric Python S
|
|
|
62
69
|
| 4.0.1 | >=3.0.1 |
|
|
63
70
|
| 4.1.0 | >=3.1.0 |
|
|
64
71
|
| 4.1.5 | >=3.1.1 |
|
|
72
|
+
| 4.2.0 | >=3.2.0 |
|
|
65
73
|
|
|
66
74
|
## Screenshots
|
|
67
75
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
ipfabric_netbox/__init__.py,sha256=
|
|
1
|
+
ipfabric_netbox/__init__.py,sha256=TThmLsadpapoAIhc1dEy0uFcb35WOikGw_rErqh7yT0,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
|
|
5
5
|
ipfabric_netbox/api/urls.py,sha256=BSQ5nqYSx0r-wnbdKGDAb5XH7BBy_0ngV_Q7vDgjMIE,948
|
|
6
6
|
ipfabric_netbox/api/views.py,sha256=X02GwpDlq25_3KlxYTWyd4PnT1RCtfp7uN0zZ5Etjp8,4429
|
|
7
7
|
ipfabric_netbox/choices.py,sha256=GqcnLqsFR4gnhWEwkvQbPxXYNi5SwNoIQz-J15LTMc4,4848
|
|
8
|
+
ipfabric_netbox/data/transform_map.json,sha256=Xb5x8dmBPDmrVUezjvkI3Wq60TgdHXocaur3W2xZ_k8,21951
|
|
9
|
+
ipfabric_netbox/exceptions.py,sha256=8XmyAqouF8ghYCpJrgSwh1gUVedBI3UPWvwJ8Aai12g,744
|
|
8
10
|
ipfabric_netbox/filtersets.py,sha256=P_2VCL892pLplPnsxul27bgGgMpHaZtgn9Vg0UsWErE,3877
|
|
9
|
-
ipfabric_netbox/forms.py,sha256=
|
|
11
|
+
ipfabric_netbox/forms.py,sha256=qtl6htAmyAIwwUoucHsqmXJME2M2SzcA69_BBiuCqs4,42942
|
|
10
12
|
ipfabric_netbox/jobs.py,sha256=jfWWNA42KMyzc-EGit6LJIe-SNob4-4IQRfadQF_GRE,2862
|
|
11
13
|
ipfabric_netbox/migrations/0001_initial.py,sha256=nka6_HJK4Q8BlmQblDntuNzVKLR484SsC6wGSbOQgI4,13813
|
|
12
14
|
ipfabric_netbox/migrations/0002_ipfabricsnapshot_status.py,sha256=xQpouHjOutyj6riN2B592njzSvz_icpkUbo5W7nWLYw,431
|
|
@@ -14,11 +16,15 @@ ipfabric_netbox/migrations/0003_ipfabricsource_type_and_more.py,sha256=XUM_ZecLl
|
|
|
14
16
|
ipfabric_netbox/migrations/0004_ipfabricsync_auto_merge.py,sha256=hlwHGKD7q3w1a1N04yIS39f6nsL_9TJCWEJlvwCdpPA,435
|
|
15
17
|
ipfabric_netbox/migrations/0005_alter_ipfabricrelationshipfield_source_model_and_more.py,sha256=egiUtdu1zHElbcIIN9sUzS93dSCltVXFv0DG9IUp1HY,2802
|
|
16
18
|
ipfabric_netbox/migrations/0006_alter_ipfabrictransformmap_target_model.py,sha256=6MmI-Uz9hmzj3nKqhUKdShjLnE8KNa4qthg0NVHjANc,2163
|
|
19
|
+
ipfabric_netbox/migrations/0007_prepare_custom_fields.py,sha256=ohnNcbQn4CMkbh3XHtvmkctThUdYhN-ywN5xerOSmdE,3898
|
|
20
|
+
ipfabric_netbox/migrations/0008_prepare_transform_maps.py,sha256=Jwr-P9MQQv9N-Yx_19V4q6lmZpeIkjoUW1gh4s-lDnI,1541
|
|
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
|
|
17
23
|
ipfabric_netbox/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
ipfabric_netbox/models.py,sha256=
|
|
24
|
+
ipfabric_netbox/models.py,sha256=krbTm99p7Tj1UHSo0OP5f6RFFdl5RggVG4vp-gkckUU,30725
|
|
19
25
|
ipfabric_netbox/navigation.py,sha256=2kZs341nAB7G76qnZT6mFxsYo68IPy-bmPMkSLA-Nk0,1735
|
|
20
|
-
ipfabric_netbox/signals.py,sha256=
|
|
21
|
-
ipfabric_netbox/tables.py,sha256=
|
|
26
|
+
ipfabric_netbox/signals.py,sha256=AnTxyTlj6iFQVscOlbzSBpplDAkkKYnhsNMP5K0g-ig,991
|
|
27
|
+
ipfabric_netbox/tables.py,sha256=4cZb-_whp132B3EJglRBEkXwkYLUpWzIybkdHfAE9tM,6819
|
|
22
28
|
ipfabric_netbox/template_content.py,sha256=bP2nUf5MM-GUbtQxJ8QoYVNXhrDCrkb8wZnbeqa07EA,315
|
|
23
29
|
ipfabric_netbox/templates/ipfabric_netbox/inc/diff.html,sha256=xOiIrvRIBtqDD65u6xcLo2xdwDKNpAylDmzznaJRGCw,3281
|
|
24
30
|
ipfabric_netbox/templates/ipfabric_netbox/inc/json.html,sha256=qPHUdaHyKM9Y7FqBEnYwcNoyp5GMFaexJFXMRf4AqZQ,569
|
|
@@ -46,14 +52,14 @@ ipfabric_netbox/templates/ipfabric_netbox/partials/sync_last_branch.html,sha256=
|
|
|
46
52
|
ipfabric_netbox/templates/ipfabric_netbox/sync_list.html,sha256=3wfwPUIAfzzIP_pu3gL0L3wH65UX5XFLBW5BW-CZJDc,5587
|
|
47
53
|
ipfabric_netbox/templates/static/ipfabric_netbox/css/rack.css,sha256=z1H-RmmsqF2pGdhn5J64TMFiccy62xZUHHlCRd8fJrQ,118
|
|
48
54
|
ipfabric_netbox/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
|
-
ipfabric_netbox/tests/test_models.py,sha256=
|
|
55
|
+
ipfabric_netbox/tests/test_models.py,sha256=syndh1M3uiZIokn_MJUHfU5jNNMUDPQ5sm8iK-gu1Is,15192
|
|
50
56
|
ipfabric_netbox/urls.py,sha256=V98K_JxHaJAgDbo-DiMj-5FQIIposLMLJCPw3dtREWU,4430
|
|
51
57
|
ipfabric_netbox/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
-
ipfabric_netbox/utilities/ipfutils.py,sha256=
|
|
53
|
-
ipfabric_netbox/utilities/logging.py,sha256=
|
|
54
|
-
ipfabric_netbox/utilities/nbutils.py,sha256=
|
|
55
|
-
ipfabric_netbox/utilities/transform_map.py,sha256=
|
|
56
|
-
ipfabric_netbox/views.py,sha256=
|
|
57
|
-
ipfabric_netbox-3.1.
|
|
58
|
-
ipfabric_netbox-3.1.
|
|
59
|
-
ipfabric_netbox-3.1.
|
|
58
|
+
ipfabric_netbox/utilities/ipfutils.py,sha256=M4YnnUdbUXg2wkOt1a_nsJok_K0ppfZ_fuwcg0wemtc,27187
|
|
59
|
+
ipfabric_netbox/utilities/logging.py,sha256=GYknjocMN6LQ2873_az3y0RKm29TCXaWviUIIneH-x0,3445
|
|
60
|
+
ipfabric_netbox/utilities/nbutils.py,sha256=kFBEiJOGvr_49hJWCS2duXojx2-A9kVk0Xp_vj0ohfs,2641
|
|
61
|
+
ipfabric_netbox/utilities/transform_map.py,sha256=g0elxtwSRJvu0ZRZHyMf4Y9R4wiQ-h2o9Er8gxUQ-Bs,2108
|
|
62
|
+
ipfabric_netbox/views.py,sha256=K2iKh6i8kv88c7gVh6wW7d8Adcso24ZE8m6gVUiNZSw,28285
|
|
63
|
+
ipfabric_netbox-3.2.1.dist-info/METADATA,sha256=qtRU2-RvAyfcsbHlOnaCnBwRbOD61tnRC9GLGqxrLRI,4975
|
|
64
|
+
ipfabric_netbox-3.2.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
65
|
+
ipfabric_netbox-3.2.1.dist-info/RECORD,,
|