Skip to content

Commit 4a58676

Browse files
committed
Update Device Initializer for Netbox 2.7
The device database model has changed in Netbox 2.7. Therefore the initializer code, that was used before, broke. As a user, you will need to update your devices.yml file as follows: - Make sure the rack face is spelled lowercase. See the diff of this commit for further information how this is meant.
1 parent 7b914d3 commit 4a58676

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

initializers/devices.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
## Possible Choices:
2+
## face:
3+
## - front
4+
## - rear
5+
## status:
6+
## - offline
7+
## - active
8+
## - planned
9+
## - staged
10+
## - failed
11+
## - inventory
12+
## - decommissioning
13+
##
14+
## Examples:
15+
116
# - name: server01
217
# device_role: server
318
# device_type: Other
419
# site: AMS 1
520
# rack: rack-01
6-
# face: Front
21+
# face: front
722
# position: 1
823
# custom_fields:
924
# text_field: Description
@@ -12,7 +27,7 @@
1227
# device_type: Other
1328
# site: AMS 2
1429
# rack: rack-02
15-
# face: Front
30+
# face: front
1631
# position: 2
1732
# custom_fields:
1833
# text_field: Description
@@ -21,7 +36,7 @@
2136
# device_type: Other
2237
# site: SING 1
2338
# rack: rack-03
24-
# face: Front
39+
# face: front
2540
# position: 3
2641
# custom_fields:
2742
# text_field: Description

startup_scripts/130_devices.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dcim.models import Site, Rack, DeviceRole, DeviceType, Device, Platform
2-
from dcim.constants import RACK_FACE_CHOICES
32
from ipam.models import IPAddress
43
from virtualization.models import Cluster
54
from tenancy.models import Tenant
@@ -49,12 +48,6 @@
4948

5049
params[assoc] = model.objects.get(**query)
5150

52-
if 'face' in params:
53-
for rack_face in RACK_FACE_CHOICES:
54-
if params['face'] in rack_face:
55-
params['face'] = rack_face[0]
56-
break
57-
5851
device, created = Device.objects.get_or_create(**params)
5952

6053
if created:

0 commit comments

Comments
 (0)