Add manufacturer seeds

This commit is contained in:
Aleksandar Radunovic 2018-10-15 15:14:11 +02:00
parent 791027f77b
commit 86675278ab
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# - name: Cisco
# slug: cisco
# - name: Intel
# slug: intel
# - name: NoName
# slug: noname

View 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)