ipfabric_netbox 3.1.2__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.

Files changed (59) hide show
  1. ipfabric_netbox/__init__.py +42 -0
  2. ipfabric_netbox/api/__init__.py +2 -0
  3. ipfabric_netbox/api/nested_serializers.py +99 -0
  4. ipfabric_netbox/api/serializers.py +160 -0
  5. ipfabric_netbox/api/urls.py +21 -0
  6. ipfabric_netbox/api/views.py +111 -0
  7. ipfabric_netbox/choices.py +226 -0
  8. ipfabric_netbox/filtersets.py +125 -0
  9. ipfabric_netbox/forms.py +1063 -0
  10. ipfabric_netbox/jobs.py +95 -0
  11. ipfabric_netbox/migrations/0001_initial.py +342 -0
  12. ipfabric_netbox/migrations/0002_ipfabricsnapshot_status.py +17 -0
  13. ipfabric_netbox/migrations/0003_ipfabricsource_type_and_more.py +49 -0
  14. ipfabric_netbox/migrations/0004_ipfabricsync_auto_merge.py +17 -0
  15. ipfabric_netbox/migrations/0005_alter_ipfabricrelationshipfield_source_model_and_more.py +64 -0
  16. ipfabric_netbox/migrations/0006_alter_ipfabrictransformmap_target_model.py +48 -0
  17. ipfabric_netbox/migrations/__init__.py +0 -0
  18. ipfabric_netbox/models.py +874 -0
  19. ipfabric_netbox/navigation.py +62 -0
  20. ipfabric_netbox/signals.py +68 -0
  21. ipfabric_netbox/tables.py +208 -0
  22. ipfabric_netbox/template_content.py +13 -0
  23. ipfabric_netbox/templates/ipfabric_netbox/inc/diff.html +72 -0
  24. ipfabric_netbox/templates/ipfabric_netbox/inc/json.html +20 -0
  25. ipfabric_netbox/templates/ipfabric_netbox/inc/logs_pending.html +6 -0
  26. ipfabric_netbox/templates/ipfabric_netbox/inc/merge_form.html +22 -0
  27. ipfabric_netbox/templates/ipfabric_netbox/inc/site_topology_button.html +70 -0
  28. ipfabric_netbox/templates/ipfabric_netbox/inc/site_topology_modal.html +61 -0
  29. ipfabric_netbox/templates/ipfabric_netbox/inc/snapshotdata.html +60 -0
  30. ipfabric_netbox/templates/ipfabric_netbox/inc/sync_delete.html +19 -0
  31. ipfabric_netbox/templates/ipfabric_netbox/inc/transform_map_field_map.html +11 -0
  32. ipfabric_netbox/templates/ipfabric_netbox/inc/transform_map_relationship_map.html +11 -0
  33. ipfabric_netbox/templates/ipfabric_netbox/ipfabric_table.html +55 -0
  34. ipfabric_netbox/templates/ipfabric_netbox/ipfabricbranch.html +141 -0
  35. ipfabric_netbox/templates/ipfabric_netbox/ipfabricsnapshot.html +105 -0
  36. ipfabric_netbox/templates/ipfabric_netbox/ipfabricsource.html +111 -0
  37. ipfabric_netbox/templates/ipfabric_netbox/ipfabricsync.html +103 -0
  38. ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap.html +41 -0
  39. ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap_list.html +17 -0
  40. ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap_restore.html +59 -0
  41. ipfabric_netbox/templates/ipfabric_netbox/partials/branch_all.html +10 -0
  42. ipfabric_netbox/templates/ipfabric_netbox/partials/branch_progress.html +19 -0
  43. ipfabric_netbox/templates/ipfabric_netbox/partials/branch_status.html +1 -0
  44. ipfabric_netbox/templates/ipfabric_netbox/partials/job_logs.html +53 -0
  45. ipfabric_netbox/templates/ipfabric_netbox/partials/sync_last_branch.html +1 -0
  46. ipfabric_netbox/templates/ipfabric_netbox/sync_list.html +126 -0
  47. ipfabric_netbox/templates/static/ipfabric_netbox/css/rack.css +9 -0
  48. ipfabric_netbox/tests/__init__.py +0 -0
  49. ipfabric_netbox/tests/test_models.py +1340 -0
  50. ipfabric_netbox/urls.py +141 -0
  51. ipfabric_netbox/utilities/__init__.py +0 -0
  52. ipfabric_netbox/utilities/ipfutils.py +591 -0
  53. ipfabric_netbox/utilities/logging.py +93 -0
  54. ipfabric_netbox/utilities/nbutils.py +105 -0
  55. ipfabric_netbox/utilities/transform_map.py +35 -0
  56. ipfabric_netbox/views.py +845 -0
  57. ipfabric_netbox-3.1.2.dist-info/METADATA +88 -0
  58. ipfabric_netbox-3.1.2.dist-info/RECORD +59 -0
  59. ipfabric_netbox-3.1.2.dist-info/WHEEL +4 -0
