Add manufacturer seeds
This commit is contained in:
parent
791027f77b
commit
86675278ab
6
initializers/manufacturers.yml
Normal file
6
initializers/manufacturers.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# - name: Cisco
|
||||||
|
# slug: cisco
|
||||||
|
# - name: Intel
|
||||||
|
# slug: intel
|
||||||
|
# - name: NoName
|
||||||
|
# slug: noname
|
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…
Reference in New Issue
Block a user