Add manufacturer seeds
This commit is contained in:
parent
791027f77b
commit
86675278ab
2 changed files with 20 additions and 0 deletions
14
startup_scripts/42_manufacturers.py
Normal file
14
startup_scripts/42_manufacturers.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from dcim.models import Manufacturer
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
with open('/opt/netbox/initializers/manufacturers.yml', 'r') as stream:
|
||||
yaml = YAML(typ='safe')
|
||||
manufacturers = yaml.load(stream)
|
||||
|
||||
if manufacturers is not None:
|
||||
for manufacturer_params in manufacturers:
|
||||
manufacturer, created = Manufacturer.objects.get_or_create(**manufacturer_params)
|
||||
|
||||
if created:
|
||||
print("Created Manufacturer", manufacturer.name)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue