From 594408643525e1bdaa5e74e5f18959d9890ca2e3 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Wed, 7 Apr 2021 09:15:21 +0200 Subject: [PATCH] Rack groups have been renamed to locations --- initializers/{rack_groups.yml => locations.yml} | 0 initializers/power_panels.yml | 2 +- initializers/racks.yml | 2 +- startup_scripts/{075_rack_groups.py => 075_locations.py} | 8 ++++---- startup_scripts/080_racks.py | 4 ++-- startup_scripts/330_power_panels.py | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) rename initializers/{rack_groups.yml => locations.yml} (100%) rename startup_scripts/{075_rack_groups.py => 075_locations.py} (60%) diff --git a/initializers/rack_groups.yml b/initializers/locations.yml similarity index 100% rename from initializers/rack_groups.yml rename to initializers/locations.yml diff --git a/initializers/power_panels.yml b/initializers/power_panels.yml index 1205851..a670ba7 100644 --- a/initializers/power_panels.yml +++ b/initializers/power_panels.yml @@ -2,4 +2,4 @@ # site: AMS 1 # - name: power panel SING 1 # site: SING 1 -# rack_group: cage 101 +# location: cage 101 diff --git a/initializers/racks.yml b/initializers/racks.yml index 379553d..9071e19 100644 --- a/initializers/racks.yml +++ b/initializers/racks.yml @@ -32,7 +32,7 @@ # text_field: Description # - site: SING 1 # name: rack-03 -# group: cage 101 +# location: cage 101 # role: Role 3 # type: 4-post-cabinet # width: 19 diff --git a/startup_scripts/075_rack_groups.py b/startup_scripts/075_locations.py similarity index 60% rename from startup_scripts/075_rack_groups.py rename to startup_scripts/075_locations.py index 3974b56..d8a2c5a 100644 --- a/startup_scripts/075_rack_groups.py +++ b/startup_scripts/075_locations.py @@ -1,9 +1,9 @@ import sys -from dcim.models import RackGroup, Site +from dcim.models import Location, Site from startup_script_utils import load_yaml -rack_groups = load_yaml("/opt/netbox/initializers/rack_groups.yml") +rack_groups = load_yaml("/opt/netbox/initializers/locations.yml") if rack_groups is None: sys.exit() @@ -17,7 +17,7 @@ for params in rack_groups: query = {field: params.pop(assoc)} params[assoc] = model.objects.get(**query) - rack_group, created = RackGroup.objects.get_or_create(**params) + location, created = Location.objects.get_or_create(**params) if created: - print("🎨 Created rack group", rack_group.name) + print("🎨 Created location", location.name) diff --git a/startup_scripts/080_racks.py b/startup_scripts/080_racks.py index 087b3f9..eb9bcf9 100644 --- a/startup_scripts/080_racks.py +++ b/startup_scripts/080_racks.py @@ -1,6 +1,6 @@ import sys -from dcim.models import Rack, RackGroup, RackRole, Site +from dcim.models import Rack, Location, RackRole, Site from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values from tenancy.models import Tenant @@ -14,7 +14,7 @@ required_assocs = {"site": (Site, "name")} optional_assocs = { "role": (RackRole, "name"), "tenant": (Tenant, "name"), - "group": (RackGroup, "name"), + "location": (Location, "name"), } for params in racks: diff --git a/startup_scripts/330_power_panels.py b/startup_scripts/330_power_panels.py index bfde18f..370a7b6 100644 --- a/startup_scripts/330_power_panels.py +++ b/startup_scripts/330_power_panels.py @@ -1,6 +1,6 @@ import sys -from dcim.models import PowerPanel, RackGroup, Site +from dcim.models import PowerPanel, Location, Site from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values power_panels = load_yaml("/opt/netbox/initializers/power_panels.yml") @@ -10,7 +10,7 @@ if power_panels is None: required_assocs = {"site": (Site, "name")} -optional_assocs = {"rack_group": (RackGroup, "name")} +optional_assocs = {"location": (Location, "name")} for params in power_panels: custom_field_data = pop_custom_fields(params)