Add initializers to produce a single 6 wedge site with 9U lockers

This commit is contained in:
Marco Ceppi 2019-10-08 11:01:42 -04:00
parent 67cc069857
commit cb72054a1a
11 changed files with 569 additions and 149 deletions

View File

@ -1,15 +1,9 @@
# - name: switch
# slug: switch
# color: Grey
# - name: router
# slug: router
# color: Cyan
# - name: load-balancer
# slug: load-balancer
# color: Red
# - name: server
# slug: server
# color: Blue
# - name: patchpanel
# slug: patchpanel
# color: Black
- name: Access Switch
slug: access-switch
color: pink
- name: Customer Compute Locker
slug: customer-compute-locker
color: Light grey
- name: Customer Network Locker
slug: customer-network-locker
color: Dark grey

View File

@ -1,23 +1,25 @@
# - model: Model 1
# manufacturer: Manufacturer 1
# slug: model-1
# u_height: 2
# custom_fields:
# text_field: Description
# - model: Model 2
# manufacturer: Manufacturer 1
# slug: model-2
# custom_fields:
# text_field: Description
# - model: Model 3
# manufacturer: Manufacturer 1
# slug: model-3
# is_full_depth: false
# u_height: 0
# custom_fields:
# text_field: Description
# - model: Other
# manufacturer: NoName
# slug: other
# custom_fields:
# text_field: Description
- is_full_depth: 'True'
manufacturer: ASRock Inc.
model: IMB-1213
slug: asrock-imb-1213
u_height: 0
- is_full_depth: 'True'
manufacturer: Flex, LTD
model: 9U Locker
slug: 9u-locker
u_height: 9
- is_full_depth: 'True'
manufacturer: Juniper Networks, Inc
model: QFX5120-48Y-8C
slug: qfx5120-48y-8c
u_height: 1
- manufacturer: Vapor, IO
model: VEC Cartridge Rev 3.0
part_number: '700747'
slug: vec-cart-v3
u_height: 0
- manufacturer: Vapor, IO
model: VEC Sled v2
slug: vec-sled-v2
subdevice_role: True
u_height: 1

View File

@ -1,27 +1,267 @@
# - name: server01
# device_role: server
# device_type: Other
# site: AMS 1
# rack: rack-01
# face: Front
# position: 1
# custom_fields:
# text_field: Description
# - name: server02
# device_role: server
# device_type: Other
# site: AMS 2
# rack: rack-02
# face: Front
# position: 2
# custom_fields:
# text_field: Description
# - name: server03
# device_role: server
# device_type: Other
# site: SING 1
# rack: rack-03
# face: Front
# position: 3
# custom_fields:
# text_field: Description
- device_role: Access Switch
device_type: QFX5120-48Y-8C
name: EFR1.TEST0.GCP
site: Test Site (TEST0.GCP)
face: Front
- device_role: Access Switch
device_type: QFX5120-48Y-8C
name: EFR2.TEST0.GCP
face: Front
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L1A.W1.TEST0.GCP
position: 1
rack: W1 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L1B.W1.TEST0.GCP
position: 1
rack: W1 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L2A.W1.TEST0.GCP
position: 10
rack: W1 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L2B.W1.TEST0.GCP
position: 10
rack: W1 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L3A.W1.TEST0.GCP
position: 19
rack: W1 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L3B.W1.TEST0.GCP
position: 19
rack: W1 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L4A.W1.TEST0.GCP
position: 28
rack: W1 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L4B.W1.TEST0.GCP
position: 28
rack: W1 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L1A.W2.TEST0.GCP
position: 1
rack: W2 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L1B.W2.TEST0.GCP
position: 1
rack: W2 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L2A.W2.TEST0.GCP
position: 10
rack: W2 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L2B.W2.TEST0.GCP
position: 10
rack: W2 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L3A.W2.TEST0.GCP
position: 19
rack: W2 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L3B.W2.TEST0.GCP
position: 19
rack: W2 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L4A.W2.TEST0.GCP
position: 28
rack: W2 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L4B.W2.TEST0.GCP
position: 28
rack: W2 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L1A.W3.TEST0.GCP
position: 1
rack: W3 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L1B.W3.TEST0.GCP
position: 1
rack: W3 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L2A.W3.TEST0.GCP
position: 10
rack: W3 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L2B.W3.TEST0.GCP
position: 10
rack: W3 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L3A.W3.TEST0.GCP
position: 19
rack: W3 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L3B.W3.TEST0.GCP
position: 19
rack: W3 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L4A.W3.TEST0.GCP
position: 28
rack: W3 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L4B.W3.TEST0.GCP
position: 28
rack: W3 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L1A.W4.TEST0.GCP
position: 1
rack: W4 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L1B.W4.TEST0.GCP
position: 1
rack: W4 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L2A.W4.TEST0.GCP
position: 10
rack: W4 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L2B.W4.TEST0.GCP
position: 10
rack: W4 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L3A.W4.TEST0.GCP
position: 19
rack: W4 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L3B.W4.TEST0.GCP
position: 19
rack: W4 Zone B
site: Test Site (TEST0.GCP)
- device_role: Customer Compute Locker
face: Front
device_type: 9U Locker
name: L4A.W4.TEST0.GCP
position: 28
rack: W4 Zone A
site: Test Site (TEST0.GCP)
- device_role: Customer Network Locker
face: Front
device_type: 9U Locker
name: L4B.W4.TEST0.GCP
position: 28
rack: W4 Zone B
site: Test Site (TEST0.GCP)

