mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2024-12-11 09:11:14 +01:00
e46a7d2f7f
Previously, the startup_scripts would fail if an initializer file was not present. Now they just ignore missing files.
20 lines
513 B
Python
20 lines
513 B
Python
from dcim.models import Manufacturer
|
|
from ruamel.yaml import YAML
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
file = Path('/opt/netbox/initializers/manufacturers.yml')
|
|
if not file.is_file():
|
|
sys.exit()
|
|
|
|
with file.open('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)
|