feat: add configuration.py with DynamicSchemaDict for netbox-branching
This commit is contained in:
49
configuration.py
Normal file
49
configuration.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# NetBox Configuration
|
||||||
|
# =============================================================================
|
||||||
|
# This file configures the database with DynamicSchemaDict for netbox-branching.
|
||||||
|
# Mount this file to /etc/netbox/config/configuration.py
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
import os
|
||||||
|
from netbox_branching.utilities import DynamicSchemaDict
|
||||||
|
|
||||||
|
# Database configuration with DynamicSchemaDict (required for netbox-branching)
|
||||||
|
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', 'localhost'),
|
||||||
|
'PORT': os.environ.get('DB_PORT', ''),
|
||||||
|
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
# Database router for branch-aware queries
|
||||||
|
DATABASE_ROUTERS = [
|
||||||
|
'netbox_branching.database.BranchAwareRouter',
|
||||||
|
]
|
||||||
|
|
||||||
|
# Redis configuration
|
||||||
|
REDIS = {
|
||||||
|
'tasks': {
|
||||||
|
'HOST': os.environ.get('REDIS_HOST', 'redis'),
|
||||||
|
'PORT': int(os.environ.get('REDIS_PORT', '6379')),
|
||||||
|
'DATABASE': 0,
|
||||||
|
'SSL': False,
|
||||||
|
},
|
||||||
|
'caching': {
|
||||||
|
'HOST': os.environ.get('REDIS_CACHE_HOST', 'redis'),
|
||||||
|
'PORT': int(os.environ.get('REDIS_CACHE_PORT', '6379')),
|
||||||
|
'DATABASE': 1,
|
||||||
|
'SSL': False,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Secret key (required)
|
||||||
|
SECRET_KEY = os.environ.get('SECRET_KEY', '')
|
||||||
|
|
||||||
|
# Allowed hosts
|
||||||
|
ALLOWED_HOSTS = ['*']
|
||||||
Reference in New Issue
Block a user