2020-10-20 20:11:10 +02:00
|
|
|
####
|
|
|
|
## We recommend to not edit this file.
|
|
|
|
## Create separate files to overwrite the settings.
|
|
|
|
## See `extra.py` as an example.
|
|
|
|
####
|
|
|
|
|
2019-06-21 22:47:09 +02:00
|
|
|
import re
|
2020-10-18 02:35:22 +02:00
|
|
|
from os import environ
|
2021-02-08 11:59:33 +01:00
|
|
|
from os.path import abspath, dirname, join
|
2022-10-07 22:33:41 +02:00
|
|
|
from typing import Any, Callable, Tuple
|
2020-10-18 02:35:22 +02:00
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# For reference see https://docs.netbox.dev/en/stable/configuration/
|
|
|
|
# Based on https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/configuration_example.py
|
|
|
|
|
|
|
|
###
|
|
|
|
# NetBox-Docker Helper functions
|
|
|
|
###
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Read secret from file
|
2022-10-06 22:53:32 +02:00
|
|
|
def _read_secret(secret_name: str, default: str | None = None) -> str | None:
|
2018-02-22 11:58:36 +01:00
|
|
|
try:
|
|
|
|
f = open('/run/secrets/' + secret_name, 'r', encoding='utf-8')
|
|
|
|
except EnvironmentError:
|
2020-05-13 14:44:41 +02:00
|
|
|
return default
|
2018-02-22 11:58:36 +01:00
|
|
|
else:
|
|
|
|
with f:
|
|
|
|
return f.readline().strip()
|
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# If the `map_fn` isn't defined, then the value that is read from the environment (or the default value if not found) is returned.
|
|
|
|
# If the `map_fn` is defined, then `map_fn` is invoked and the value (that was read from the environment or the default value if not found)
|
|
|
|
# is passed to it as a parameter. The value returned from `map_fn` is then the return value of this function.
|
|
|
|
# The `map_fn` is not invoked, if the value (that was read from the environment or the default value if not found) is None.
|
|
|
|
def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn: Callable[[str], Any | None] = None) -> Any | None:
|
|
|
|
env_value = environ.get(variable_name, default)
|
|
|
|
|
|
|
|
if env_value == None:
|
|
|
|
return env_value
|
|
|
|
|
|
|
|
if not map_fn:
|
|
|
|
return env_value
|
|
|
|
|
|
|
|
return map_fn(env_value)
|
|
|
|
|
2022-10-13 18:13:08 +02:00
|
|
|
_AS_BOOL = lambda value : value.lower() == 'true'
|
2022-10-06 22:53:32 +02:00
|
|
|
_AS_INT = lambda value : int(value)
|
2022-10-13 18:13:08 +02:00
|
|
|
_AS_LIST = lambda value : list(filter(None, value.split(' ')))
|
2022-10-06 22:53:32 +02:00
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
_BASE_DIR = dirname(dirname(abspath(__file__)))
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
#########################
|
|
|
|
# #
|
|
|
|
# Required settings #
|
|
|
|
# #
|
|
|
|
#########################
|
|
|
|
|
|
|
|
# This is a list of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write
|
|
|
|
# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
|
|
|
|
#
|
|
|
|
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
|
2020-10-18 02:35:22 +02:00
|
|
|
ALLOWED_HOSTS = environ.get('ALLOWED_HOSTS', '*').split(' ')
|
2023-01-03 16:48:00 +01:00
|
|
|
# ensure that '*' or 'localhost' is always in ALLOWED_HOSTS (needed for health checks)
|
2023-01-03 14:41:26 +01:00
|
|
|
if '*' not in ALLOWED_HOSTS and 'localhost' not in ALLOWED_HOSTS:
|
|
|
|
ALLOWED_HOSTS.append('localhost')
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# PostgreSQL database configuration. See the Django documentation for a complete list of available parameters:
|
|
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
|
2018-02-22 11:58:36 +01:00
|
|
|
DATABASE = {
|
2021-02-08 11:59:33 +01:00
|
|
|
'NAME': environ.get('DB_NAME', 'netbox'), # Database name
|
|
|
|
'USER': environ.get('DB_USER', ''), # PostgreSQL username
|
2020-10-20 21:36:40 +02:00
|
|
|
'PASSWORD': _read_secret('db_password', environ.get('DB_PASSWORD', '')),
|
2021-02-08 11:59:33 +01:00
|
|
|
# PostgreSQL password
|
|
|
|
'HOST': environ.get('DB_HOST', 'localhost'), # Database server
|
|
|
|
'PORT': environ.get('DB_PORT', ''), # Database port (leave blank for default)
|
2020-10-18 02:35:22 +02:00
|
|
|
'OPTIONS': {'sslmode': environ.get('DB_SSLMODE', 'prefer')},
|
2021-02-08 11:59:33 +01:00
|
|
|
# Database connection SSLMODE
|
2022-10-06 22:53:32 +02:00
|
|
|
'CONN_MAX_AGE': _environ_get_and_map('DB_CONN_MAX_AGE', '300', _AS_INT),
|
2021-02-08 11:59:33 +01:00
|
|
|
# Max database connection age
|
2022-10-13 18:13:08 +02:00
|
|
|
'DISABLE_SERVER_SIDE_CURSORS': _environ_get_and_map('DB_DISABLE_SERVER_SIDE_CURSORS', 'False', _AS_BOOL),
|
2021-06-24 17:21:08 +02:00
|
|
|
# Disable the use of server-side cursors transaction pooling
|
2018-02-22 11:58:36 +01:00
|
|
|
}
|
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate
|
|
|
|
# configuration exists for each. Full connection details are required in both sections, and it is strongly recommended
|
|
|
|
# to use two separate database IDs.
|
2019-06-21 22:47:09 +02:00
|
|
|
REDIS = {
|
2020-04-02 05:41:35 +02:00
|
|
|
'tasks': {
|
2020-10-18 02:35:22 +02:00
|
|
|
'HOST': environ.get('REDIS_HOST', 'localhost'),
|
2022-10-06 22:53:32 +02:00
|
|
|
'PORT': _environ_get_and_map('REDIS_PORT', 6379, _AS_INT),
|
2023-01-27 15:02:11 +01:00
|
|
|
'USERNAME': environ.get('REDIS_USERNAME', ''),
|
2020-10-20 21:36:40 +02:00
|
|
|
'PASSWORD': _read_secret('redis_password', environ.get('REDIS_PASSWORD', '')),
|
2022-10-06 22:53:32 +02:00
|
|
|
'DATABASE': _environ_get_and_map('REDIS_DATABASE', 0, _AS_INT),
|
2022-10-13 18:13:08 +02:00
|
|
|
'SSL': _environ_get_and_map('REDIS_SSL', 'False', _AS_BOOL),
|
|
|
|
'INSECURE_SKIP_TLS_VERIFY': _environ_get_and_map('REDIS_INSECURE_SKIP_TLS_VERIFY', 'False', _AS_BOOL),
|
2019-12-16 12:51:59 +01:00
|
|
|
},
|
|
|
|
'caching': {
|
2020-10-18 02:35:22 +02:00
|
|
|
'HOST': environ.get('REDIS_CACHE_HOST', environ.get('REDIS_HOST', 'localhost')),
|
2022-10-06 22:53:32 +02:00
|
|
|
'PORT': _environ_get_and_map('REDIS_CACHE_PORT', environ.get('REDIS_PORT', '6379'), _AS_INT),
|
2023-01-27 15:02:11 +01:00
|
|
|
'USERNAME': environ.get('REDIS_CACHE_USERNAME', environ.get('REDIS_USERNAME', ''),
|
2020-10-20 21:36:40 +02:00
|
|
|
'PASSWORD': _read_secret('redis_cache_password', environ.get('REDIS_CACHE_PASSWORD', environ.get('REDIS_PASSWORD', ''))),
|
2022-10-06 22:53:32 +02:00
|
|
|
'DATABASE': _environ_get_and_map('REDIS_CACHE_DATABASE', '1', _AS_INT),
|
2022-10-13 18:13:08 +02:00
|
|
|
'SSL': _environ_get_and_map('REDIS_CACHE_SSL', environ.get('REDIS_SSL', 'False'), _AS_BOOL),
|
|
|
|
'INSECURE_SKIP_TLS_VERIFY': _environ_get_and_map('REDIS_CACHE_INSECURE_SKIP_TLS_VERIFY', environ.get('REDIS_INSECURE_SKIP_TLS_VERIFY', 'False'), _AS_BOOL),
|
2019-12-16 12:51:59 +01:00
|
|
|
},
|
2019-06-21 22:47:09 +02:00
|
|
|
}
|
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
|
|
|
|
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
|
|
|
|
# symbols. NetBox will not run without this defined. For more information, see
|
|
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
|
2020-10-20 21:45:37 +02:00
|
|
|
SECRET_KEY = _read_secret('secret_key', environ.get('SECRET_KEY', ''))
|
2020-10-18 02:35:22 +02:00
|
|
|
|
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
#########################
|
|
|
|
# #
|
|
|
|
# Optional settings #
|
|
|
|
# #
|
|
|
|
#########################
|
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# # Specify one or more name and email address tuples representing NetBox administrators. These people will be notified of
|
|
|
|
# # application errors (assuming correct email settings are provided).
|
|
|
|
# ADMINS = [
|
|
|
|
# # ['John Doe', 'jdoe@example.com'],
|
|
|
|
# ]
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'ALLOWED_URL_SCHEMES' in environ:
|
2022-10-13 18:13:08 +02:00
|
|
|
ALLOWED_URL_SCHEMES = _environ_get_and_map('ALLOWED_URL_SCHEMES', None, _AS_LIST)
|
2020-10-18 02:35:22 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# Optionally display a persistent banner at the top and/or bottom of every page. HTML is allowed. To display the same
|
|
|
|
# content in both banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
|
2022-10-07 22:33:41 +02:00
|
|
|
if 'BANNER_TOP' in environ:
|
|
|
|
BANNER_TOP = environ.get('BANNER_TOP', None)
|
|
|
|
if 'BANNER_BOTTOM' in environ:
|
|
|
|
BANNER_BOTTOM = environ.get('BANNER_BOTTOM', None)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Text to include on the login page above the login form. HTML is allowed.
|
2022-10-07 22:33:41 +02:00
|
|
|
if 'BANNER_LOGIN' in environ:
|
|
|
|
BANNER_LOGIN = environ.get('BANNER_LOGIN', None)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Base URL path if accessing NetBox within a directory. For example, if installed at http://example.com/netbox/, set:
|
|
|
|
# BASE_PATH = 'netbox/'
|
2020-10-18 02:35:22 +02:00
|
|
|
BASE_PATH = environ.get('BASE_PATH', '')
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2019-06-21 22:47:09 +02:00
|
|
|
# Maximum number of days to retain logged changes. Set to 0 to retain changes indefinitely. (Default: 90)
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'CHANGELOG_RETENTION' in environ:
|
|
|
|
CHANGELOG_RETENTION = _environ_get_and_map('CHANGELOG_RETENTION', None, _AS_INT)
|
2019-06-21 22:47:09 +02:00
|
|
|
|
2022-09-01 19:03:19 +02:00
|
|
|
# Maximum number of days to retain job results (scripts and reports). Set to 0 to retain job results in the database indefinitely. (Default: 90)
|
2022-10-07 22:33:41 +02:00
|
|
|
if 'JOBRESULT_RETENTION' in environ:
|
|
|
|
JOBRESULT_RETENTION = _environ_get_and_map('JOBRESULT_RETENTION', None, _AS_INT)
|
2022-09-01 19:03:19 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to True, all origins will be
|
|
|
|
# allowed. Otherwise, define a list of allowed origins using either CORS_ORIGIN_WHITELIST or
|
|
|
|
# CORS_ORIGIN_REGEX_WHITELIST. For more information, see https://github.com/ottoyiu/django-cors-headers
|
2022-10-13 18:13:08 +02:00
|
|
|
CORS_ORIGIN_ALLOW_ALL = _environ_get_and_map('CORS_ORIGIN_ALLOW_ALL', 'False', _AS_BOOL)
|
|
|
|
CORS_ORIGIN_WHITELIST = _environ_get_and_map('CORS_ORIGIN_WHITELIST', 'https://localhost', _AS_LIST)
|
|
|
|
CORS_ORIGIN_REGEX_WHITELIST = [re.compile(r) for r in _environ_get_and_map('CORS_ORIGIN_REGEX_WHITELIST', '', _AS_LIST)]
|
2022-04-07 16:09:27 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
|
2022-10-06 22:53:32 +02:00
|
|
|
# sensitive information about your installation. Only enable debugging while performing testing.
|
|
|
|
# Never enable debugging on a production system.
|
2022-10-13 18:13:08 +02:00
|
|
|
DEBUG = _environ_get_and_map('DEBUG', 'False', _AS_BOOL)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# This parameter serves as a safeguard to prevent some potentially dangerous behavior,
|
|
|
|
# such as generating new database schema migrations.
|
|
|
|
# Set this to True only if you are actively developing the NetBox code base.
|
2022-10-13 18:13:08 +02:00
|
|
|
DEVELOPER = _environ_get_and_map('DEVELOPER', 'False', _AS_BOOL)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Email settings
|
|
|
|
EMAIL = {
|
2020-10-18 02:35:22 +02:00
|
|
|
'SERVER': environ.get('EMAIL_SERVER', 'localhost'),
|
2022-10-06 22:53:32 +02:00
|
|
|
'PORT': _environ_get_and_map('EMAIL_PORT', 25, _AS_INT),
|
2020-10-18 02:35:22 +02:00
|
|
|
'USERNAME': environ.get('EMAIL_USERNAME', ''),
|
2020-10-20 21:36:40 +02:00
|
|
|
'PASSWORD': _read_secret('email_password', environ.get('EMAIL_PASSWORD', '')),
|
2022-10-13 18:13:08 +02:00
|
|
|
'USE_SSL': _environ_get_and_map('EMAIL_USE_SSL', 'False', _AS_BOOL),
|
|
|
|
'USE_TLS': _environ_get_and_map('EMAIL_USE_TLS', 'False', _AS_BOOL),
|
2020-10-18 02:35:22 +02:00
|
|
|
'SSL_CERTFILE': environ.get('EMAIL_SSL_CERTFILE', ''),
|
|
|
|
'SSL_KEYFILE': environ.get('EMAIL_SSL_KEYFILE', ''),
|
2022-10-06 22:53:32 +02:00
|
|
|
'TIMEOUT': _environ_get_and_map('EMAIL_TIMEOUT', 10, _AS_INT), # seconds
|
2020-10-18 02:35:22 +02:00
|
|
|
'FROM_EMAIL': environ.get('EMAIL_FROM', ''),
|
2018-02-22 11:58:36 +01:00
|
|
|
}
|
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce unique IP space within the global table
|
|
|
|
# (all prefixes and IP addresses not assigned to a VRF), set ENFORCE_GLOBAL_UNIQUE to True.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'ENFORCE_GLOBAL_UNIQUE' in environ:
|
2022-10-13 18:13:08 +02:00
|
|
|
ENFORCE_GLOBAL_UNIQUE = _environ_get_and_map('ENFORCE_GLOBAL_UNIQUE', None, _AS_BOOL)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2019-06-21 22:47:09 +02:00
|
|
|
# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
|
|
|
|
# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
|
2022-10-13 18:13:08 +02:00
|
|
|
EXEMPT_VIEW_PERMISSIONS = _environ_get_and_map('EXEMPT_VIEW_PERMISSIONS', '', _AS_LIST)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# HTTP proxies NetBox should use when sending outbound HTTP requests (e.g. for webhooks).
|
|
|
|
# HTTP_PROXIES = {
|
|
|
|
# 'http': 'http://10.10.1.10:3128',
|
|
|
|
# 'https': 'http://10.10.1.10:1080',
|
|
|
|
# }
|
|
|
|
|
|
|
|
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
|
|
|
|
# NetBox from an internal IP.
|
2022-10-13 18:13:08 +02:00
|
|
|
INTERNAL_IPS = _environ_get_and_map('INTERNAL_IPS', '127.0.0.1 ::1', _AS_LIST)
|
2019-06-21 22:47:09 +02:00
|
|
|
|
2022-02-01 03:45:29 +01:00
|
|
|
# Enable GraphQL API.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'GRAPHQL_ENABLED' in environ:
|
2022-10-13 18:13:08 +02:00
|
|
|
GRAPHQL_ENABLED = _environ_get_and_map('GRAPHQL_ENABLED', None, _AS_BOOL)
|
2022-02-01 03:45:29 +01:00
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# # Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
|
|
|
|
# # https://docs.djangoproject.com/en/stable/topics/logging/
|
|
|
|
# LOGGING = {}
|
|
|
|
|
|
|
|
# Automatically reset the lifetime of a valid session upon each authenticated request. Enables users to remain
|
|
|
|
# authenticated to NetBox indefinitely.
|
2022-10-13 18:13:08 +02:00
|
|
|
LOGIN_PERSISTENCE = _environ_get_and_map('LOGIN_PERSISTENCE', 'False', _AS_BOOL)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
|
|
|
|
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.
|
2022-10-13 18:13:08 +02:00
|
|
|
LOGIN_REQUIRED = _environ_get_and_map('LOGIN_REQUIRED', 'False', _AS_BOOL)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2020-06-16 20:27:59 +02:00
|
|
|
# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to
|
|
|
|
# re-authenticate. (Default: 1209600 [14 days])
|
2022-10-06 22:53:32 +02:00
|
|
|
LOGIN_TIMEOUT = _environ_get_and_map('LOGIN_TIMEOUT', 1209600, _AS_INT)
|
2020-06-16 20:27:59 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# Setting this to True will display a "maintenance mode" banner at the top of every page.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'MAINTENANCE_MODE' in environ:
|
2022-10-13 18:13:08 +02:00
|
|
|
MAINTENANCE_MODE = _environ_get_and_map('MAINTENANCE_MODE', None, _AS_BOOL)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2022-04-19 12:59:27 +02:00
|
|
|
# Maps provider
|
2022-10-07 22:33:41 +02:00
|
|
|
if 'MAPS_URL' in environ:
|
|
|
|
MAPS_URL = environ.get('MAPS_URL', None)
|
2022-04-19 12:59:27 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
|
|
|
|
# "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
|
|
|
|
# all objects by specifying "?limit=0".
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'MAX_PAGE_SIZE' in environ:
|
|
|
|
MAX_PAGE_SIZE = _environ_get_and_map('MAX_PAGE_SIZE', None, _AS_INT)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# The file path where uploaded media such as image attachments are stored. A trailing slash is not needed. Note that
|
|
|
|
# the default value of this setting is derived from the installed location.
|
2020-10-18 02:35:22 +02:00
|
|
|
MEDIA_ROOT = environ.get('MEDIA_ROOT', join(_BASE_DIR, 'media'))
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2019-06-21 22:47:09 +02:00
|
|
|
# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics'
|
2022-10-13 18:13:08 +02:00
|
|
|
METRICS_ENABLED = _environ_get_and_map('METRICS_ENABLED', 'False', _AS_BOOL)
|
2019-06-21 22:47:09 +02:00
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# Credentials that NetBox will uses to authenticate to devices when connecting via NAPALM.
|
2022-10-07 22:33:41 +02:00
|
|
|
if 'NAPALM_USERNAME' in environ:
|
|
|
|
NAPALM_USERNAME = environ.get('NAPALM_USERNAME', None)
|
|
|
|
if 'NAPALM_PASSWORD' in environ:
|
|
|
|
NAPALM_PASSWORD = _read_secret('napalm_password', environ.get('NAPALM_PASSWORD', None))
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# NAPALM timeout (in seconds). (Default: 30)
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'NAPALM_TIMEOUT' in environ:
|
|
|
|
NAPALM_TIMEOUT = _environ_get_and_map('NAPALM_TIMEOUT', None, _AS_INT)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# # NAPALM optional arguments (see http://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must
|
|
|
|
# # be provided as a dictionary.
|
|
|
|
# NAPALM_ARGS = None
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Determine how many objects to display per page within a list. (Default: 50)
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'PAGINATE_COUNT' in environ:
|
|
|
|
PAGINATE_COUNT = _environ_get_and_map('PAGINATE_COUNT', None, _AS_INT)
|
2020-10-18 02:35:22 +02:00
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# # Enable installed plugins. Add the name of each plugin to the list.
|
|
|
|
# PLUGINS = []
|
2020-10-18 02:35:22 +02:00
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# # Plugins configuration settings. These settings are used by various plugins that the user may have installed.
|
|
|
|
# # Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings.
|
|
|
|
# PLUGINS_CONFIG = {
|
|
|
|
# }
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
|
|
|
|
# prefer IPv4 instead.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'PREFER_IPV4' in environ:
|
2022-10-13 18:13:08 +02:00
|
|
|
PREFER_IPV4 = _environ_get_and_map('PREFER_IPV4', None, _AS_BOOL)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# The default value for the amperage field when creating new power feeds.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'POWERFEED_DEFAULT_AMPERAGE' in environ:
|
|
|
|
POWERFEED_DEFAULT_AMPERAGE = _environ_get_and_map('POWERFEED_DEFAULT_AMPERAGE', None, _AS_INT)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# The default value (percentage) for the max_utilization field when creating new power feeds.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'POWERFEED_DEFAULT_MAX_UTILIZATION' in environ:
|
|
|
|
POWERFEED_DEFAULT_MAX_UTILIZATION = _environ_get_and_map('POWERFEED_DEFAULT_MAX_UTILIZATION', None, _AS_INT)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# The default value for the voltage field when creating new power feeds.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'POWERFEED_DEFAULT_VOLTAGE' in environ:
|
|
|
|
POWERFEED_DEFAULT_VOLTAGE = _environ_get_and_map('POWERFEED_DEFAULT_VOLTAGE', None, _AS_INT)
|
2020-03-28 05:30:26 +01:00
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# Rack elevation size defaults, in pixels. For best results, the ratio of width to height should be roughly 10:1.
|
2022-10-08 16:34:02 +02:00
|
|
|
if 'RACK_ELEVATION_DEFAULT_UNIT_HEIGHT' in environ:
|
|
|
|
RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = _environ_get_and_map('RACK_ELEVATION_DEFAULT_UNIT_HEIGHT', None, _AS_INT)
|
|
|
|
if 'RACK_ELEVATION_DEFAULT_UNIT_WIDTH' in environ:
|
|
|
|
RACK_ELEVATION_DEFAULT_UNIT_WIDTH = _environ_get_and_map('RACK_ELEVATION_DEFAULT_UNIT_WIDTH', None, _AS_INT)
|
2020-10-18 02:35:22 +02:00
|
|
|
|
|
|
|
# Remote authentication support
|
2022-10-13 18:13:08 +02:00
|
|
|
REMOTE_AUTH_ENABLED = _environ_get_and_map('REMOTE_AUTH_ENABLED', 'False', _AS_BOOL)
|
2020-10-20 21:40:14 +02:00
|
|
|
REMOTE_AUTH_BACKEND = environ.get('REMOTE_AUTH_BACKEND', 'netbox.authentication.RemoteUserBackend')
|
|
|
|
REMOTE_AUTH_HEADER = environ.get('REMOTE_AUTH_HEADER', 'HTTP_REMOTE_USER')
|
2022-10-13 18:13:08 +02:00
|
|
|
REMOTE_AUTH_AUTO_CREATE_USER = _environ_get_and_map('REMOTE_AUTH_AUTO_CREATE_USER', 'True', _AS_BOOL)
|
|
|
|
REMOTE_AUTH_DEFAULT_GROUPS = _environ_get_and_map('REMOTE_AUTH_DEFAULT_GROUPS', '', _AS_LIST)
|
2022-10-06 22:53:32 +02:00
|
|
|
# REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
|
2020-10-18 02:35:22 +02:00
|
|
|
|
2020-03-28 05:30:26 +01:00
|
|
|
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
|
|
|
|
# version check or use the URL below to check for release in the official NetBox repository.
|
2020-10-18 02:35:22 +02:00
|
|
|
RELEASE_CHECK_URL = environ.get('RELEASE_CHECK_URL', None)
|
2022-10-06 22:53:32 +02:00
|
|
|
# RELEASE_CHECK_URL = 'https://api.github.com/repos/netbox-community/netbox/releases'
|
2020-03-28 05:30:26 +01:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of
|
|
|
|
# this setting is derived from the installed location.
|
2020-10-18 02:35:22 +02:00
|
|
|
REPORTS_ROOT = environ.get('REPORTS_ROOT', '/etc/netbox/reports')
|
|
|
|
|
|
|
|
# Maximum execution time for background tasks, in seconds.
|
2022-10-06 22:53:32 +02:00
|
|
|
RQ_DEFAULT_TIMEOUT = _environ_get_and_map('RQ_DEFAULT_TIMEOUT', 300, _AS_INT)
|
2018-02-22 11:58:36 +01:00
|
|
|
|
2019-10-14 09:47:18 +02:00
|
|
|
# The file path where custom scripts will be stored. A trailing slash is not needed. Note that the default value of
|
|
|
|
# this setting is derived from the installed location.
|
2020-10-18 02:35:22 +02:00
|
|
|
SCRIPTS_ROOT = environ.get('SCRIPTS_ROOT', '/etc/netbox/scripts')
|
|
|
|
|
2022-10-06 22:53:32 +02:00
|
|
|
# The name to use for the csrf token cookie.
|
|
|
|
CSRF_COOKIE_NAME = environ.get('CSRF_COOKIE_NAME', 'csrftoken')
|
|
|
|
|
|
|
|
# Cross-Site-Request-Forgery-Attack settings. If Netbox is sitting behind a reverse proxy, you might need to set the CSRF_TRUSTED_ORIGINS flag.
|
|
|
|
# Django 4.0 requires to specify the URL Scheme in this setting. An example environment variable could be specified like:
|
|
|
|
# CSRF_TRUSTED_ORIGINS=https://demo.netbox.dev http://demo.netbox.dev
|
2022-10-13 18:13:08 +02:00
|
|
|
CSRF_TRUSTED_ORIGINS = _environ_get_and_map('CSRF_TRUSTED_ORIGINS', '', _AS_LIST)
|
2022-10-06 22:53:32 +02:00
|
|
|
|
|
|
|
# The name to use for the session cookie.
|
|
|
|
SESSION_COOKIE_NAME = environ.get('SESSION_COOKIE_NAME', 'sessionid')
|
|
|
|
|
2020-10-18 02:35:22 +02:00
|
|
|
# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use
|
|
|
|
# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
|
|
|
|
# database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
|
2022-10-07 22:33:41 +02:00
|
|
|
SESSION_FILE_PATH = environ.get('SESSION_FILE_PATH', environ.get('SESSIONS_ROOT', None))
|
2019-10-14 09:47:18 +02:00
|
|
|
|
2018-02-22 11:58:36 +01:00
|
|
|
# Time zone (default: UTC)
|
2020-10-18 02:35:22 +02:00
|
|
|
TIME_ZONE = environ.get('TIME_ZONE', 'UTC')
|
2018-02-22 11:58:36 +01:00
|
|
|
|
|
|
|
# Date/time formatting. See the following link for supported formats:
|
2020-10-18 02:35:22 +02:00
|
|
|
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
|
|
|
|
DATE_FORMAT = environ.get('DATE_FORMAT', 'N j, Y')
|
|
|
|
SHORT_DATE_FORMAT = environ.get('SHORT_DATE_FORMAT', 'Y-m-d')
|
|
|
|
TIME_FORMAT = environ.get('TIME_FORMAT', 'g:i a')
|
|
|
|
SHORT_TIME_FORMAT = environ.get('SHORT_TIME_FORMAT', 'H:i:s')
|
|
|
|
DATETIME_FORMAT = environ.get('DATETIME_FORMAT', 'N j, Y g:i a')
|
|
|
|
SHORT_DATETIME_FORMAT = environ.get('SHORT_DATETIME_FORMAT', 'Y-m-d H:i')
|