From 7b914d31d66f56bb9cf6ab8fbba131a23a6127a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=A4der?= Date: Fri, 17 Jan 2020 15:44:19 +0100 Subject: [PATCH] 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. --- initializers/racks.yml | 28 ++++++++++++++++++++++------ startup_scripts/080_racks.py | 9 --------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/initializers/racks.yml b/initializers/racks.yml index 3a31526..51502de 100644 --- a/initializers/racks.yml +++ b/initializers/racks.yml @@ -1,16 +1,32 @@ +## Possible Choices: +## width: +## - 19 +## - 23 +## types: +## - 2-post-frame +## - 4-post-frame +## - 4-post-cabinet +## - wall-frame +## - wall-cabinet +## outer_unit: +## - mm +## - in +## +## Examples: + # - site: AMS 1 # name: rack-01 # role: Role 1 -# type: 4-post cabinet -# width: 19 inches +# type: 4-post-cabinet +# width: 19 # u_height: 47 # custom_fields: # text_field: Description # - site: AMS 2 # name: rack-02 # role: Role 2 -# type: 4-post cabinet -# width: 19 inches +# type: 4-post-cabinet +# width: 19 # u_height: 47 # custom_fields: # text_field: Description @@ -18,8 +34,8 @@ # name: rack-03 # group: cage 101 # role: Role 3 -# type: 4-post cabinet -# width: 19 inches +# type: 4-post-cabinet +# width: 19 # u_height: 47 # custom_fields: # text_field: Description diff --git a/startup_scripts/080_racks.py b/startup_scripts/080_racks.py index 05bca10..ed7713d 100644 --- a/startup_scripts/080_racks.py +++ b/startup_scripts/080_racks.py @@ -1,7 +1,6 @@ from dcim.models import Site, RackRole, Rack, RackGroup from tenancy.models import Tenant from extras.models import CustomField, CustomFieldValue -from dcim.constants import RACK_TYPE_CHOICES, RACK_WIDTH_CHOICES from ruamel.yaml import YAML from pathlib import Path import sys @@ -41,14 +40,6 @@ with file.open('r') as stream: params[assoc] = model.objects.get(**query) - for rack_type in RACK_TYPE_CHOICES: - if params['type'] in rack_type: - params['type'] = rack_type[0] - - for rack_width in RACK_WIDTH_CHOICES: - if params['width'] in rack_width: - params['width'] = rack_width[0] - rack, created = Rack.objects.get_or_create(**params) if created: