mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-20 04:12:25 -06:00
Add initializers to produce a single 6 wedge site with 9U lockers
This commit is contained in:
28
scripts/export-to-initializers
Executable file
28
scripts/export-to-initializers
Executable 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))
|
||||
Reference in New Issue
Block a user