diff --git a/plugins.py b/plugins.py index 09c3e74..64cdf28 100644 --- a/plugins.py +++ b/plugins.py @@ -7,6 +7,9 @@ # IMPORTANT: netbox_branching MUST be the last plugin in the list # ============================================================================= +import os + +# Plugin list - netbox_branching must be LAST PLUGINS = [ 'netbox_bgp', 'netbox_secrets', @@ -18,20 +21,35 @@ PLUGINS = [ 'netbox_branching', # MUST be last ] +# Plugin configuration PLUGINS_CONFIG = { - 'netbox_branching': { - # https://github.com/netboxlabs/netbox-branching#configuration - }, - 'netbox_bgp': { - # 'top_level_menu': True, - # 'asdot': False, - }, - 'netbox_secrets': { - # 'public_key_size': 4096, - }, - 'netbox_topology_views': { - # 'static_image_directory': 'netbox_topology_views/img', - # 'allow_coordinates_saving': True, - # 'always_save_coordinates': False, - }, + 'netbox_branching': {}, + 'netbox_bgp': {}, + 'netbox_secrets': {}, + 'netbox_topology_views': {}, } + +# ============================================================================= +# NetBox Branching - Database Configuration +# ============================================================================= +# Required for netbox-branching plugin to work properly. +# See: https://netboxlabs.com/docs/extensions/branching/netbox-docker/ +# ============================================================================= + +from netbox_branching.utilities import DynamicSchemaDict + +DATABASES = DynamicSchemaDict({ + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('DB_NAME', 'netbox'), + 'USER': os.environ.get('DB_USER', 'netbox'), + 'PASSWORD': os.environ.get('DB_PASSWORD', ''), + 'HOST': os.environ.get('DB_HOST', 'postgres'), + 'PORT': os.environ.get('DB_PORT', ''), + 'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')), + } +}) + +DATABASE_ROUTERS = [ + 'netbox_branching.database.BranchAwareRouter', +]