ipfabric_netbox 3.1.2__py3-none-any.whl → 3.2.0__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.
@@ -8,6 +8,7 @@ from django.core import serializers
8
8
  from django.test import TestCase
9
9
  from django.utils import timezone
10
10
 
11
+ from ipfabric_netbox.choices import IPFabricSnapshotStatusModelChoices
11
12
  from ipfabric_netbox.models import IPFabricSnapshot
12
13
  from ipfabric_netbox.models import IPFabricSource
13
14
  from ipfabric_netbox.models import IPFabricSync
@@ -15,953 +16,9 @@ from ipfabric_netbox.models import IPFabricTransformField
15
16
  from ipfabric_netbox.models import IPFabricTransformMap
16
17
  from ipfabric_netbox.utilities.ipfutils import IPFabricSyncRunner
17
18
 
18
- transform_maps = [
19
- {
20
- "model": "ipfabric_netbox.ipfabrictransformmap",
21
- "pk": 4,
22
- "fields": {
23
- "created": "2023-06-22T09:12:03.018Z",
24
- "last_updated": "2023-06-22T09:12:03.018Z",
25
- "custom_field_data": {},
26
- "name": "Platform Transform Map",
27
- "source_model": "device",
28
- "target_model": 43,
29
- "status": "",
30
- },
31
- },
32
- {
33
- "model": "ipfabric_netbox.ipfabrictransformmap",
34
- "pk": 1,
35
- "fields": {
36
- "created": "2023-06-22T09:12:02.886Z",
37
- "last_updated": "2023-06-22T09:53:32.100Z",
38
- "custom_field_data": {},
39
- "name": "Site Transform Map",
40
- "source_model": "site",
41
- "target_model": 56,
42
- "status": "active",
43
- },
44
- },
45
- {
46
- "model": "ipfabric_netbox.ipfabrictransformmap",
47
- "pk": 2,
48
- "fields": {
49
- "created": "2023-06-22T09:12:02.924Z",
50
- "last_updated": "2023-06-22T15:02:20.038Z",
51
- "custom_field_data": {},
52
- "name": "Manufacturer Transform Map",
53
- "source_model": "device",
54
- "target_model": 42,
55
- "status": "",
56
- },
57
- },
58
- {
59
- "model": "ipfabric_netbox.ipfabrictransformmap",
60
- "pk": 5,
61
- "fields": {
62
- "created": "2023-06-22T09:12:03.087Z",
63
- "last_updated": "2023-06-22T15:51:28.987Z",
64
- "custom_field_data": {},
65
- "name": "Device Transform Map",
66
- "source_model": "device",
67
- "target_model": 31,
68
- "status": "active",
69
- },
70
- },
71
- {
72
- "model": "ipfabric_netbox.ipfabrictransformmap",
73
- "pk": 6,
74
- "fields": {
75
- "created": "2023-06-22T09:12:03.134Z",
76
- "last_updated": "2023-06-22T16:24:22.879Z",
77
- "custom_field_data": {},
78
- "name": "Device Role Transform Map",
79
- "source_model": "device",
80
- "target_model": 34,
81
- "status": "",
82
- },
83
- },
84
- {
85
- "model": "ipfabric_netbox.ipfabrictransformmap",
86
- "pk": 3,
87
- "fields": {
88
- "created": "2023-06-22T09:12:02.971Z",
89
- "last_updated": "2023-06-23T13:23:50.445Z",
90
- "custom_field_data": {},
91
- "name": "Device Type Transform Map",
92
- "source_model": "device",
93
- "target_model": 35,
94
- "status": "",
95
- },
96
- },
97
- {
98
- "model": "ipfabric_netbox.ipfabrictransformmap",
99
- "pk": 10,
100
- "fields": {
101
- "created": "2023-06-23T14:42:40.118Z",
102
- "last_updated": "2023-06-23T14:42:40.118Z",
103
- "custom_field_data": {},
104
- "name": "Interface Transform Map",
105
- "source_model": "interface",
106
- "target_model": 38,
107
- "status": "",
108
- },
109
- },
110
- {
111
- "model": "ipfabric_netbox.ipfabrictransformmap",
112
- "pk": 11,
113
- "fields": {
114
- "created": "2023-06-28T15:13:56.033Z",
115
- "last_updated": "2023-06-28T15:18:37.423Z",
116
- "custom_field_data": {},
117
- "name": "Inventory Transform Map",
118
- "source_model": "part_number",
119
- "target_model": 40,
120
- "status": "",
121
- },
122
- },
123
- {
124
- "model": "ipfabric_netbox.ipfabrictransformmap",
125
- "pk": 12,
126
- "fields": {
127
- "created": "2023-07-14T15:37:25.428Z",
128
- "last_updated": "2023-07-14T15:37:25.428Z",
129
- "custom_field_data": {},
130
- "name": "VLAN Transform Map",
131
- "source_model": "vlan",
132
- "target_model": 75,
133
- "status": "active",
134
- },
135
- },
136
- {
137
- "model": "ipfabric_netbox.ipfabrictransformmap",
138
- "pk": 13,
139
- "fields": {
140
- "created": "2023-07-14T16:39:14.674Z",
141
- "last_updated": "2023-07-14T16:39:14.675Z",
142
- "custom_field_data": {},
143
- "name": "VRF Transform Map",
144
- "source_model": "vrf",
145
- "target_model": 73,
146
- "status": "",
147
- },
148
- },
149
- {
150
- "model": "ipfabric_netbox.ipfabrictransformmap",
151
- "pk": 14,
152
- "fields": {
153
- "created": "2023-07-18T09:36:57.588Z",
154
- "last_updated": "2023-07-18T09:36:57.588Z",
155
- "custom_field_data": {},
156
- "name": "Prefix Transform Map",
157
- "source_model": "prefix",
158
- "target_model": 69,
159
- "status": "active",
160
- },
161
- },
162
- {
163
- "model": "ipfabric_netbox.ipfabrictransformmap",
164
- "pk": 15,
165
- "fields": {
166
- "created": "2023-07-31T10:54:29.792Z",
167
- "last_updated": "2023-07-31T10:54:29.792Z",
168
- "custom_field_data": {},
169
- "name": "Virtual Chassis Transform Map",
170
- "source_model": "virtualchassis",
171
- "target_model": 58,
172
- "status": "",
173
- },
174
- },
175
- {
176
- "model": "ipfabric_netbox.ipfabrictransformmap",
177
- "pk": 16,
178
- "fields": {
179
- "created": "2023-08-15T14:34:00.334Z",
180
- "last_updated": "2023-08-15T14:34:00.334Z",
181
- "custom_field_data": {},
182
- "name": "IP Address Transform Map",
183
- "source_model": "ipaddress",
184
- "target_model": 68,
185
- "status": "active",
186
- },
187
- },
188
- ]
189
-
190
- transform_fields = [
191
- {
192
- "model": "ipfabric_netbox.ipfabrictransformfield",
193
- "pk": 19,
194
- "fields": {
195
- "created": "2023-06-23T15:01:13.459Z",
196
- "last_updated": "2023-06-23T15:01:13.459Z",
197
- "custom_field_data": {},
198
- "description": "",
199
- "comments": "",
200
- "transform_map": 10,
201
- "source_field": "dscr",
202
- "target_field": "description",
203
- "coalesce": False,
204
- "template": '{{ object.dscr or ""}}',
205
- },
206
- },
207
- {
208
- "model": "ipfabric_netbox.ipfabrictransformfield",
209
- "pk": 20,
210
- "fields": {
211
- "created": "2023-06-28T10:39:24.588Z",
212
- "last_updated": "2023-06-28T10:39:24.588Z",
213
- "custom_field_data": {},
214
- "description": "",
215
- "comments": "",
216
- "transform_map": 10,
217
- "source_field": "media",
218
- "target_field": "type",
219
- "coalesce": False,
220
- "template": "1000base-t",
221
- },
222
- },
223
- {
224
- "model": "ipfabric_netbox.ipfabrictransformfield",
225
- "pk": 2,
226
- "fields": {
227
- "created": "2023-06-22T09:12:02.900Z",
228
- "last_updated": "2023-06-22T09:12:02.900Z",
229
- "custom_field_data": {},
230
- "description": "",
231
- "comments": "",
232
- "transform_map": 1,
233
- "source_field": "siteName",
234
- "target_field": "slug",
235
- "coalesce": True,
236
- "template": "{{ object.siteName | slugify }}",
237
- },
238
- },
239
- {
240
- "model": "ipfabric_netbox.ipfabrictransformfield",
241
- "pk": 3,
242
- "fields": {
243
- "created": "2023-06-22T09:12:02.933Z",
244
- "last_updated": "2023-06-22T09:12:02.933Z",
245
- "custom_field_data": {},
246
- "description": "",
247
- "comments": "",
248
- "transform_map": 2,
249
- "source_field": "vendor",
250
- "target_field": "name",
251
- "coalesce": False,
252
- "template": None,
253
- },
254
- },
255
- {
256
- "model": "ipfabric_netbox.ipfabrictransformfield",
257
- "pk": 25,
258
- "fields": {
259
- "created": "2023-06-28T10:46:04.153Z",
260
- "last_updated": "2023-06-28T10:46:04.153Z",
261
- "custom_field_data": {},
262
- "description": "",
263
- "comments": "",
264
- "transform_map": 10,
265
- "source_field": "l1",
266
- "target_field": "enabled",
267
- "coalesce": False,
268
- "template": '{% if object.l1 == "up" %}True{% else %}False{% endif %}',
269
- },
270
- },
271
- {
272
- "model": "ipfabric_netbox.ipfabrictransformfield",
273
- "pk": 34,
274
- "fields": {
275
- "created": "2023-07-14T15:38:30.728Z",
276
- "last_updated": "2023-07-31T10:37:21.182Z",
277
- "custom_field_data": {},
278
- "description": "",
279
- "comments": "",
280
- "transform_map": 12,
281
- "source_field": "vlanName",
282
- "target_field": "name",
283
- "coalesce": False,
284
- "template": '{{ object.vlanName or ""}}',
285
- },
286
- },
287
- {
288
- "model": "ipfabric_netbox.ipfabrictransformfield",
289
- "pk": 40,
290
- "fields": {
291
- "created": "2023-07-31T15:07:09.911Z",
292
- "last_updated": "2023-07-31T15:07:09.911Z",
293
- "custom_field_data": {},
294
- "description": "",
295
- "comments": "",
296
- "transform_map": 15,
297
- "source_field": "master",
298
- "target_field": "name",
299
- "coalesce": True,
300
- "template": "",
301
- },
302
- },
303
- {
304
- "model": "ipfabric_netbox.ipfabrictransformfield",
305
- "pk": 22,
306
- "fields": {
307
- "created": "2023-06-28T10:41:47.345Z",
308
- "last_updated": "2023-06-28T12:08:47.704Z",
309
- "custom_field_data": {},
310
- "description": "",
311
- "comments": "",
312
- "transform_map": 10,
313
- "source_field": "mac",
314
- "target_field": "mac_address",
315
- "coalesce": False,
316
- "template": '{% if object.mac %}{{ object.mac | mac_to_format(frmt="MAC_COLON_TWO") | upper }}{% else %}{{ "00:00:00:00:00:01" | mac_to_format(frmt="MAC_COLON_TWO") | upper }}{% endif %}',
317
- },
318
- },
319
- {
320
- "model": "ipfabric_netbox.ipfabrictransformfield",
321
- "pk": 4,
322
- "fields": {
323
- "created": "2023-06-22T09:12:02.948Z",
324
- "last_updated": "2023-06-22T09:12:02.948Z",
325
- "custom_field_data": {},
326
- "description": "",
327
- "comments": "",
328
- "transform_map": 2,
329
- "source_field": "vendor",
330
- "target_field": "slug",
331
- "coalesce": True,
332
- "template": "{{ object.vendor | slugify }}",
333
- },
334
- },
335
- {
336
- "model": "ipfabric_netbox.ipfabrictransformfield",
337
- "pk": 8,
338
- "fields": {
339
- "created": "2023-06-22T09:12:03.043Z",
340
- "last_updated": "2023-07-14T10:54:57.940Z",
341
- "custom_field_data": {},
342
- "description": "",
343
- "comments": "",
344
- "transform_map": 4,
345
- "source_field": "vendor",
346
- "target_field": "slug",
347
- "coalesce": True,
348
- "template": "{{ object.vendor | slugify }}{%if object.family %}_{{ object.family | slugify }}{% endif %}",
349
- },
350
- },
351
- {
352
- "model": "ipfabric_netbox.ipfabrictransformfield",
353
- "pk": 6,
354
- "fields": {
355
- "created": "2023-06-22T09:12:02.995Z",
356
- "last_updated": "2023-06-22T09:12:02.995Z",
357
- "custom_field_data": {},
358
- "description": "",
359
- "comments": "",
360
- "transform_map": 3,
361
- "source_field": "vendor",
362
- "target_field": "slug",
363
- "coalesce": True,
364
- "template": "{{ object.vendor | slugify }}",
365
- },
366
- },
367
- {
368
- "model": "ipfabric_netbox.ipfabrictransformfield",
369
- "pk": 26,
370
- "fields": {
371
- "created": "2023-06-28T10:49:23.845Z",
372
- "last_updated": "2023-06-28T14:50:04.953Z",
373
- "custom_field_data": {},
374
- "description": "",
375
- "comments": "",
376
- "transform_map": 10,
377
- "source_field": "intName",
378
- "target_field": "name",
379
- "coalesce": True,
380
- "template": "",
381
- },
382
- },
383
- {
384
- "model": "ipfabric_netbox.ipfabrictransformfield",
385
- "pk": 28,
386
- "fields": {
387
- "created": "2023-06-28T15:20:02.726Z",
388
- "last_updated": "2023-06-28T15:20:08.343Z",
389
- "custom_field_data": {},
390
- "description": "",
391
- "comments": "",
392
- "transform_map": 11,
393
- "source_field": "sn",
394
- "target_field": "serial",
395
- "coalesce": True,
396
- "template": "",
397
- },
398
- },
399
- {
400
- "model": "ipfabric_netbox.ipfabrictransformfield",
401
- "pk": 29,
402
- "fields": {
403
- "created": "2023-06-28T15:20:22.262Z",
404
- "last_updated": "2023-06-28T15:20:22.262Z",
405
- "custom_field_data": {},
406
- "description": "",
407
- "comments": "",
408
- "transform_map": 11,
409
- "source_field": "pid",
410
- "target_field": "part_id",
411
- "coalesce": False,
412
- "template": "",
413
- },
414
- },
415
- {
416
- "model": "ipfabric_netbox.ipfabrictransformfield",
417
- "pk": 7,
418
- "fields": {
419
- "created": "2023-06-22T09:12:03.027Z",
420
- "last_updated": "2023-07-14T10:56:34.746Z",
421
- "custom_field_data": {},
422
- "description": "",
423
- "comments": "",
424
- "transform_map": 4,
425
- "source_field": "family",
426
- "target_field": "name",
427
- "coalesce": False,
428
- "template": "{%if object.family %}{{ object.family | slugify }}{% else %}{{ object.vendor }}{% endif %}",
429
- },
430
- },
431
- {
432
- "model": "ipfabric_netbox.ipfabrictransformfield",
433
- "pk": 35,
434
- "fields": {
435
- "created": "2023-07-14T15:38:43.642Z",
436
- "last_updated": "2023-07-14T15:39:37.833Z",
437
- "custom_field_data": {},
438
- "description": "",
439
- "comments": "",
440
- "transform_map": 12,
441
- "source_field": "vlanId",
442
- "target_field": "vid",
443
- "coalesce": True,
444
- "template": "",
445
- },
446
- },
447
- {
448
- "model": "ipfabric_netbox.ipfabrictransformfield",
449
- "pk": 36,
450
- "fields": {
451
- "created": "2023-07-14T15:39:00.515Z",
452
- "last_updated": "2023-07-14T15:57:48.819Z",
453
- "custom_field_data": {},
454
- "description": "",
455
- "comments": "",
456
- "transform_map": 12,
457
- "source_field": "dscr",
458
- "target_field": "description",
459
- "coalesce": False,
460
- "template": '{{ object.dscr or ""}}',
461
- },
462
- },
463
- {
464
- "model": "ipfabric_netbox.ipfabrictransformfield",
465
- "pk": 11,
466
- "fields": {
467
- "created": "2023-06-22T09:12:03.112Z",
468
- "last_updated": "2023-06-22T09:12:03.112Z",
469
- "custom_field_data": {},
470
- "description": "",
471
- "comments": "",
472
- "transform_map": 5,
473
- "source_field": "sn",
474
- "target_field": "serial",
475
- "coalesce": True,
476
- "template": "{{ object | serial }}",
477
- },
478
- },
479
- {
480
- "model": "ipfabric_netbox.ipfabrictransformfield",
481
- "pk": 37,
482
- "fields": {
483
- "created": "2023-07-14T16:39:34.015Z",
484
- "last_updated": "2023-07-14T16:39:34.015Z",
485
- "custom_field_data": {},
486
- "description": "",
487
- "comments": "",
488
- "transform_map": 13,
489
- "source_field": "vrf",
490
- "target_field": "name",
491
- "coalesce": True,
492
- "template": "",
493
- },
494
- },
495
- {
496
- "model": "ipfabric_netbox.ipfabrictransformfield",
497
- "pk": 21,
498
- "fields": {
499
- "created": "2023-06-28T10:41:03.607Z",
500
- "last_updated": "2023-08-08T14:44:52.118Z",
501
- "custom_field_data": {},
502
- "description": "",
503
- "comments": "",
504
- "transform_map": 10,
505
- "source_field": "mtu",
506
- "target_field": "mtu",
507
- "coalesce": False,
508
- "template": "{{ object.mtu or 1500 }}",
509
- },
510
- },
511
- {
512
- "model": "ipfabric_netbox.ipfabrictransformfield",
513
- "pk": 38,
514
- "fields": {
515
- "created": "2023-07-14T16:39:57.563Z",
516
- "last_updated": "2023-07-14T16:44:39.864Z",
517
- "custom_field_data": {},
518
- "description": "",
519
- "comments": "",
520
- "transform_map": 13,
521
- "source_field": "rd",
522
- "target_field": "rd",
523
- "coalesce": True,
524
- "template": "",
525
- },
526
- },
527
- {
528
- "model": "ipfabric_netbox.ipfabrictransformfield",
529
- "pk": 42,
530
- "fields": {
531
- "created": "2023-08-09T12:31:17.235Z",
532
- "last_updated": "2023-08-09T12:31:17.235Z",
533
- "custom_field_data": {},
534
- "description": "",
535
- "comments": "",
536
- "transform_map": 5,
537
- "source_field": "hostname",
538
- "target_field": "vc_position",
539
- "coalesce": False,
540
- "template": "{% if object.virtual_chassis is defined %}{{ object.virtual_chassis.member }}{% else %}None{% endif %}",
541
- },
542
- },
543
- {
544
- "model": "ipfabric_netbox.ipfabrictransformfield",
545
- "pk": 10,
546
- "fields": {
547
- "created": "2023-06-22T09:12:03.095Z",
548
- "last_updated": "2023-08-14T09:56:03.044Z",
549
- "custom_field_data": {},
550
- "description": "",
551
- "comments": "",
552
- "transform_map": 5,
553
- "source_field": "hostname",
554
- "target_field": "name",
555
- "coalesce": False,
556
- "template": "",
557
- },
558
- },
559
- {
560
- "model": "ipfabric_netbox.ipfabrictransformfield",
561
- "pk": 1,
562
- "fields": {
563
- "created": "2023-06-22T09:12:02.889Z",
564
- "last_updated": "2023-07-17T10:08:24.194Z",
565
- "custom_field_data": {},
566
- "description": "",
567
- "comments": "",
568
- "transform_map": 1,
569
- "source_field": "siteName",
570
- "target_field": "name",
571
- "coalesce": False,
572
- "template": "",
573
- },
574
- },
575
- {
576
- "model": "ipfabric_netbox.ipfabrictransformfield",
577
- "pk": 27,
578
- "fields": {
579
- "created": "2023-06-28T15:19:45.005Z",
580
- "last_updated": "2023-06-28T16:18:37.860Z",
581
- "custom_field_data": {},
582
- "description": "",
583
- "comments": "",
584
- "transform_map": 11,
585
- "source_field": "name",
586
- "target_field": "name",
587
- "coalesce": False,
588
- "template": "{% if object.name is not none %}{{ object.name }}{% elif object.dscr is not none %}{{ object.dscr}}{% else %}Default Name{% endif %}",
589
- },
590
- },
591
- {
592
- "model": "ipfabric_netbox.ipfabrictransformfield",
593
- "pk": 12,
594
- "fields": {
595
- "created": "2023-06-22T09:12:03.144Z",
596
- "last_updated": "2023-06-22T16:24:30.681Z",
597
- "custom_field_data": {},
598
- "description": "",
599
- "comments": "",
600
- "transform_map": 6,
601
- "source_field": "devType",
602
- "target_field": "name",
603
- "coalesce": False,
604
- "template": "",
605
- },
606
- },
607
- {
608
- "model": "ipfabric_netbox.ipfabrictransformfield",
609
- "pk": 13,
610
- "fields": {
611
- "created": "2023-06-22T09:12:03.161Z",
612
- "last_updated": "2023-06-22T16:24:34.880Z",
613
- "custom_field_data": {},
614
- "description": "",
615
- "comments": "",
616
- "transform_map": 6,
617
- "source_field": "devType",
618
- "target_field": "slug",
619
- "coalesce": True,
620
- "template": "{{ object.devType | slugify }}",
621
- },
622
- },
623
- {
624
- "model": "ipfabric_netbox.ipfabrictransformfield",
625
- "pk": 39,
626
- "fields": {
627
- "created": "2023-07-18T09:40:37.112Z",
628
- "last_updated": "2023-07-18T09:41:09.238Z",
629
- "custom_field_data": {},
630
- "description": "",
631
- "comments": "",
632
- "transform_map": 14,
633
- "source_field": "net",
634
- "target_field": "prefix",
635
- "coalesce": True,
636
- "template": "",
637
- },
638
- },
639
- {
640
- "model": "ipfabric_netbox.ipfabrictransformfield",
641
- "pk": 43,
642
- "fields": {
643
- "created": "2023-08-15T14:25:31.706Z",
644
- "last_updated": "2023-08-15T14:25:31.706Z",
645
- "custom_field_data": {},
646
- "description": "",
647
- "comments": "",
648
- "transform_map": 10,
649
- "source_field": "primaryIp",
650
- "target_field": "mgmt_only",
651
- "coalesce": False,
652
- "template": "{% if object.primaryIp == object.loginIp %}True{% else %}False{% endif %}",
653
- },
654
- },
655
- {
656
- "model": "ipfabric_netbox.ipfabrictransformfield",
657
- "pk": 5,
658
- "fields": {
659
- "created": "2023-06-22T09:12:02.979Z",
660
- "last_updated": "2023-07-14T13:51:37.370Z",
661
- "custom_field_data": {},
662
- "description": "",
663
- "comments": "",
664
- "transform_map": 3,
665
- "source_field": "model",
666
- "target_field": "model",
667
- "coalesce": False,
668
- "template": '{% if object.model|string != ""%}{{ object.model | string }}{% else %}{{ object.vendor }} - {{ object.family }} - {{ object.platform }}{% endif %}',
669
- },
670
- },
671
- {
672
- "model": "ipfabric_netbox.ipfabrictransformfield",
673
- "pk": 14,
674
- "fields": {
675
- "created": "2023-06-22T09:12:03.177Z",
676
- "last_updated": "2023-06-22T16:24:48.259Z",
677
- "custom_field_data": {},
678
- "description": "",
679
- "comments": "",
680
- "transform_map": 6,
681
- "source_field": "devType",
682
- "target_field": "vm_role",
683
- "coalesce": True,
684
- "template": "False",
685
- },
686
- },
687
- {
688
- "model": "ipfabric_netbox.ipfabrictransformfield",
689
- "pk": 44,
690
- "fields": {
691
- "created": "2023-08-15T14:38:13.622Z",
692
- "last_updated": "2023-08-15T20:12:45.341Z",
693
- "custom_field_data": {},
694
- "description": "",
695
- "comments": "",
696
- "transform_map": 16,
697
- "source_field": "sn",
698
- "target_field": "assigned_object_id",
699
- "coalesce": False,
700
- "template": "{{ dcim.Interface.objects.filter(device__serial=object.sn, name=object.intName).first().pk }}",
701
- },
702
- },
703
- {
704
- "model": "ipfabric_netbox.ipfabrictransformfield",
705
- "pk": 45,
706
- "fields": {
707
- "created": "2023-08-15T14:59:24.131Z",
708
- "last_updated": "2023-08-15T20:26:08.071Z",
709
- "custom_field_data": {},
710
- "description": "",
711
- "comments": "",
712
- "transform_map": 16,
713
- "source_field": "net",
714
- "target_field": "address",
715
- "coalesce": True,
716
- "template": "{% if object.net %}{% set MASK = object.net.split('/')[1] %}{% else %}{% set MASK = 32 %}{% endif %}{{ object.ip }}/{{MASK}}",
717
- },
718
- },
719
- ]
720
-
721
- transform_relationship_fields = [
722
- {
723
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
724
- "pk": 21,
725
- "fields": {
726
- "created": "2023-07-31T19:48:34.485Z",
727
- "last_updated": "2023-08-09T10:41:49.273Z",
728
- "custom_field_data": {},
729
- "transform_map": 15,
730
- "source_model": 31,
731
- "target_field": "master",
732
- "coalesce": False,
733
- "template": "{{ dcim.Device.objects.filter(serial=object.sn).first().pk }}",
734
- },
735
- },
736
- {
737
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
738
- "pk": 3,
739
- "fields": {
740
- "created": "2023-06-23T11:01:56.160Z",
741
- "last_updated": "2023-06-23T11:04:55.366Z",
742
- "custom_field_data": {},
743
- "transform_map": 5,
744
- "source_model": 43,
745
- "target_field": "platform",
746
- "coalesce": False,
747
- "template": None,
748
- },
749
- },
750
- {
751
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
752
- "pk": 4,
753
- "fields": {
754
- "created": "2023-06-23T11:05:37.165Z",
755
- "last_updated": "2023-06-23T11:05:37.165Z",
756
- "custom_field_data": {},
757
- "transform_map": 5,
758
- "source_model": 56,
759
- "target_field": "site",
760
- "coalesce": False,
761
- "template": None,
762
- },
763
- },
764
- {
765
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
766
- "pk": 5,
767
- "fields": {
768
- "created": "2023-06-23T11:07:26.908Z",
769
- "last_updated": "2023-06-23T11:07:26.908Z",
770
- "custom_field_data": {},
771
- "transform_map": 5,
772
- "source_model": 35,
773
- "target_field": "device_type",
774
- "coalesce": False,
775
- "template": None,
776
- },
777
- },
778
- {
779
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
780
- "pk": 6,
781
- "fields": {
782
- "created": "2023-06-23T11:11:42.914Z",
783
- "last_updated": "2023-06-23T11:11:42.914Z",
784
- "custom_field_data": {},
785
- "transform_map": 5,
786
- "source_model": 34,
787
- "target_field": "device_role",
788
- "coalesce": False,
789
- "template": None,
790
- },
791
- },
792
- {
793
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
794
- "pk": 7,
795
- "fields": {
796
- "created": "2023-06-23T13:42:05.285Z",
797
- "last_updated": "2023-06-23T13:42:05.285Z",
798
- "custom_field_data": {},
799
- "transform_map": 3,
800
- "source_model": 42,
801
- "target_field": "manufacturer",
802
- "coalesce": False,
803
- "template": None,
804
- },
805
- },
806
- {
807
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
808
- "pk": 9,
809
- "fields": {
810
- "created": "2023-06-23T14:17:57.664Z",
811
- "last_updated": "2023-06-23T14:17:57.664Z",
812
- "custom_field_data": {},
813
- "transform_map": 4,
814
- "source_model": 42,
815
- "target_field": "manufacturer",
816
- "coalesce": False,
817
- "template": None,
818
- },
819
- },
820
- {
821
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
822
- "pk": 22,
823
- "fields": {
824
- "created": "2023-08-09T12:39:35.028Z",
825
- "last_updated": "2023-08-09T12:39:35.028Z",
826
- "custom_field_data": {},
827
- "transform_map": 5,
828
- "source_model": 58,
829
- "target_field": "virtual_chassis",
830
- "coalesce": False,
831
- "template": "{% if object.virtual_chassis is defined %}{{ dcim.VirtualChassis.objects.filter(name=object.virtual_chassis.master).first().pk }}{% endif %}",
832
- },
833
- },
834
- {
835
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
836
- "pk": 11,
837
- "fields": {
838
- "created": "2023-06-28T11:00:44.494Z",
839
- "last_updated": "2023-06-28T14:37:54.113Z",
840
- "custom_field_data": {},
841
- "transform_map": 10,
842
- "source_model": 31,
843
- "target_field": "device",
844
- "coalesce": True,
845
- "template": None,
846
- },
847
- },
848
- {
849
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
850
- "pk": 12,
851
- "fields": {
852
- "created": "2023-06-28T15:19:18.237Z",
853
- "last_updated": "2023-06-28T15:19:18.237Z",
854
- "custom_field_data": {},
855
- "transform_map": 11,
856
- "source_model": 42,
857
- "target_field": "manufacturer",
858
- "coalesce": False,
859
- "template": None,
860
- },
861
- },
862
- {
863
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
864
- "pk": 13,
865
- "fields": {
866
- "created": "2023-06-28T15:19:35.397Z",
867
- "last_updated": "2023-07-14T14:15:42.974Z",
868
- "custom_field_data": {},
869
- "transform_map": 11,
870
- "source_model": 31,
871
- "target_field": "device",
872
- "coalesce": False,
873
- "template": None,
874
- },
875
- },
876
- {
877
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
878
- "pk": 14,
879
- "fields": {
880
- "created": "2023-07-14T15:39:27.858Z",
881
- "last_updated": "2023-07-14T15:39:27.858Z",
882
- "custom_field_data": {},
883
- "transform_map": 12,
884
- "source_model": 56,
885
- "target_field": "site",
886
- "coalesce": True,
887
- "template": None,
888
- },
889
- },
890
- {
891
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
892
- "pk": 23,
893
- "fields": {
894
- "created": "2023-08-15T14:48:42.409Z",
895
- "last_updated": "2023-08-15T20:24:33.161Z",
896
- "custom_field_data": {},
897
- "transform_map": 16,
898
- "source_model": 5,
899
- "target_field": "assigned_object_type",
900
- "coalesce": False,
901
- "template": '{{ contenttypes.ContentType.objects.get(app_label="dcim", model="interface").pk }}',
902
- },
903
- },
904
- {
905
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
906
- "pk": 24,
907
- "fields": {
908
- "created": "2023-08-15T21:44:41.058Z",
909
- "last_updated": "2023-08-15T21:47:26.684Z",
910
- "custom_field_data": {},
911
- "transform_map": 16,
912
- "source_model": 73,
913
- "target_field": "vrf",
914
- "coalesce": False,
915
- "template": "{{ ipam.VRF.objects.filter(name=object.vrf).first().pk }}",
916
- },
917
- },
918
- {
919
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
920
- "pk": 15,
921
- "fields": {
922
- "created": "2023-07-18T09:40:50.275Z",
923
- "last_updated": "2023-08-15T21:53:36.179Z",
924
- "custom_field_data": {},
925
- "transform_map": 14,
926
- "source_model": 56,
927
- "target_field": "site",
928
- "coalesce": True,
929
- "template": "{% set SLUG = object.siteName | slugify %}\r\n{{ dcim.Site.objects.filter(slug=SLUG).first().pk }}",
930
- },
931
- },
932
- {
933
- "model": "ipfabric_netbox.ipfabricrelationshipfield",
934
- "pk": 17,
935
- "fields": {
936
- "created": "2023-07-18T21:19:36.757Z",
937
- "last_updated": "2023-07-18T21:19:44.148Z",
938
- "custom_field_data": {},
939
- "transform_map": 14,
940
- "source_model": 73,
941
- "target_field": "vrf",
942
- "coalesce": True,
943
- "template": "{{ ipam.VRF.objects.filter(name=object.vrf).first().pk }}",
944
- },
945
- },
946
- ]
947
-
948
19
 
949
20
  class IPFabricTransformMapModelTestCase(TestCase):
950
21
  def setUp(self):
951
- deserialized_tm = serializers.deserialize("json", json.dumps(transform_maps))
952
- for deserialized_object in deserialized_tm:
953
- deserialized_object.save()
954
-
955
- deserialized_tf = serializers.deserialize("json", json.dumps(transform_fields))
956
- for deserialized_object in deserialized_tf:
957
- deserialized_object.save()
958
-
959
- deserialized_trf = serializers.deserialize(
960
- "json", json.dumps(transform_relationship_fields)
961
- )
962
- for deserialized_object in deserialized_trf:
963
- deserialized_object.save()
964
-
965
22
  source = IPFabricSource.objects.create(
966
23
  name="test",
967
24
  url="https://localhost",
@@ -972,6 +29,7 @@ class IPFabricTransformMapModelTestCase(TestCase):
972
29
  name="S01 - Day 2 - IPF Lab - 02-Jul-21 06:29:16 - 12dd8c61-129c-431a-b98b-4c9211571f89",
973
30
  source=source,
974
31
  snapshot_id="12dd8c61-129c-431a-b98b-4c9211571f89",
32
+ status=IPFabricSnapshotStatusModelChoices.STATUS_LOADED,
975
33
  data={
976
34
  "end": "2021-07-02T06:29:16.311000Z",
977
35
  "name": "S01 - Day 2 - IPF Lab",
@@ -1035,14 +93,14 @@ class IPFabricTransformMapModelTestCase(TestCase):
1035
93
  {"count": 1, "error_type": "ABWorkerAuthError"},
1036
94
  ],
1037
95
  "locked": False,
1038
- "status": "done",
96
+ "status": "loaded",
1039
97
  "loading": False,
1040
98
  "version": "6.3.0-13",
1041
99
  "user_count": 2324,
1042
100
  "loaded_size": 170856074,
1043
101
  "snapshot_id": "12dd8c61-129c-431a-b98b-4c9211571f89",
1044
102
  "from_archive": True,
1045
- "finish_status": "done",
103
+ "finish_status": "loaded",
1046
104
  "unloaded_size": 26914884,
1047
105
  "initial_version": "4.4.3+2",
1048
106
  "interface_count": 9608,
@@ -1162,7 +220,7 @@ class IPFabricTransformMapModelTestCase(TestCase):
1162
220
  "dcim", "platform", device_data, uuid=device_uuid
1163
221
  )
