2018-10-15 08:14:11 -05:00
|
|
|
from dcim.models import Manufacturer
|
|
|
|
from ruamel.yaml import YAML
|
2018-12-19 07:25:58 -06:00
|
|
|
from pathlib import Path
|
|
|
|
import sys
|
2018-10-15 08:14:11 -05:00
|
|
|
|
2018-12-19 07:25:58 -06:00
|
|
|
file = Path('/opt/netbox/initializers/manufacturers.yml')
|
|
|
|
if not file.is_file():
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
with file.open('r') as stream:
|
2018-10-15 08:14:11 -05:00
|
|
|
yaml = YAML(typ='safe')
|
|
|
|
manufacturers = yaml.load(stream)
|
|
|
|
|
|
|
|
if manufacturers is not None:
|
2018-10-16 04:05:28 -05:00
|
|
|
for params in manufacturers:
|
|
|
|
manufacturer, created = Manufacturer.objects.get_or_create(**params)
|
2018-10-15 08:14:11 -05:00
|
|
|
|
|
|
|
if created:
|
2018-10-30 04:51:43 -05:00
|
|
|
print("🏭 Created Manufacturer", manufacturer.name)
|