add tags & secret roles
This commit is contained in:
parent
31f52041f8
commit
3094665092
4 changed files with 53 additions and 0 deletions
23
startup_scripts/020_tags.py
Normal file
23
startup_scripts/020_tags.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from extras.models import Tag
|
||||
from utilities.choices import ColorChoices
|
||||
|
||||
from startup_script_utils import load_yaml
|
||||
import sys
|
||||
|
||||
tags = load_yaml('/opt/netbox/initializers/tags.yml')
|
||||
|
||||
if tags is None:
|
||||
sys.exit()
|
||||
|
||||
for params in tags:
|
||||
if 'color' in params:
|
||||
color = params.pop('color')
|
||||
|
||||
for color_tpl in ColorChoices:
|
||||
if color in color_tpl:
|
||||
params['color'] = color_tpl[0]
|
||||
|
||||
tag, created = Tag.objects.get_or_create(**params)
|
||||
|
||||
if created:
|
||||
print("🎨 Created Tag", tag.name)
|
14
startup_scripts/310_secret_roles.py
Normal file
14
startup_scripts/310_secret_roles.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from secrets.models import SecretRole
|
||||
from startup_script_utils import load_yaml
|
||||
import sys
|
||||
|
||||
secret_roles = load_yaml('/opt/netbox/initializers/secret_roles.yml')
|
||||
|
||||
if secret_roles is None:
|
||||
sys.exit()
|
||||
|
||||
for params in secret_roles:
|
||||
secret_role, created = SecretRole.objects.get_or_create(**params)
|
||||
|
||||
if created:
|
||||
print("🔑 Created Secret Role", secret_role.name)
|
Loading…
Add table
Add a link
Reference in a new issue