netbox-docker/startup_scripts/050_manufacturers.py
2018-10-16 13:26:13 +02:00

15 lines
419 B
Python

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 params in manufacturers:
manufacturer, created = Manufacturer.objects.get_or_create(**params)
if created:
print("Created Manufacturer", manufacturer.name)