mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2024-11-30 03:43:22 +01:00
20 lines
514 B
Python
20 lines
514 B
Python
from tenancy.models import TenantGroup
|
|
from ruamel.yaml import YAML
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
file = Path('/opt/netbox/initializers/tenant_groups.yml')
|
|
if not file.is_file():
|
|
sys.exit()
|
|
|
|
with file.open('r') as stream:
|
|
yaml = YAML(typ='safe')
|
|
tenant_groups = yaml.load(stream)
|
|
|
|
if tenant_groups is not None:
|
|
for params in tenant_groups:
|
|
tenant_group, created = TenantGroup.objects.get_or_create(**params)
|
|
|
|
if created:
|
|
print("🔳 Created Tenant Group", tenant_group.name)
|