feat: Make startup scripts idempotent
This commit is contained in:
parent
a6eb4fef00
commit
9be7b0e109
42 changed files with 275 additions and 95 deletions
|
@ -2,7 +2,7 @@ import sys
|
|||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from extras.models import CustomLink
|
||||
from startup_script_utils import load_yaml
|
||||
from startup_script_utils import load_yaml, split_params
|
||||
|
||||
custom_links = load_yaml("/opt/netbox/initializers/custom_links.yml")
|
||||
|
||||
|
@ -28,6 +28,8 @@ for link in custom_links:
|
|||
)
|
||||
continue
|
||||
|
||||
custom_link, created = CustomLink.objects.get_or_create(**link)
|
||||
matching_params, defaults = split_params(link)
|
||||
custom_link, created = CustomLink.objects.get_or_create(**matching_params, defaults=defaults)
|
||||
|
||||
if created:
|
||||
print("🔗 Created Custom Link '{0}'".format(custom_link.name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue