Ignore missing initializers
Previously, the startup_scripts would fail if an initializer file was not present. Now they just ignore missing files.
This commit is contained in:
parent
03eb153da4
commit
e46a7d2f7f
12 changed files with 88 additions and 13 deletions
|
@ -2,8 +2,14 @@ from django.contrib.auth.models import Permission, Group, User
|
|||
from users.models import Token
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
with open('/opt/netbox/initializers/users.yml', 'r') as stream:
|
||||
file = Path('/opt/netbox/initializers/users.yml')
|
||||
if not file.is_file():
|
||||
sys.exit()
|
||||
|
||||
with file.open('r') as stream:
|
||||
yaml=YAML(typ='safe')
|
||||
users = yaml.load(stream)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue