Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / contrib / components / netbox / components / netbox-app / resources / config / configuration / configuration.py
1 import os
2 import socket
3
4 # For reference see http://netbox.readthedocs.io/en/latest/configuration/mandatory-settings/
5 # Based on https://github.com/digitalocean/netbox/blob/develop/netbox/netbox/configuration.example.py
6
7 # Read secret from file
8 def read_secret(secret_name):
9     try:
10         f = open('/run/secrets/' + secret_name, 'r', encoding='utf-8')
11     except EnvironmentError:
12         return ''
13     else:
14         with f:
15             return f.readline().strip()
16
17 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18
19 #########################
20 #                       #
21 #   Required settings   #
22 #                       #
23 #########################
24
25 # This is a list of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write
26 # access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
27 #
28 # Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
29 ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', socket.gethostname()).split(' ')
30
31 # PostgreSQL database configuration.
32 DATABASE = {
33     'NAME': os.environ.get('DB_NAME', 'netbox'),         # Database name
34     'USER': os.environ.get('DB_USER', ''),               # PostgreSQL username
35     'PASSWORD': os.environ.get('DB_PASSWORD', read_secret('db_password')),
36                                                          # PostgreSQL password
37     'HOST': os.environ.get('DB_HOST', 'localhost'),      # Database server
38     'PORT': os.environ.get('DB_PORT', ''),               # Database port (leave blank for default)
39 }
40
41 # This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
42 # For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
43 # symbols. NetBox will not run without this defined. For more information, see
44 # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SECRET_KEY
45 SECRET_KEY = os.environ.get('SECRET_KEY', read_secret('secret_key'))
46
47 #########################
48 #                       #
49 #   Optional settings   #
50 #                       #
51 #########################
52
53 # Specify one or more name and email address tuples representing NetBox administrators. These people will be notified of
54 # application errors (assuming correct email settings are provided).
55 ADMINS = [
56     # ['John Doe', 'jdoe@example.com'],
57 ]
58
59 # Optionally display a persistent banner at the top and/or bottom of every page. HTML is allowed. To display the same
60 # content in both banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
61 BANNER_TOP = os.environ.get('BANNER_TOP', '')
62 BANNER_BOTTOM = os.environ.get('BANNER_BOTTOM', '')
63
64 # Text to include on the login page above the login form. HTML is allowed.
65 BANNER_LOGIN = os.environ.get('BANNER_LOGIN', '')
66
67 # Base URL path if accessing NetBox within a directory. For example, if installed at http://example.com/netbox/, set:
68 # BASE_PATH = 'netbox/'
69 BASE_PATH = os.environ.get('BASE_PATH', '')
70
71 # API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to True, all origins will be
72 # allowed. Otherwise, define a list of allowed origins using either CORS_ORIGIN_WHITELIST or
73 # CORS_ORIGIN_REGEX_WHITELIST. For more information, see https://github.com/ottoyiu/django-cors-headers
74 CORS_ORIGIN_ALLOW_ALL = os.environ.get('CORS_ORIGIN_ALLOW_ALL', 'False').lower() == 'true'
75 CORS_ORIGIN_WHITELIST = os.environ.get('CORS_ORIGIN_WHITELIST', '').split(' ')
76 CORS_ORIGIN_REGEX_WHITELIST = [
77     # r'^(https?://)?(\w+\.)?example\.com$',
78 ]
79
80 # Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
81 # sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging
82 # on a production system.
83 DEBUG = os.environ.get('DEBUG', 'False').lower() == 'true'
84
85 # Email settings
86 EMAIL = {
87     'SERVER': os.environ.get('EMAIL_SERVER', 'localhost'),
88     'PORT': int(os.environ.get('EMAIL_PORT', 25)),
89     'USERNAME': os.environ.get('EMAIL_USERNAME', ''),
90     'PASSWORD': os.environ.get('EMAIL_PASSWORD', read_secret('email_password')),
91     'TIMEOUT': int(os.environ.get('EMAIL_TIMEOUT', 10)),  # seconds
92     'FROM_EMAIL': os.environ.get('EMAIL_FROM', ''),
93 }
94
95 # Enforcement of unique IP space can be toggled on a per-VRF basis.
96 # To enforce unique IP space within the global table (all prefixes and IP addresses not assigned to a VRF),
97 # set ENFORCE_GLOBAL_UNIQUE to True.
98 ENFORCE_GLOBAL_UNIQUE = os.environ.get('ENFORCE_GLOBAL_UNIQUE', 'False').lower() == 'true'
99
100 # Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
101 #   https://docs.djangoproject.com/en/1.11/topics/logging/
102 LOGGING = {}
103
104 # Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
105 # are permitted to access most data in NetBox (excluding secrets) but not make any changes.
106 LOGIN_REQUIRED = os.environ.get('LOGIN_REQUIRED', 'False').lower() == 'true'
107
108 # Base URL path if accessing NetBox within a directory. For example, if installed at http://example.com/netbox/, set:
109 # BASE_PATH = 'netbox/'
110 BASE_PATH = os.environ.get('BASE_PATH', '')
111
112 # Setting this to True will display a "maintenance mode" banner at the top of every page.
113 MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', 'False').lower() == 'true'
114
115 # An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
116 # "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
117 # all objects by specifying "?limit=0".
118 MAX_PAGE_SIZE = int(os.environ.get('MAX_PAGE_SIZE', 1000))
119
120 # The file path where uploaded media such as image attachments are stored. A trailing slash is not needed. Note that
121 # the default value of this setting is derived from the installed location.
122 MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.join(BASE_DIR, 'media'))
123
124 # Credentials that NetBox will use to access live devices.
125 NAPALM_USERNAME = os.environ.get('NAPALM_USERNAME', '')
126 NAPALM_PASSWORD = os.environ.get('NAPALM_PASSWORD', read_secret('napalm_password'))
127
128 # NAPALM timeout (in seconds). (Default: 30)
129 NAPALM_TIMEOUT = int(os.environ.get('NAPALM_TIMEOUT', 30))
130
131 # NAPALM optional arguments (see http://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must
132 # be provided as a dictionary.
133 NAPALM_ARGS = {}
134
135 # Determine how many objects to display per page within a list. (Default: 50)
136 PAGINATE_COUNT = int(os.environ.get('PAGINATE_COUNT', 50))
137
138 # When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
139 # prefer IPv4 instead.
140 PREFER_IPV4 = os.environ.get('PREFER_IPV4', 'False').lower() == 'true'
141
142 # The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of
143 # this setting is derived from the installed location.
144 REPORTS_ROOT = os.environ.get('REPORTS_ROOT', '/etc/netbox/reports')
145
146 # Time zone (default: UTC)
147 TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC')
148
149 # Date/time formatting. See the following link for supported formats:
150 # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
151 DATE_FORMAT = os.environ.get('DATE_FORMAT', 'N j, Y')
152 SHORT_DATE_FORMAT = os.environ.get('SHORT_DATE_FORMAT', 'Y-m-d')
153 TIME_FORMAT = os.environ.get('TIME_FORMAT', 'g:i a')
154 SHORT_TIME_FORMAT = os.environ.get('SHORT_TIME_FORMAT', 'H:i:s')
155 DATETIME_FORMAT = os.environ.get('DATETIME_FORMAT', 'N j, Y g:i a')
156 SHORT_DATETIME_FORMAT = os.environ.get('SHORT_DATETIME_FORMAT', 'Y-m-d H:i')