@@ -0,0 +1,42 @@
1
+ import requests
2
+ from django.db import connection
3
+ from netbox.plugins import PluginConfig
4
+
5
+
6
+ class NetboxIPFabricConfig(PluginConfig):
7
+ name = "ipfabric_netbox"
8
+ verbose_name = "NetBox IP Fabric SoT Plugin"
9
+ description = "Sync IP Fabric into NetBox"
10
+ version = "3.1.1"
11
+ base_url = "ipfabric"
12
+ min_version = "4.1"
13
+
14
+ def ready(self):
15
+ super().ready()
16
+ try:
17
+ from ipfabric_netbox.signals import ipfabric_netbox_init
18
+
19
+ all_tables = connection.introspection.table_names()
20
+ if all(
21
+ item in all_tables
22
+ for item in [
23
+ "extras_customfield",
24
+ "ipfabric_netbox_ipfabricbranch",
25
+ "ipfabric_netbox_ipfabricsource",
26
+ ]
27
+ ):
28
+ ipfabric_netbox_init()
29
+ if "ipfabric_netbox_ipfabrictransformmap" in all_tables:
30
+ from ipfabric_netbox.models import IPFabricTransformMap
31
+ from ipfabric_netbox.utilities.transform_map import BuildTransformMaps
32
+
33
+ if IPFabricTransformMap.objects.count() == 0:
34
+ data = requests.get(
35
+ "https://gitlab.com/ip-fabric/integrations/ipfabric-netbox/-/raw/main/scripts/transform_map.json"
36
+ ).json()
37
+ BuildTransformMaps(data=data)
38
+ except Exception as e:
39
+ print(f"Failed to initialize IP Fabric plugin: {e}.")
40
+
41
+
42
+ config = NetboxIPFabricConfig
@@ -0,0 +1,2 @@
1
+ from .nested_serializers import * # noqa: F401, F403
2
+ from .serializers import * # noqa: F401, F403
@@ -0,0 +1,99 @@
1
+ from drf_spectacular.types import OpenApiTypes
2
+ from drf_spectacular.utils import extend_schema_field
3
+ from netbox.api.fields import ContentTypeField
4
+ from netbox.api.serializers import NetBoxModelSerializer
5
+ from netbox.api.serializers import WritableNestedSerializer
6
+ from rest_framework import serializers
7
+ from users.api.serializers_.nested import NestedUserSerializer
8
+
9
+ from ipfabric_netbox.models import IPFabricBranch
10
+ from ipfabric_netbox.models import IPFabricSnapshot
11
+ from ipfabric_netbox.models import IPFabricSource
12
+ from ipfabric_netbox.models import IPFabricSync
13
+ from ipfabric_netbox.models import IPFabricTransformMap
14
+
15
+ # from .serializers import IPFabricSyncSerializer
16
+
17
+ __all__ = (
18
+ "NestedIPFabricSourceSerializer",
19
+ "NestedIPFabricSnapshotSerializer",
20
+ "NestedIPFabricTransformMapSerializer",
21
+ "NestedIPFabricBranchSerializer",
22
+ "NestedIPFabricSyncSerializer",
23
+ )
24
+
25
+
26
+ class NestedIPFabricSourceSerializer(WritableNestedSerializer):
27
+ url = serializers.URLField()
28
+
29
+ class Meta:
30
+ model = IPFabricSource
31
+ fields = ["id", "url", "display", "name", "type"]
32
+
33
+
34
+ class NestedIPFabricSnapshotSerializer(NetBoxModelSerializer):
35
+ source = NestedIPFabricSourceSerializer(read_only=True)
36
+ display = serializers.SerializerMethodField(read_only=True)
37
+
38
+ class Meta:
39
+ model = IPFabricSnapshot
40
+ fields = [
41
+ "id",
42
+ "name",
43
+ "source",
44
+ "snapshot_id",
45
+ "status",
46
+ "date",
47
+ "display",
48
+ "sites",
49
+ ]
50
+
51
+ @extend_schema_field(OpenApiTypes.STR)
52
+ def get_display(self, obj):
53
+ return f"{obj.name} ({obj.snapshot_id})"
54
+
55
+
56
+ class NestedIPFabricSyncSerializer(NetBoxModelSerializer):
57
+ snapshot_data = NestedIPFabricSnapshotSerializer(read_only=True)
58
+
59
+ class Meta:
60
+ model = IPFabricSync
61
+ fields = [
62
+ "id",
63
+ "name",
64
+ "display",
65
+ "snapshot_data",
66
+ "type",
67
+ "status",
68
+ "parameters",
69
+ "last_synced",
70
+ ]
71
+
72
+
73
+ class NestedIPFabricTransformMapSerializer(NetBoxModelSerializer):
74
+ target_model = ContentTypeField(read_only=True)
75
+
76
+ class Meta:
77
+ model = IPFabricTransformMap
78
+ fields = [
79
+ "id",
80
+ "source_model",
81
+ "target_model",
82
+ "status",
83
+ ]
84
+
85
+
86
+ class NestedIPFabricBranchSerializer(NetBoxModelSerializer):
87
+ user = NestedUserSerializer(read_only=True)
88
+ sync = NestedIPFabricSyncSerializer(read_only=True)
89
+
90
+ class Meta:
91
+ model = IPFabricBranch
92
+ fields = [
93
+ "id",
94
+ "name",
95
+ "display",
96
+ "sync",
97
+ "description",
98
+ "user",
99
+ ]
@@ -0,0 +1,160 @@
1
+ from core.choices import DataSourceStatusChoices
2
+ from netbox.api.fields import ChoiceField
3
+ from netbox.api.fields import ContentTypeField
4
+ from netbox.api.serializers import NetBoxModelSerializer
5
+ from rest_framework import serializers
6
+ from users.api.serializers_.nested import NestedUserSerializer
7
+
8
+ from .nested_serializers import NestedIPFabricBranchSerializer # noqa: F401
9
+ from .nested_serializers import NestedIPFabricSnapshotSerializer
10
+ from .nested_serializers import NestedIPFabricSourceSerializer
11
+ from .nested_serializers import NestedIPFabricTransformMapSerializer
12
+ from ipfabric_netbox.models import IPFabricBranch
13
+ from ipfabric_netbox.models import IPFabricRelationshipField
14
+ from ipfabric_netbox.models import IPFabricSnapshot
15
+ from ipfabric_netbox.models import IPFabricSource
16
+ from ipfabric_netbox.models import IPFabricSync
17
+ from ipfabric_netbox.models import IPFabricTransformField
18
+ from ipfabric_netbox.models import IPFabricTransformMap
19
+
20
+ __all__ = (
21
+ "IPFabricSyncSerializer",
22
+ "IPFabricSnapshotSerializer",
23
+ "IPFabricRelationshipFieldSerializer",
24
+ "IPFabricTransformFieldSerializer",
25
+ "IPFabricTransformMapSerializer",
26
+ "IPFabricBranchSerializer",
27
+ "IPFabricSourceSerializer",
28
+ )
29
+
30
+
31
+ class IPFabricSyncSerializer(NetBoxModelSerializer):
32
+ snapshot_data = NestedIPFabricSnapshotSerializer(read_only=True)
33
+
34
+ class Meta:
35
+ model = IPFabricSync
36
+ fields = [
37
+ "id",
38
+ "name",
39
+ "display",
40
+ "snapshot_data",
41
+ "type",
42
+ "status",
43
+ "parameters",
44
+ "last_synced",
45
+ "created",
46
+ "last_updated",
47
+ ]
48
+
49
+
50
+ class IPFabricSnapshotSerializer(NetBoxModelSerializer):
51
+ source = NestedIPFabricSourceSerializer()
52
+ data = serializers.JSONField()
53
+ date = serializers.DateTimeField()
54
+ last_updated = serializers.DateTimeField()
55
+
56
+ class Meta:
57
+ model = IPFabricSnapshot
58
+ fields = [
59
+ "id",
60
+ "name",
61
+ "source",
62
+ "snapshot_id",
63
+ "status",
64
+ "date",
65
+ "display",
66
+ "sites",
67
+ "data",
68
+ "created",
69
+ "last_updated",
70
+ ]
71
+
72
+ extra_kwargs = {
73
+ "raw_data": {"write_only": True},
74
+ }
75
+
76
+
77
+ class IPFabricRelationshipFieldSerializer(NetBoxModelSerializer):
78
+ transform_map = NestedIPFabricTransformMapSerializer(read_only=True)
79
+ source_model = ContentTypeField(read_only=True)
80
+
81
+ class Meta:
82
+ model = IPFabricRelationshipField
83
+ fields = [
84
+ "id",
85
+ "transform_map",
86
+ "source_model",
87
+ "target_field",
88
+ "coalesce",
89
+ "template",
90
+ ]
91
+
92
+
93
+ class IPFabricTransformMapSerializer(NetBoxModelSerializer):
94
+ target_model = ContentTypeField(read_only=True)
95
+
96
+ class Meta:
97
+ model = IPFabricTransformMap
98
+ fields = [
99
+ "id",
100
+ "source_model",
101
+ "target_model",
102
+ "status",
103
+ "created",
104
+ "last_updated",
105
+ ]
106
+
107
+
108
+ class IPFabricTransformFieldSerializer(NetBoxModelSerializer):
109
+ transform_map = NestedIPFabricTransformMapSerializer(read_only=True)
110
+
111
+ class Meta:
112
+ model = IPFabricTransformField
113
+ fields = [
114
+ "id",
115
+ "transform_map",
116
+ "source_field",
117
+ "target_field",
118
+ "coalesce",
119
+ "template",
120
+ ]
121
+
122
+
123
+ class IPFabricBranchSerializer(NetBoxModelSerializer):
124
+ user = NestedUserSerializer(read_only=True)
125
+ sync = IPFabricSyncSerializer(read_only=True)
126
+
127
+ class Meta:
128
+ model = IPFabricBranch
129
+ fields = [
130
+ "id",
131
+ "name",
132
+ "display",
133
+ "sync",
134
+ "description",
135
+ "user",
136
+ "created",
137
+ "last_updated",
138
+ ]
139
+
140
+
141
+ class IPFabricSourceSerializer(NetBoxModelSerializer):
142
+ status = ChoiceField(choices=DataSourceStatusChoices)
143
+ url = serializers.URLField()
144
+
145
+ class Meta:
146
+ model = IPFabricSource
147
+ fields = [
148
+ "id",
149
+ "url",
150
+ "display",
151
+ "name",
152
+ "type",
153
+ "status",
154
+ "last_synced",
155
+ "description",
156
+ "comments",
157
+ "parameters",
158
+ "created",
159
+ "last_updated",
160
+ ]
@@ -0,0 +1,21 @@
1
+ # api/urls.py
2
+ from netbox.api.routers import NetBoxRouter
3
+
4
+ from ipfabric_netbox.api.views import IPFabricBranchViewSet
5
+ from ipfabric_netbox.api.views import IPFabricRelationshipFieldiewSet
6
+ from ipfabric_netbox.api.views import IPFabricSnapshotViewSet
7
+ from ipfabric_netbox.api.views import IPFabricSourceViewSet
8
+ from ipfabric_netbox.api.views import IPFabricSyncViewSet
9
+ from ipfabric_netbox.api.views import IPFabricTransformFieldiewSet
10
+ from ipfabric_netbox.api.views import IPFabricTransformMapViewSet
11
+
12
+
13
+ router = NetBoxRouter()
14
+ router.register("source", IPFabricSourceViewSet)
15
+ router.register("snapshot", IPFabricSnapshotViewSet)
16
+ router.register("transform-map", IPFabricTransformMapViewSet)
17
+ router.register("sync", IPFabricSyncViewSet)
18
+ router.register("branch", IPFabricBranchViewSet)
19
+ router.register("transform-field", IPFabricTransformFieldiewSet)
20
+ router.register("relationship-field", IPFabricRelationshipFieldiewSet)
21
+ urlpatterns = router.urls
@@ -0,0 +1,111 @@
1
+ from django.db import transaction
2
+ from netbox.api.viewsets import NetBoxModelViewSet
3
+ from netbox.api.viewsets import NetBoxReadOnlyModelViewSet
4
+ from rest_framework.decorators import action
5
+ from rest_framework.response import Response
6
+ from utilities.query import count_related
7
+
8
+ from .serializers import IPFabricBranchSerializer
9
+ from .serializers import IPFabricRelationshipFieldSerializer
10
+ from .serializers import IPFabricSnapshotSerializer
11
+ from .serializers import IPFabricSourceSerializer
12
+ from .serializers import IPFabricSyncSerializer
13
+ from .serializers import IPFabricTransformFieldSerializer
14
+ from .serializers import IPFabricTransformMapSerializer
15
+ from ipfabric_netbox.filtersets import IPFabricSnapshotFilterSet
16
+ from ipfabric_netbox.filtersets import IPFabricSourceFilterSet
17
+ from ipfabric_netbox.filtersets import IPFabricTransformFieldFilterSet
18
+ from ipfabric_netbox.models import IPFabricBranch
19
+ from ipfabric_netbox.models import IPFabricData
20
+ from ipfabric_netbox.models import IPFabricRelationshipField
21
+ from ipfabric_netbox.models import IPFabricSnapshot
22
+ from ipfabric_netbox.models import IPFabricSource
23
+ from ipfabric_netbox.models import IPFabricSync
24
+ from ipfabric_netbox.models import IPFabricTransformField
25
+ from ipfabric_netbox.models import IPFabricTransformMap
26
+
27
+
28
+ class IPFabricTransformMapViewSet(NetBoxReadOnlyModelViewSet):
29
+ queryset = IPFabricTransformMap.objects.all()
30
+ serializer_class = IPFabricTransformMapSerializer
31
+
32
+
33
+ class IPFabricTransformFieldiewSet(NetBoxReadOnlyModelViewSet):
34
+ queryset = IPFabricTransformField.objects.all()
35
+ serializer_class = IPFabricTransformFieldSerializer
36
+ filterset_class = IPFabricTransformFieldFilterSet
37
+
38
+
39
+ class IPFabricRelationshipFieldiewSet(NetBoxReadOnlyModelViewSet):
40
+ queryset = IPFabricRelationshipField.objects.all()
41
+ serializer_class = IPFabricRelationshipFieldSerializer
42
+ filterset_class = IPFabricTransformFieldFilterSet
43
+
44
+
45
+ class IPFabricSyncViewSet(NetBoxReadOnlyModelViewSet):
46
+ queryset = IPFabricSync.objects.all()
47
+ serializer_class = IPFabricSyncSerializer
48
+
49
+
50
+ class IPFabricBranchViewSet(NetBoxReadOnlyModelViewSet):
51
+ queryset = IPFabricBranch.objects.all()
52
+ serializer_class = IPFabricBranchSerializer
53
+
54
+
55
+ class IPFabricSnapshotViewSet(NetBoxModelViewSet):
56
+ queryset = IPFabricSnapshot.objects.all()
57
+ serializer_class = IPFabricSnapshotSerializer
58
+ filterset_class = IPFabricSnapshotFilterSet
59
+
60
+ @action(detail=True, methods=["patch", "delete"], url_path="raw")
61
+ def raw(self, request, pk):
62
+ snapshot = self.get_object()
63
+ if request.method == "DELETE":
64
+ raw_data = IPFabricData.objects.filter(snapshot_data=snapshot)
65
+ raw_data._raw_delete(raw_data.db)
66
+ return Response({"status": "success"})
67
+ elif request.method == "PATCH":
68
+ transaction.set_autocommit(False)
69
+ IPFabricData.objects.bulk_create(
70
+ [
71
+ IPFabricData(
72
+ snapshot_data=snapshot, data=item["data"], type=item["type"]
73
+ )
74
+ for item in request.data["data"]
75
+ ],
76
+ batch_size=5000,
77
+ )
78
+ transaction.commit()
79
+ return Response({"status": "success"})
80
+
81
+ @action(detail=True, methods=["get"], url_path="sites")
82
+ def sites(self, request, pk):
83
+ q = request.GET.get("q", None)
84
+ snapshot = IPFabricSnapshot.objects.get(pk=pk)
85
+ new_sites = {"results": []}
86
+ if snapshot.data:
87
+ sites = snapshot.data.get("sites", None)
88
+ num = 0
89
+ if sites:
90
+ for site in sites:
91
+ if q:
92
+ if q.lower() in site.lower():
93
+ new_sites["results"].append(
94
+ {"display": site, "name": site, "id": site}
95
+ )
96
+ else:
97
+ new_sites["results"].append(
98
+ {"display": site, "name": site, "id": site}
99
+ )
100
+ num += 1
101
+ return Response(new_sites)
102
+ else:
103
+ return Response([])
104
+
105
+
106
+ class IPFabricSourceViewSet(NetBoxModelViewSet):
107
+ queryset = IPFabricSource.objects.annotate(
108
+ snapshot_count=count_related(IPFabricSnapshot, "source")
109
+ )
110
+ serializer_class = IPFabricSourceSerializer
111
+ filterset_class = IPFabricSourceFilterSet
@@ -0,0 +1,226 @@
1
+ from django.utils.translation import gettext_lazy as _
2
+ from utilities.choices import ChoiceSet
3
+
4
+ transform_field_source_columns = {
5
+ "site": [
6
+ "id",
7
+ "siteName",
8
+ "devicesCount",
9
+ "usersCount",
10
+ "stpDCount",
11
+ "switchesCount",
12
+ "vlanCount",
13
+ "rDCount",
14
+ "routersCount",
15
+ "networksCount",
16
+ ],
17
+ "device": [
18
+ "id",
19
+ "sn",
20
+ "hostname",
21
+ "siteName",
22
+ "rd",
23
+ "stpDomain",
24
+ "snHw",
25
+ "loginIp",
26
+ "objectId",
27
+ "loginType",
28
+ "uptime",
29
+ "reload",
30
+ "memoryUtilization",
31
+ "memoryTotalBytes",
32
+ "memoryUsedBytes",
33
+ "vendor",
34
+ "family",
35
+ "platform",
36
+ "model",
37
+ "configReg",
38
+ "version",
39
+ "image",
40
+ "processor",
41
+ "mac",
42
+ "devType",
43
+ "hostnameOriginal",
44
+ "hostnameProcessed",
45
+ "domain",
46
+ "fqdn",
47
+ ],
48
+ "inventory": [
49
+ "id",
50
+ "deviceSn",
51
+ "hostname",
52
+ "siteName",
53
+ "deviceId",
54
+ "name",
55
+ "dscr",
56
+ "pid",
57
+ "sn",
58
+ "vid",
59
+ "vendor",
60
+ "platform",
61
+ "model",
62
+ ],
63
+ "interface": [
64
+ "id",
65
+ "dscr",
66
+ "duplex",
67
+ "errDisabled",
68
+ "hasTransceiver",
69
+ "hostname",
70
+ "intName",
71
+ "intNameAlias",
72
+ "l1",
73
+ "l2",
74
+ "loginIp",
75
+ "loginType",
76
+ "mac",
77
+ "media",
78
+ "mtu",
79
+ "nameOriginal",
80
+ "primaryIp",
81
+ "reason",
82
+ "rel",
83
+ "siteName",
84
+ "sn",
85
+ "speed",
86
+ "speedValue",
87
+ "transceiverPn",
88
+ "transceiverSn",
89
+ "transceiverType",
90
+ ],
91
+ "part_number": [
92
+ "id",
93
+ "deviceSn",
94
+ "hostname",
95
+ "siteName",
96
+ "deviceId",
97
+ "name",
98
+ "dscr",
99
+ "pid",
100
+ "sn",
101
+ "vid",
102
+ "vendor",
103
+ "platform",
104
+ "model",
105
+ ],
106
+ "vlan": ["id", "siteName", "vlanId", "vlanName", "dscr", "devCount"],
107
+ "vrf": ["id", "sn", "hostname", "siteName", "vrf", "rd", "intCount"],
108
+ "prefix": ["id", "siteName", "net", "hosts", "gw", "gwV", "vrf", "vlanId"],
109
+ "virtualchassis": [
110
+ "id",
111
+ "sn",
112
+ "master",
113
+ "siteName",
114
+ "uptime",
115
+ "member",
116
+ "connectionsCount",
117
+ "pn",
118
+ "memberSn",
119
+ "role",
120
+ "state",
121
+ "mac",
122
+ "ver",
123
+ "image",
124
+ "hwVer",
125
+ ],
126
+ "ipaddress": [
127
+ "hostname",
128
+ "sn",
129
+ "intName",
130
+ "stateL1",
131
+ "stateL2",
132
+ "siteName",
133
+ "dnsName",
134
+ "dnsHostnameMatch",
135
+ "vlanId",
136
+ "dnsReverseMatch",
137
+ "mac",
138
+ "ip",
139
+ "net",
140
+ "type",
141
+ "vrf",
142
+ ],
143
+ }
144
+
145
+
146
+ class IPFabricTransformMapSourceModelChoices(ChoiceSet):
147
+ SITE = "site"
148
+ INVENTORY = "inventory"
149
+ DEVICE = "device"
150
+ VIRTUALCHASSIS = "virtualchassis"
151
+ INTERFACE = "interface"
152
+ VLAN = "vlan"
153
+ VRF = "vrf"
154
+ PREFIX = "prefix"
155
+ IPADDRESS = "ipaddress"
156
+ # PARTNUMBERS = "part_number"
157
+
158
+ CHOICES = (
159
+ (SITE, "Site", "cyan"),
160
+ (INVENTORY, "Inventory", "gray"),
161
+ (DEVICE, "Device", "gray"),
162
+ (VIRTUALCHASSIS, "Virtual Chassis", "grey"),
163
+ (INTERFACE, "Interface", "gray"),
164
+ (VLAN, "VLAN", "gray"),
165
+ (VRF, "VRF", "gray"),
166
+ (PREFIX, "Prefix", "gray"),
167
+ (IPADDRESS, "IP Address", "gray"),
168
+ # (PARTNUMBERS, "Part Number", "gray"),
169
+ )
170
+
171
+
172
+ class IPFabricSnapshotStatusModelChoices(ChoiceSet):
173
+ key = "IPFabricSnapshot.status"
174
+
175
+ STATUS_LOADED = "loaded"
176
+ STATUS_UNLOADED = "unloaded"
177
+
178
+ CHOICES = [
179
+ (STATUS_LOADED, _("Loaded"), "green"),
180
+ (STATUS_UNLOADED, _("Unloaded"), "red"),
181
+ ]
182
+
183
+
184
+ class IPFabricSyncTypeChoices(ChoiceSet):
185
+ ALL = "all"
186
+ DCIM = "dcim"
187
+ IPAM = "ipam"
188
+
189
+ CHOICES = (
190
+ (ALL, _("All"), "gray"),
191
+ (DCIM, _("DCIM"), "blue"),
192
+ (IPAM, _("IPAM"), "blue"),
193
+ )
194
+
195
+
196
+ class IPFabricSourceTypeChoices(ChoiceSet):
197
+ LOCAL = "local"
198
+ REMOTE = "remote"
199
+
200
+ CHOICES = (
201
+ (LOCAL, "Local", "cyan"),
202
+ (REMOTE, "Remote", "gray"),
203
+ )
204
+
205
+
206
+ class IPFabricRawDataTypeChoices(ChoiceSet):
207
+ DEVICE = "device"
208
+ VLAN = "vlan"
209
+ VRF = "vrf"
210
+ VIRTUALCHASSIS = "virtualchassis"
211
+ PREFIX = "prefix"
212
+ INTERFACE = "interface"
213
+ IPADDRESS = "ipaddress"
214
+ INVENTORYITEM = "inventoryitem"
215
+ SITE = "site"
216
+
217
+ CHOICES = (
218
+ (DEVICE, "Local", "cyan"),
219
+ (VLAN, "VLAN", "gray"),
220
+ (VIRTUALCHASSIS, "Virtual Chassis", "gray"),
221
+ (PREFIX, "Prefix", "gray"),
222
+ (INTERFACE, "Interface", "gray"),
223
+ (INVENTORYITEM, "Inventory Item", "gray"),
224
+ (IPADDRESS, "IP Address", "gray"),
225
+ (SITE, "Site", "gray"),
226
+ )