View File

@ -1,6 +1,18 @@
# - name: Manufacturer 1
# slug: manufacturer-1
# - name: Manufacturer 2
# slug: manufacturer-2
# - name: NoName
# slug: noname
- name: ASRock Inc.
slug: asrock-inc
- name: BasX
slug: basx
- name: Eaton
slug: eaton
- name: eGauge Systems, LLC
slug: egauge-systems-llc
- name: Flex, LTD
slug: flex-ltd
- name: HID Global Corporation
slug: hid-global-corporation
- name: Juniper Networks, Inc
slug: juniper-networks-inc
- name: Ubiquiti Networks, Inc
slug: ubiquiti-networks-inc
- name: Vapor, IO
slug: vapor

View File

@ -0,0 +1,18 @@
- name: Rack 1
site: Test Site (TEST0.GCP)
slug: w1-c1-test0-gcp
- name: Rack 2
site: Test Site (TEST0.GCP)
slug: w2-c1-test0-gcp
- name: Rack 3
site: Test Site (TEST0.GCP)
slug: w3-c1-test0-gcp
- name: Rack 4
site: Test Site (TEST0.GCP)
slug: w4-c1-test0-gcp
- name: Rack 5
site: Test Site (TEST0.GCP)
slug: w5-c1-test0-gcp
- name: Rack 6
site: Test Site (TEST0.GCP)
slug: w6-c1-test0-gcp

View File

@ -1,12 +1,9 @@
# - name: Role 1
# slug: role-1
# color: Pink
# - name: Role 2
# slug: role-2
# color: Cyan
# - name: Role 3
# slug: role-3
# color: Grey
# - name: Role 4
# slug: role-4
# color: Teal
- color: 8bc34a
name: Customer
slug: customer
- color: 2196f3
name: Facility
slug: facility
- color: ff5722
name: Utility
slug: utility

View File