1164
222
 
1165
- self.device_role = runner.get_model_or_update(
223
+ self.role = runner.get_model_or_update(
1166
224
  "dcim", "devicerole", device_data, uuid=device_uuid
1167
225
  )
1168
226
 
@@ -1211,7 +269,9 @@ class IPFabricTransformMapModelTestCase(TestCase):
1211
269
  "fields": {
1212
270
  "name": "Site Transform Map",
1213
271
  "source_model": "site",
1214
- "target_model": 56,
272
+ "target_model": ContentType.objects.get(
273
+ app_label="dcim", model="site"
274
+ ).pk,
1215
275
  "status": "active",
1216
276
  },
1217
277
  }
@@ -1268,7 +328,7 @@ class IPFabricTransformMapModelTestCase(TestCase):
1268
328
  self.assertEqual(device_object.name, "L21PE152")
1269
329
  self.assertEqual(device_object.serial, "a15ff98")
1270
330
  self.assertEqual(device_object.platform, self.platform)
1271
- self.assertEqual(device_object.device_role, self.device_role)
331
+ self.assertEqual(device_object.role, self.role)
1272
332
  self.assertEqual(device_object.device_type, self.dt_obj)
1273
333
  self.assertEqual(device_object.device_type.manufacturer, self.mf_obj)
1274
334
  self.assertEqual(device_object.site, self.site)
@@ -1331,7 +391,14 @@ class IPFabricTransformMapModelTestCase(TestCase):
1331
391
  "slug": None,
1332
392
  }
1333
393
 
1334
- transform_field = IPFabricTransformField.objects.get(pk=10)
394
+ transform_field = IPFabricTransformField.objects.get(
395
+ source_field="hostname",
396
+ target_field="name",
397
+ transform_map=IPFabricTransformMap.objects.get(
398
+ source_model="device",
399
+ target_model=ContentType.objects.get(app_label="dcim", model="device"),
400
+ ),
401
+ )
1335
402
  transform_field.template = "{{ object.hostname }} - test"
1336
403
  transform_field.save()
1337
404
  device_object = runner.get_model_or_update(