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.
- ipfabric_netbox/__init__.py +42 -0
- ipfabric_netbox/api/__init__.py +2 -0
- ipfabric_netbox/api/nested_serializers.py +99 -0
- ipfabric_netbox/api/serializers.py +160 -0
- ipfabric_netbox/api/urls.py +21 -0
- ipfabric_netbox/api/views.py +111 -0
- ipfabric_netbox/choices.py +226 -0
- ipfabric_netbox/filtersets.py +125 -0
- ipfabric_netbox/forms.py +1063 -0
- ipfabric_netbox/jobs.py +95 -0
- ipfabric_netbox/migrations/0001_initial.py +342 -0
- ipfabric_netbox/migrations/0002_ipfabricsnapshot_status.py +17 -0
- ipfabric_netbox/migrations/0003_ipfabricsource_type_and_more.py +49 -0
- ipfabric_netbox/migrations/0004_ipfabricsync_auto_merge.py +17 -0
- ipfabric_netbox/migrations/0005_alter_ipfabricrelationshipfield_source_model_and_more.py +64 -0
- ipfabric_netbox/migrations/0006_alter_ipfabrictransformmap_target_model.py +48 -0
- ipfabric_netbox/migrations/__init__.py +0 -0
- ipfabric_netbox/models.py +874 -0
- ipfabric_netbox/navigation.py +62 -0
- ipfabric_netbox/signals.py +68 -0
- ipfabric_netbox/tables.py +208 -0
- ipfabric_netbox/template_content.py +13 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/diff.html +72 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/json.html +20 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/logs_pending.html +6 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/merge_form.html +22 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/site_topology_button.html +70 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/site_topology_modal.html +61 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/snapshotdata.html +60 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/sync_delete.html +19 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/transform_map_field_map.html +11 -0
- ipfabric_netbox/templates/ipfabric_netbox/inc/transform_map_relationship_map.html +11 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabric_table.html +55 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricbranch.html +141 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricsnapshot.html +105 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricsource.html +111 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabricsync.html +103 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap.html +41 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap_list.html +17 -0
- ipfabric_netbox/templates/ipfabric_netbox/ipfabrictransformmap_restore.html +59 -0
- ipfabric_netbox/templates/ipfabric_netbox/partials/branch_all.html +10 -0
- ipfabric_netbox/templates/ipfabric_netbox/partials/branch_progress.html +19 -0
- ipfabric_netbox/templates/ipfabric_netbox/partials/branch_status.html +1 -0
- ipfabric_netbox/templates/ipfabric_netbox/partials/job_logs.html +53 -0
- ipfabric_netbox/templates/ipfabric_netbox/partials/sync_last_branch.html +1 -0
- ipfabric_netbox/templates/ipfabric_netbox/sync_list.html +126 -0
- ipfabric_netbox/templates/static/ipfabric_netbox/css/rack.css +9 -0
- ipfabric_netbox/tests/__init__.py +0 -0
- ipfabric_netbox/tests/test_models.py +1340 -0
- ipfabric_netbox/urls.py +141 -0
- ipfabric_netbox/utilities/__init__.py +0 -0
- ipfabric_netbox/utilities/ipfutils.py +591 -0
- ipfabric_netbox/utilities/logging.py +93 -0
- ipfabric_netbox/utilities/nbutils.py +105 -0
- ipfabric_netbox/utilities/transform_map.py +35 -0
- ipfabric_netbox/views.py +845 -0
- ipfabric_netbox-3.1.2.dist-info/METADATA +88 -0
- ipfabric_netbox-3.1.2.dist-info/RECORD +59 -0
- ipfabric_netbox-3.1.2.dist-info/WHEEL +4 -0
ipfabric_netbox/jobs.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from datetime import timedelta
|
|
3
|
+
|
|
4
|
+
from core.choices import DataSourceStatusChoices
|
|
5
|
+
from core.choices import JobStatusChoices
|
|
6
|
+
from core.exceptions import SyncError
|
|
7
|
+
from core.models import Job
|
|
8
|
+
from netbox.context_managers import event_tracking
|
|
9
|
+
from rq.timeouts import JobTimeoutException
|
|
10
|
+
from utilities.datetime import local_now
|
|
11
|
+
from utilities.request import NetBoxFakeRequest
|
|
12
|
+
|
|
13
|
+
from .models import IPFabricBranch
|
|
14
|
+
from .models import IPFabricSource
|
|
15
|
+
from .models import IPFabricSync
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def sync_ipfabricsource(job, *args, **kwargs):
|
|
21
|
+
ipfsource = IPFabricSource.objects.get(pk=job.object_id)
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
job.start()
|
|
25
|
+
ipfsource.sync(job=job)
|
|
26
|
+
job.terminate()
|
|
27
|
+
except Exception as e:
|
|
28
|
+
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
|
|
29
|
+
IPFabricSource.objects.filter(pk=ipfsource.pk).update(
|
|
30
|
+
status=DataSourceStatusChoices.FAILED
|
|
31
|
+
)
|
|
32
|
+
if type(e) in (SyncError, JobTimeoutException):
|
|
33
|
+
logging.error(e)
|
|
34
|
+
else:
|
|
35
|
+
raise e
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def sync_ipfabric(job, *args, **kwargs):
|
|
39
|
+
obj = IPFabricSync.objects.get(pk=job.object_id)
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
job.start()
|
|
43
|
+
obj.sync(job=job)
|
|
44
|
+
job.terminate()
|
|
45
|
+
except Exception as e:
|
|
46
|
+
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
|
|
47
|
+
IPFabricSync.objects.filter(pk=obj.pk).update(
|
|
48
|
+
status=DataSourceStatusChoices.FAILED
|
|
49
|
+
)
|
|
50
|
+
if type(e) in (SyncError, JobTimeoutException):
|
|
51
|
+
logging.error(e)
|
|
52
|
+
else:
|
|
53
|
+
raise e
|
|
54
|
+
finally:
|
|
55
|
+
if obj.interval and not kwargs.get("adhoc"):
|
|
56
|
+
new_scheduled_time = local_now() + timedelta(minutes=obj.interval)
|
|
57
|
+
job = Job.enqueue(
|
|
58
|
+
sync_ipfabric,
|
|
59
|
+
name=f"{obj.name} - (scheduled)",
|
|
60
|
+
instance=obj,
|
|
61
|
+
user=obj.user,
|
|
62
|
+
schedule_at=new_scheduled_time,
|
|
63
|
+
interval=obj.interval,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def merge_ipfabric_branch(job, *args, **kwargs):
|
|
68
|
+
branch = IPFabricBranch.objects.get(pk=job.object_id)
|
|
69
|
+
try:
|
|
70
|
+
request = NetBoxFakeRequest(
|
|
71
|
+
{
|
|
72
|
+
"META": {},
|
|
73
|
+
"POST": branch.sync.parameters,
|
|
74
|
+
"GET": {},
|
|
75
|
+
"FILES": {},
|
|
76
|
+
"user": branch.user,
|
|
77
|
+
"path": "",
|
|
78
|
+
"id": job.job_id,
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
job.start()
|
|
83
|
+
with event_tracking(request):
|
|
84
|
+
branch.sync_merge()
|
|
85
|
+
job.terminate()
|
|
86
|
+
except Exception as e:
|
|
87
|
+
print(e)
|
|
88
|
+
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
|
|
89
|
+
IPFabricSync.objects.filter(pk=branch.sync.pk).update(
|
|
90
|
+
status=DataSourceStatusChoices.FAILED
|
|
91
|
+
)
|
|
92
|
+
if type(e) in (SyncError, JobTimeoutException):
|
|
93
|
+
logging.error(e)
|
|
94
|
+
else:
|
|
95
|
+
raise e
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Generated by Django 4.1.8 on 2023-09-28 13:22
|
|
2
|
+
import django.core.validators
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
import taggit.managers
|
|
5
|
+
import utilities.json
|
|
6
|
+
from django.conf import settings
|
|
7
|
+
from django.db import migrations
|
|
8
|
+
from django.db import models
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Migration(migrations.Migration):
|
|
12
|
+
initial = True
|
|
13
|
+
|
|
14
|
+
dependencies = [
|
|
15
|
+
("core", "0005_job_created_auto_now"),
|
|
16
|
+
("extras", "0092_delete_jobresult"),
|
|
17
|
+
("contenttypes", "0002_remove_content_type_name"),
|
|
18
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
operations = [
|
|
22
|
+
migrations.CreateModel(
|
|
23
|
+
name="IPFabricSnapshot",
|
|
24
|
+
fields=[
|
|
25
|
+
(
|
|
26
|
+
"id",
|
|
27
|
+
models.BigAutoField(
|
|
28
|
+
auto_created=True, primary_key=True, serialize=False
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
("created", models.DateTimeField(auto_now_add=True)),
|
|
32
|
+
("last_updated", models.DateTimeField(editable=False)),
|
|
33
|
+
("name", models.CharField(max_length=200)),
|
|
34
|
+
("snapshot_id", models.CharField(max_length=100, unique=True)),
|
|
35
|
+
("data", models.JSONField(blank=True, null=True)),
|
|
36
|
+
("date", models.DateTimeField(blank=True, editable=False, null=True)),
|
|
37
|
+
],
|
|
38
|
+
options={
|
|
39
|
+
"verbose_name": "IP Fabric Snapshot",
|
|
40
|
+
"verbose_name_plural": "IP Fabric Snapshots",
|
|
41
|
+
"ordering": ("source", "-date"),
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
migrations.CreateModel(
|
|
45
|
+
name="IPFabricTransformMap",
|
|
46
|
+
fields=[
|
|
47
|
+
(
|
|
48
|
+
"id",
|
|
49
|
+
models.BigAutoField(
|
|
50
|
+
auto_created=True, primary_key=True, serialize=False
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
("created", models.DateTimeField(auto_now_add=True, null=True)),
|
|
54
|
+
("last_updated", models.DateTimeField(auto_now=True, null=True)),
|
|
55
|
+
(
|
|
56
|
+
"custom_field_data",
|
|
57
|
+
models.JSONField(
|
|
58
|
+
blank=True,
|
|
59
|
+
default=dict,
|
|
60
|
+
encoder=utilities.json.CustomFieldJSONEncoder,
|
|
61
|
+
),
|
|
62
|
+
),
|
|
63
|
+
("name", models.CharField(max_length=100, unique=True)),
|
|
64
|
+
("source_model", models.CharField(max_length=50)),
|
|
65
|
+
("status", models.CharField(max_length=50)),
|
|
66
|
+
(
|
|
67
|
+
"tags",
|
|
68
|
+
taggit.managers.TaggableManager(
|
|
69
|
+
through="extras.TaggedItem", to="extras.Tag"
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
(
|
|
73
|
+
"target_model",
|
|
74
|
+
models.ForeignKey(
|
|
75
|
+
limit_choices_to=models.Q(
|
|
76
|
+
models.Q(
|
|
77
|
+
models.Q(("app_label", "dcim"), ("model", "site")),
|
|
78
|
+
models.Q(
|
|
79
|
+
("app_label", "dcim"), ("model", "manufacturer")
|
|
80
|
+
),
|
|
81
|
+
models.Q(("app_label", "dcim"), ("model", "platform")),
|
|
82
|
+
models.Q(
|
|
83
|
+
("app_label", "dcim"), ("model", "devicerole")
|
|
84
|
+
),
|
|
85
|
+
models.Q(
|
|
86
|
+
("app_label", "dcim"), ("model", "devicetype")
|
|
87
|
+
),
|
|
88
|
+
models.Q(("app_label", "dcim"), ("model", "device")),
|
|
89
|
+
models.Q(
|
|
90
|
+
("app_label", "dcim"), ("model", "virtualchassis")
|
|
91
|
+
),
|
|
92
|
+
models.Q(("app_label", "dcim"), ("model", "interface")),
|
|
93
|
+
models.Q(("app_label", "ipam"), ("model", "vlan")),
|
|
94
|
+
models.Q(("app_label", "ipam"), ("model", "vrf")),
|
|
95
|
+
models.Q(("app_label", "ipam"), ("model", "prefix")),
|
|
96
|
+
models.Q(("app_label", "ipam"), ("model", "ipaddress")),
|
|
97
|
+
models.Q(
|
|
98
|
+
("app_label", "contenttypes"),
|
|
99
|
+
("model", "contenttype"),
|
|
100
|
+
),
|
|
101
|
+
_connector="OR",
|
|
102
|
+
)
|
|
103
|
+
),
|
|
104
|
+
on_delete=django.db.models.deletion.PROTECT,
|
|
105
|
+
related_name="+",
|
|
106
|
+
to="contenttypes.contenttype",
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
],
|
|
110
|
+
options={
|
|
111
|
+
"verbose_name": "IP Fabric Transform Map",
|
|
112
|
+
"verbose_name_plural": "IP Fabric Transform Maps",
|
|
113
|
+
},
|
|
114
|
+
),
|
|
115
|
+
migrations.CreateModel(
|
|
116
|
+
name="IPFabricTransformField",
|
|
117
|
+
fields=[
|
|
118
|
+
(
|
|
119
|
+
"id",
|
|
120
|
+
models.BigAutoField(
|
|
121
|
+
auto_created=True, primary_key=True, serialize=False
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
("source_field", models.CharField(max_length=100)),
|
|
125
|
+
("target_field", models.CharField(max_length=100)),
|
|
126
|
+
("coalesce", models.BooleanField(default=False)),
|
|
127
|
+
("template", models.TextField(blank=True, null=True)),
|
|
128
|
+
(
|
|
129
|
+
"transform_map",
|
|
130
|
+
models.ForeignKey(
|
|
131
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
132
|
+
related_name="field_maps",
|
|
133
|
+
to="ipfabric_netbox.ipfabrictransformmap",
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
],
|
|
137
|
+
options={
|
|
138
|
+
"verbose_name": "IP Fabric Transform Field",
|
|
139
|
+
"verbose_name_plural": "IP Fabric Transform Fields",
|
|
140
|
+
"ordering": ("transform_map",),
|
|
141
|
+
},
|
|
142
|
+
),
|
|
143
|
+
migrations.CreateModel(
|
|
144
|
+
name="IPFabricSync",
|
|
145
|
+
fields=[
|
|
146
|
+
(
|
|
147
|
+
"id",
|
|
148
|
+
models.BigAutoField(
|
|
149
|
+
auto_created=True, primary_key=True, serialize=False
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
("created", models.DateTimeField(auto_now_add=True, null=True)),
|
|
153
|
+
("last_updated", models.DateTimeField(auto_now=True, null=True)),
|
|
154
|
+
("name", models.CharField(max_length=100, unique=True)),
|
|
155
|
+
("type", models.CharField(default="dcim", max_length=50)),
|
|
156
|
+
(
|
|
157
|
+
"status",
|
|
158
|
+
models.CharField(default="new", editable=False, max_length=50),
|
|
159
|
+
),
|
|
160
|
+
("parameters", models.JSONField(blank=True, null=True)),
|
|
161
|
+
(
|
|
162
|
+
"last_synced",
|
|
163
|
+
models.DateTimeField(blank=True, editable=False, null=True),
|
|
164
|
+
),
|
|
165
|
+
("scheduled", models.DateTimeField(blank=True, null=True)),
|
|
166
|
+
(
|
|
167
|
+
"interval",
|
|
168
|
+
models.PositiveIntegerField(
|
|
169
|
+
blank=True,
|
|
170
|
+
null=True,
|
|
171
|
+
validators=[django.core.validators.MinValueValidator(1)],
|
|
172
|
+
),
|
|
173
|
+
),
|
|
174
|
+
(
|
|
175
|
+
"snapshot_data",
|
|
176
|
+
models.ForeignKey(
|
|
177
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
178
|
+
related_name="snapshots",
|
|
179
|
+
to="ipfabric_netbox.ipfabricsnapshot",
|
|
180
|
+
),
|
|
181
|
+
),
|
|
182
|
+
(
|
|
183
|
+
"tags",
|
|
184
|
+
taggit.managers.TaggableManager(
|
|
185
|
+
through="extras.TaggedItem", to="extras.Tag"
|
|
186
|
+
),
|
|
187
|
+
),
|
|
188
|
+
(
|
|
189
|
+
"user",
|
|
190
|
+
models.ForeignKey(
|
|
191
|
+
blank=True,
|
|
192
|
+
null=True,
|
|
193
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
194
|
+
related_name="+",
|
|
195
|
+
to=settings.AUTH_USER_MODEL,
|
|
196
|
+
),
|
|
197
|
+
),
|
|
198
|
+
],
|
|
199
|
+
options={
|
|
200
|
+
"verbose_name": "IP Fabric Sync",
|
|
201
|
+
"ordering": ["pk"],
|
|
202
|
+
},
|
|
203
|
+
),
|
|
204
|
+
migrations.CreateModel(
|
|
205
|
+
name="IPFabricSource",
|
|
206
|
+
fields=[
|
|
207
|
+
(
|
|
208
|
+
"id",
|
|
209
|
+
models.BigAutoField(
|
|
210
|
+
auto_created=True, primary_key=True, serialize=False
|
|
211
|
+
),
|
|
212
|
+
),
|
|
213
|
+
("created", models.DateTimeField(auto_now_add=True, null=True)),
|
|
214
|
+
("last_updated", models.DateTimeField(auto_now=True, null=True)),
|
|
215
|
+
(
|
|
216
|
+
"custom_field_data",
|
|
217
|
+
models.JSONField(
|
|
218
|
+
blank=True,
|
|
219
|
+
default=dict,
|
|
220
|
+
encoder=utilities.json.CustomFieldJSONEncoder,
|
|
221
|
+
),
|
|
222
|
+
),
|
|
223
|
+
("description", models.CharField(blank=True, max_length=200)),
|
|
224
|
+
("comments", models.TextField(blank=True)),
|
|
225
|
+
("name", models.CharField(max_length=100, unique=True)),
|
|
226
|
+
("url", models.CharField(max_length=200)),
|
|
227
|
+
(
|
|
228
|
+
"status",
|
|
229
|
+
models.CharField(default="new", editable=False, max_length=50),
|
|
230
|
+
),
|
|
231
|
+
("parameters", models.JSONField(blank=True, null=True)),
|
|
232
|
+
(
|
|
233
|
+
"last_synced",
|
|
234
|
+
models.DateTimeField(blank=True, editable=False, null=True),
|
|
235
|
+
),
|
|
236
|
+
(
|
|
237
|
+
"tags",
|
|
238
|
+
taggit.managers.TaggableManager(
|
|
239
|
+
through="extras.TaggedItem", to="extras.Tag"
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
],
|
|
243
|
+
options={
|
|
244
|
+
"verbose_name": "IP Fabric Source",
|
|
245
|
+
"verbose_name_plural": "IP Fabric Sources",
|
|
246
|
+
"ordering": ("name",),
|
|
247
|
+
},
|
|
248
|
+
),
|
|
249
|
+
migrations.AddField(
|
|
250
|
+
model_name="ipfabricsnapshot",
|
|
251
|
+
name="source",
|
|
252
|
+
field=models.ForeignKey(
|
|
253
|
+
editable=False,
|
|
254
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
255
|
+
related_name="snapshots",
|
|
256
|
+
to="ipfabric_netbox.ipfabricsource",
|
|
257
|
+
),
|
|
258
|
+
),
|
|
259
|
+
migrations.CreateModel(
|
|
260
|
+
name="IPFabricRelationshipField",
|
|
261
|
+
fields=[
|
|
262
|
+
(
|
|
263
|
+
"id",
|
|
264
|
+
models.BigAutoField(
|
|
265
|
+
auto_created=True, primary_key=True, serialize=False
|
|
266
|
+
),
|
|
267
|
+
),
|
|
268
|
+
("target_field", models.CharField(max_length=100)),
|
|
269
|
+
("coalesce", models.BooleanField(default=False)),
|
|
270
|
+
("template", models.TextField(blank=True, null=True)),
|
|
271
|
+
(
|
|
272
|
+
"source_model",
|
|
273
|
+
models.ForeignKey(
|
|
274
|
+
limit_choices_to=models.Q(
|
|
275
|
+
models.Q(
|
|
276
|
+
("app_label", "dcim"),
|
|
277
|
+
("app_label", "ipam"),
|
|
278
|
+
models.Q(
|
|
279
|
+
("app_label", "contenttypes"),
|
|
280
|
+
("model", "contenttype"),
|
|
281
|
+
),
|
|
282
|
+
_connector="OR",
|
|
283
|
+
)
|
|
284
|
+
),
|
|
285
|
+
on_delete=django.db.models.deletion.PROTECT,
|
|
286
|
+
related_name="ipfabric_transform_fields",
|
|
287
|
+
to="contenttypes.contenttype",
|
|
288
|
+
),
|
|
289
|
+
),
|
|
290
|
+
(
|
|
291
|
+
"transform_map",
|
|
292
|
+
models.ForeignKey(
|
|
293
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
294
|
+
related_name="relationship_maps",
|
|
295
|
+
to="ipfabric_netbox.ipfabrictransformmap",
|
|
296
|
+
),
|
|
297
|
+
),
|
|
298
|
+
],
|
|
299
|
+
options={
|
|
300
|
+
"verbose_name": "IP Fabric Relationship Field",
|
|
301
|
+
"verbose_name_plural": "IP Fabric Relationship Fields",
|
|
302
|
+
"ordering": ("transform_map",),
|
|
303
|
+
},
|
|
304
|
+
),
|
|
305
|
+
migrations.CreateModel(
|
|
306
|
+
name="IPFabricBranch",
|
|
307
|
+
fields=[
|
|
308
|
+
(
|
|
309
|
+
"branch_ptr",
|
|
310
|
+
models.OneToOneField(
|
|
311
|
+
auto_created=True,
|
|
312
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
313
|
+
parent_link=True,
|
|
314
|
+
primary_key=True,
|
|
315
|
+
serialize=False,
|
|
316
|
+
to="extras.branch",
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
(
|
|
320
|
+
"job",
|
|
321
|
+
models.ForeignKey(
|
|
322
|
+
null=True,
|
|
323
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
324
|
+
to="core.job",
|
|
325
|
+
),
|
|
326
|
+
),
|
|
327
|
+
(
|
|
328
|
+
"sync",
|
|
329
|
+
models.ForeignKey(
|
|
330
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
331
|
+
to="ipfabric_netbox.ipfabricsync",
|
|
332
|
+
),
|
|
333
|
+
),
|
|
334
|
+
],
|
|
335
|
+
options={
|
|
336
|
+
"verbose_name": "IP Fabric Branch",
|
|
337
|
+
"verbose_name_plural": "IP Fabric Branches",
|
|
338
|
+
"ordering": ("name",),
|
|
339
|
+
},
|
|
340
|
+
bases=("extras.branch",),
|
|
341
|
+
),
|
|
342
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 4.1.10 on 2023-10-10 15:47
|
|
2
|
+
from django.db import migrations
|
|
3
|
+
from django.db import models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
dependencies = [
|
|
8
|
+
("ipfabric_netbox", "0001_initial"),
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
operations = [
|
|
12
|
+
migrations.AddField(
|
|
13
|
+
model_name="ipfabricsnapshot",
|
|
14
|
+
name="status",
|
|
15
|
+
field=models.CharField(default="unloaded", max_length=50),
|
|
16
|
+
),
|
|
17
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Generated by Django 4.1.10 on 2024-01-05 16:59
|
|
2
|
+
import django.db.models.deletion
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
from django.db import models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("ipfabric_netbox", "0002_ipfabricsnapshot_status"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name="ipfabricsource",
|
|
15
|
+
name="type",
|
|
16
|
+
field=models.CharField(default="local", max_length=50),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="ipfabricsnapshot",
|
|
20
|
+
name="snapshot_id",
|
|
21
|
+
field=models.CharField(max_length=100),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterField(
|
|
24
|
+
model_name="ipfabricsource",
|
|
25
|
+
name="last_synced",
|
|
26
|
+
field=models.DateTimeField(blank=True, null=True),
|
|
27
|
+
),
|
|
28
|
+
migrations.CreateModel(
|
|
29
|
+
name="IPFabricData",
|
|
30
|
+
fields=[
|
|
31
|
+
(
|
|
32
|
+
"id",
|
|
33
|
+
models.BigAutoField(
|
|
34
|
+
auto_created=True, primary_key=True, serialize=False
|
|
35
|
+
),
|
|
36
|
+
),
|
|
37
|
+
("data", models.JSONField(blank=True, null=True)),
|
|
38
|
+
("type", models.CharField(max_length=50)),
|
|
39
|
+
(
|
|
40
|
+
"snapshot_data",
|
|
41
|
+
models.ForeignKey(
|
|
42
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
43
|
+
related_name="ipf_data",
|
|
44
|
+
to="ipfabric_netbox.ipfabricsnapshot",
|
|
45
|
+
),
|
|
46
|
+
),
|
|
47
|
+
],
|
|
48
|
+
),
|
|
49
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 4.1.10 on 2024-01-09 16:01
|
|
2
|
+
from django.db import migrations
|
|
3
|
+
from django.db import models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
dependencies = [
|
|
8
|
+
("ipfabric_netbox", "0003_ipfabricsource_type_and_more"),
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
operations = [
|
|
12
|
+
migrations.AddField(
|
|
13
|
+
model_name="ipfabricsync",
|
|
14
|
+
name="auto_merge",
|
|
15
|
+
field=models.BooleanField(default=False),
|
|
16
|
+
),
|
|
17
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Generated by Django 5.0.5 on 2024-05-16 15:23
|
|
2
|
+
import django.db.models.deletion
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
from django.db import models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("contenttypes", "0002_remove_content_type_name"),
|
|
10
|
+
("ipfabric_netbox", "0004_ipfabricsync_auto_merge"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AlterField(
|
|
15
|
+
model_name="ipfabricrelationshipfield",
|
|
16
|
+
name="source_model",
|
|
17
|
+
field=models.ForeignKey(
|
|
18
|
+
limit_choices_to=models.Q(
|
|
19
|
+
models.Q(
|
|
20
|
+
("app_label", "dcim"),
|
|
21
|
+
("app_label", "ipam"),
|
|
22
|
+
("app_label", "tenancy"),
|
|
23
|
+
models.Q(
|
|
24
|
+
("app_label", "contenttypes"), ("model", "contenttype")
|
|
25
|
+
),
|
|
26
|
+
_connector="OR",
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
on_delete=django.db.models.deletion.PROTECT,
|
|
30
|
+
related_name="ipfabric_transform_fields",
|
|
31
|
+
to="contenttypes.contenttype",
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
migrations.AlterField(
|
|
35
|
+
model_name="ipfabrictransformmap",
|
|
36
|
+
name="target_model",
|
|
37
|
+
field=models.ForeignKey(
|
|
38
|
+
limit_choices_to=models.Q(
|
|
39
|
+
models.Q(
|
|
40
|
+
models.Q(("app_label", "dcim"), ("model", "site")),
|
|
41
|
+
models.Q(("app_label", "dcim"), ("model", "manufacturer")),
|
|
42
|
+
models.Q(("app_label", "dcim"), ("model", "platform")),
|
|
43
|
+
models.Q(("app_label", "dcim"), ("model", "devicerole")),
|
|
44
|
+
models.Q(("app_label", "dcim"), ("model", "devicetype")),
|
|
45
|
+
models.Q(("app_label", "dcim"), ("model", "device")),
|
|
46
|
+
models.Q(("app_label", "dcim"), ("model", "virtualchassis")),
|
|
47
|
+
models.Q(("app_label", "dcim"), ("model", "interface")),
|
|
48
|
+
models.Q(("app_label", "ipam"), ("model", "vlan")),
|
|
49
|
+
models.Q(("app_label", "ipam"), ("model", "vrf")),
|
|
50
|
+
models.Q(("app_label", "ipam"), ("model", "prefix")),
|
|
51
|
+
models.Q(("app_label", "ipam"), ("model", "ipaddress")),
|
|
52
|
+
models.Q(
|
|
53
|
+
("app_label", "contenttypes"), ("model", "contenttype")
|
|
54
|
+
),
|
|
55
|
+
models.Q(("app_label", "tenancy"), ("model", "tenant")),
|
|
56
|
+
_connector="OR",
|
|
57
|
+
)
|
|
58
|
+
),
|
|
59
|
+
on_delete=django.db.models.deletion.PROTECT,
|
|
60
|
+
related_name="+",
|
|
61
|
+
to="contenttypes.contenttype",
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Generated by Django 5.0.9 on 2024-12-18 10:51
|
|
2
|
+
import django.db.models.deletion
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
from django.db import models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("contenttypes", "0002_remove_content_type_name"),
|
|
10
|
+
(
|
|
11
|
+
"ipfabric_netbox",
|
|
12
|
+
"0005_alter_ipfabricrelationshipfield_source_model_and_more",
|
|
13
|
+
),
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
operations = [
|
|
17
|
+
migrations.AlterField(
|
|
18
|
+
model_name="ipfabrictransformmap",
|
|
19
|
+
name="target_model",
|
|
20
|
+
field=models.ForeignKey(
|
|
21
|
+
limit_choices_to=models.Q(
|
|
22
|
+
models.Q(
|
|
23
|
+
models.Q(("app_label", "dcim"), ("model", "site")),
|
|
24
|
+
models.Q(("app_label", "dcim"), ("model", "manufacturer")),
|
|
25
|
+
models.Q(("app_label", "dcim"), ("model", "platform")),
|
|
26
|
+
models.Q(("app_label", "dcim"), ("model", "devicerole")),
|
|
27
|
+
models.Q(("app_label", "dcim"), ("model", "devicetype")),
|
|
28
|
+
models.Q(("app_label", "dcim"), ("model", "device")),
|
|
29
|
+
models.Q(("app_label", "dcim"), ("model", "virtualchassis")),
|
|
30
|
+
models.Q(("app_label", "dcim"), ("model", "interface")),
|
|
31
|
+
models.Q(("app_label", "ipam"), ("model", "vlan")),
|
|
32
|
+
models.Q(("app_label", "ipam"), ("model", "vrf")),
|
|
33
|
+
models.Q(("app_label", "ipam"), ("model", "prefix")),
|
|
34
|
+
models.Q(("app_label", "ipam"), ("model", "ipaddress")),
|
|
35
|
+
models.Q(
|
|
36
|
+
("app_label", "contenttypes"), ("model", "contenttype")
|
|
37
|
+
),
|
|
38
|
+
models.Q(("app_label", "tenancy"), ("model", "tenant")),
|
|
39
|
+
models.Q(("app_label", "dcim"), ("model", "inventoryitem")),
|
|
40
|
+
_connector="OR",
|
|
41
|
+
)
|
|
42
|
+
),
|
|
43
|
+
on_delete=django.db.models.deletion.PROTECT,
|
|
44
|
+
related_name="+",
|
|
45
|
+
to="contenttypes.contenttype",
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
]
|
|
File without changes
|