@ -1,24 +1,157 @@
# - site: AMS 1
# name: rack-01
# role: Role 1
# type: 4-post cabinet
# width: 19 inches
# u_height: 47
# custom_fields:
# text_field: Description
# - site: AMS 2
# name: rack-02
# role: Role 2
# type: 4-post cabinet
# width: 19 inches
# u_height: 47
# custom_fields:
# text_field: Description
# - site: SING 1
# name: rack-03
# role: Role 3
# type: 4-post cabinet
# width: 19 inches
# u_height: 47
# custom_fields:
# text_field: Description
- facility_id: f.w1.c1.test0.gcp
group: Rack 1
name: W1 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w1.c1.test0.gcp
group: Rack 1
name: W1 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w1.c1.test0.gcp
group: Rack 1
name: W1 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: f.w2.c1.test0.gcp
group: Rack 2
name: W2 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w2.c1.test0.gcp
group: Rack 2
name: W2 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w2.c1.test0.gcp
group: Rack 2
name: W2 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: f.w3.c1.test0.gcp
group: Rack 3
name: W3 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w3.c1.test0.gcp
group: Rack 3
name: W3 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w3.c1.test0.gcp
group: Rack 3
name: W3 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: f.w4.c1.test0.gcp
group: Rack 4
name: W4 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w4.c1.test0.gcp
group: Rack 4
name: W4 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w4.c1.test0.gcp
group: Rack 4
name: W4 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: f.w5.c1.test0.gcp
group: Rack 5
name: W5 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w5.c1.test0.gcp
group: Rack 5
name: W5 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w5.c1.test0.gcp
group: Rack 5
name: W5 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: f.w6.c1.test0.gcp
group: Rack 6
name: W6 Facility
role: Facility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: a.w6.c1.test0.gcp
group: Rack 6
name: W6 Zone A
role: Customer
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'
- facility_id: b.w6.c1.test0.gcp
group: Rack 6
name: W6 Zone B
role: Utility
site: Test Site (TEST0.GCP)
type: 4-post cabinet
u_height: '36'
width: '19'

View File

@ -1,10 +1,2 @@
# - name: Singapore
# slug: singapore
# - name: Amsterdam
# slug: amsterdam
# - name: Downtown
# slug: downtown
# parent: Amsterdam
# - name: Suburbs
# slug: suburbs
# parent: Amsterdam
- name: GCP
slug: gcp

View File

@ -1,32 +1,5 @@
# - name: AMS 1
# slug: ams1
# region: Downtown
# status: 1
# facility: Amsterdam 1
# asn: 12345
# custom_fields:
# text_field: Description
# - name: AMS 2
# slug: ams2
# region: Downtown
# status: 1
# facility: Amsterdam 2
# asn: 54321
# custom_fields:
# text_field: Description
# - name: AMS 3
# slug: ams3
# region: Suburbs
# status: 1
# facility: Amsterdam 3
# asn: 67890
# custom_fields:
# text_field: Description
# - name: SING 1
# slug: sing1
# region: Singapore
# status: 1
# facility: Singapore 1
# asn: 09876
# custom_fields:
# text_field: Description
- name: Test Site (TEST0.GCP)
slug: test0-gcp
region: GCP
status: 1
facility: us-central1

View File

@ -0,0 +1,31 @@
from dcim.models import Site, RackGroup
from ruamel.yaml import YAML
from pathlib import Path
import sys
file = Path('/opt/netbox/initializers/rack_groups.yml')
if not file.is_file():
sys.exit()
with file.open('r') as stream:
yaml=YAML(typ='safe')
rack_groups = yaml.load(stream)
required_assocs = {
'site': (Site, 'name')
}
if rack_groups is not None:
for params in rack_groups:
for assoc, details in required_assocs.items():
model, field = details
query = { field: params.pop(assoc) }
params[assoc] = model.objects.get(**query)
rack_group, created = RackGroup.objects.get_or_create(**params)
if created:
print("👪 Created rack group", rack_group.name)

28
scripts/export-to-initializers Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import os
import csv
import sys
import yaml
import argparse
parser = argparse.ArgumentParser(description='Netbox csv export to initializer yaml')
parser.add_argument(
'input',
type=argparse.FileType('r'),
metavar='export.csv',
help='netbox csv export'
)
parser.add_argument(
'output',
type=argparse.FileType('w'),
help='parsed yaml output'
)
args = parser.parse_args()
data = [r for r in csv.reader(args.input)]
header = data.pop(0)
output = [dict(zip(header, r)) for r in data]
args.output.write(yaml.dump(output, default_flow_style=False))