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
|
@ -1,7 +1,13 @@
|
|||
from dcim.models import Manufacturer
|
||||
from ruamel.yaml import YAML
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
with open('/opt/netbox/initializers/manufacturers.yml', 'r') as stream:
|
||||
file = Path('/opt/netbox/initializers/manufacturers.yml')
|
||||
if not file.is_file():
|
||||
sys.exit()
|
||||
|
||||
with file.open('r') as stream:
|
||||
yaml = YAML(typ='safe')
|
||||
manufacturers = yaml.load(stream)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue