2019-07-04 14:10:56 +02:00
|
|
|
from ipam.models import Role
|
|
|
|
from ruamel.yaml import YAML
|
|
|
|
from pathlib import Path
|
|
|
|
import sys
|
|
|
|
|
|
|
|
file = Path('/opt/netbox/initializers/prefix_vlan_roles.yml')
|
|
|
|
if not file.is_file():
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
with file.open('r') as stream:
|
|
|
|
yaml = YAML(typ='safe')
|
|
|
|
roles = yaml.load(stream)
|
|
|
|
|
|
|
|
if roles is not None:
|
|
|
|
for params in roles:
|
|
|
|
role, created = Role.objects.get_or_create(**params)
|
|
|
|
|
|
|
|
if created:
|
2019-10-10 16:52:29 +02:00
|
|
|
print("⛹️ Created Prefix/VLAN Role", role.name)
|