From 32daef91a7da57e8d6e0eff3b25c2d2ae475cf8e Mon Sep 17 00:00:00 2001 From: ylamouroux Date: Thu, 2 Jul 2020 19:37:20 +0200 Subject: [PATCH] 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() --- configuration/configuration.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configuration/configuration.py b/configuration/configuration.py index 404b6a0..07651a4 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -1,6 +1,7 @@ import os import re import socket +import json # 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 @@ -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') 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') + + +# 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', '{}'))