add 2 environment variables to configurations in order to control plugins:

- PLUGINS: list of plugins in this form -> PLUGINS="plug1,plug2"
  - PLUGINS_CONFIG: json string -> dict()
This commit is contained in:
ylamouroux 2020-07-02 19:37:20 +02:00
parent 4b0f158852
commit 32daef91a7

View file

@ -1,6 +1,7 @@
import os import os
import re import re
import socket import socket
import json
# For reference see http://netbox.readthedocs.io/en/latest/configuration/mandatory-settings/ # For reference see http://netbox.readthedocs.io/en/latest/configuration/mandatory-settings/
# Based on https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/configuration.example.py # Based on https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/configuration.example.py
@ -214,3 +215,8 @@ TIME_FORMAT = os.environ.get('TIME_FORMAT', 'g:i a')
SHORT_TIME_FORMAT = os.environ.get('SHORT_TIME_FORMAT', 'H:i:s') SHORT_TIME_FORMAT = os.environ.get('SHORT_TIME_FORMAT', 'H:i:s')
DATETIME_FORMAT = os.environ.get('DATETIME_FORMAT', 'N j, Y g:i a') DATETIME_FORMAT = os.environ.get('DATETIME_FORMAT', 'N j, Y g:i a')
SHORT_DATETIME_FORMAT = os.environ.get('SHORT_DATETIME_FORMAT', 'Y-m-d H:i') SHORT_DATETIME_FORMAT = os.environ.get('SHORT_DATETIME_FORMAT', 'Y-m-d H:i')
# Provide a list of plugins as "plug1,plug2,..."
PLUGINS = list(filter(lambda x: x != '', os.environ.get('PLUGINS', '').split(',')))
PLUGINS_CONFIG = json.loads(os.environ.get('PLUGINS_CONFIG', '{}'))