netbox-docker/startup_scripts/140_cluster_types.py

20 lines
521 B
Python
Raw Normal View History

from virtualization.models import ClusterType
from ruamel.yaml import YAML
from pathlib import Path
import sys
file = Path('/opt/netbox/initializers/cluster_types.yml')
if not file.is_file():
sys.exit()
with file.open('r') as stream:
yaml = YAML(typ='safe')
cluster_types = yaml.load(stream)
if cluster_types is not None:
for params in cluster_types:
cluster_type, created = ClusterType.objects.get_or_create(**params)
if created:
2019-10-10 16:52:29 +02:00
print("🧰 Created Cluster Type", cluster_type.name)