Added more startup_scripts and initializers examples.

This commit is contained in:
Alvaro Arriola
2019-07-04 14:10:56 +02:00
parent 5a4e9d7a14
commit 4cb5b9f20d
28 changed files with 732 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
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)