Skip to content

Commit 7b914d3

Browse files
committed
Update Rack Initializer for Netbox 2.7
The rack 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 racks.yml file as follows: - Rack types must match one of the 5 rack types given, e.g. '4-post-cabinet'. - Rack width must match one of the 2 rack widths given, i.e. '19' or '23'. See the diff of this commit for further information how this is meant.
1 parent c001626 commit 7b914d3

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

initializers/racks.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
1+
## Possible Choices:
2+
## width:
3+
## - 19
4+
## - 23
5+
## types:
6+
## - 2-post-frame
7+
## - 4-post-frame
8+
## - 4-post-cabinet
9+
## - wall-frame
10+
## - wall-cabinet
11+
## outer_unit:
12+
## - mm
13+
## - in
14+
##
15+
## Examples:
16+
117
# - site: AMS 1
218
# name: rack-01
319
# role: Role 1
4-
# type: 4-post cabinet
5-
# width: 19 inches
20+
# type: 4-post-cabinet
21+
# width: 19
622
# u_height: 47
723
# custom_fields:
824
# text_field: Description
925
# - site: AMS 2
1026
# name: rack-02
1127
# role: Role 2
12-
# type: 4-post cabinet
13-
# width: 19 inches
28+
# type: 4-post-cabinet
29+
# width: 19
1430
# u_height: 47
1531
# custom_fields:
1632
# text_field: Description
1733
# - site: SING 1
1834
# name: rack-03
1935
# group: cage 101
2036
# role: Role 3
21-
# type: 4-post cabinet
22-
# width: 19 inches
37+
# type: 4-post-cabinet
38+
# width: 19
2339
# u_height: 47
2440
# custom_fields:
2541
# text_field: Description

startup_scripts/080_racks.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from dcim.models import Site, RackRole, Rack, RackGroup
22
from tenancy.models import Tenant
33
from extras.models import CustomField, CustomFieldValue
4-
from dcim.constants import RACK_TYPE_CHOICES, RACK_WIDTH_CHOICES
54
from ruamel.yaml import YAML
65
from pathlib import Path
76
import sys
@@ -41,14 +40,6 @@
4140

4241
params[assoc] = model.objects.get(**query)
4342

44-
for rack_type in RACK_TYPE_CHOICES:
45-
if params['type'] in rack_type:
46-
params['type'] = rack_type[0]
47-
48-
for rack_width in RACK_WIDTH_CHOICES:
49-
if params['width'] in rack_width:
50-
params['width'] = rack_width[0]
51-
5243
rack, created = Rack.objects.get_or_create(**params)
5344

5445
if created:

0 commit comments

Comments
 (0)