add tags & secret roles
This commit is contained in:
parent
31f52041f8
commit
3094665092
4
initializers/secret_roles.yml
Normal file
4
initializers/secret_roles.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# - name: Super Secret Passwords
|
||||
# slug: super-secret
|
||||
# - name: SNMP Communities
|
||||
# slug: snmp
|
12
initializers/tags.yml
Normal file
12
initializers/tags.yml
Normal file
@ -0,0 +1,12 @@
|
||||
# - name: Tag 1
|
||||
# slug: tag-1
|
||||
# color: Pink
|
||||
# - name: Tag 2
|
||||
# slug: tag-2
|
||||
# color: Cyan
|
||||
# - name: Tag 3
|
||||
# slug: tag-3
|
||||
# color: Grey
|
||||
# - name: Tag 4
|
||||
# slug: tag-4
|
||||
# color: Teal
|
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…
Reference in New Issue
Block a user