Rack groups have been renamed to locations

This commit is contained in:
Tobias Genannt 2021-04-07 09:15:21 +02:00
parent 9ab202f921
commit 5944086435
6 changed files with 10 additions and 10 deletions

View File

@ -2,4 +2,4 @@
# site: AMS 1 # site: AMS 1
# - name: power panel SING 1 # - name: power panel SING 1
# site: SING 1 # site: SING 1
# rack_group: cage 101 # location: cage 101

View File

@ -32,7 +32,7 @@
# text_field: Description # text_field: Description
# - site: SING 1 # - site: SING 1
# name: rack-03 # name: rack-03
# group: cage 101 # location: cage 101
# role: Role 3 # role: Role 3
# type: 4-post-cabinet # type: 4-post-cabinet
# width: 19 # width: 19

View File

@ -1,9 +1,9 @@
import sys import sys
from dcim.models import RackGroup, Site from dcim.models import Location, Site
from startup_script_utils import load_yaml 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: if rack_groups is None:
sys.exit() sys.exit()
@ -17,7 +17,7 @@ for params in rack_groups:
query = {field: params.pop(assoc)} query = {field: params.pop(assoc)}
params[assoc] = model.objects.get(**query) 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: if created:
print("🎨 Created rack group", rack_group.name) print("🎨 Created location", location.name)

View File

@ -1,6 +1,6 @@
import sys 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 startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
from tenancy.models import Tenant from tenancy.models import Tenant
@ -14,7 +14,7 @@ required_assocs = {"site": (Site, "name")}
optional_assocs = { optional_assocs = {
"role": (RackRole, "name"), "role": (RackRole, "name"),
"tenant": (Tenant, "name"), "tenant": (Tenant, "name"),
"group": (RackGroup, "name"), "location": (Location, "name"),
} }
for params in racks: for params in racks:

View File

@ -1,6 +1,6 @@
import sys 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 from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
power_panels = load_yaml("/opt/netbox/initializers/power_panels.yml") power_panels = load_yaml("/opt/netbox/initializers/power_panels.yml")
@ -10,7 +10,7 @@ if power_panels is None:
required_assocs = {"site": (Site, "name")} required_assocs = {"site": (Site, "name")}
optional_assocs = {"rack_group": (RackGroup, "name")} optional_assocs = {"location": (Location, "name")}
for params in power_panels: for params in power_panels:
custom_field_data = pop_custom_fields(params) custom_field_data = pop_custom_fields(params)