Skip to content

Commit 8caf755

Browse files
authored
Merge pull request #209 from netbox-community/2.7-prep
Prepare for Netbox 2.7
2 parents 40ef427 + 27f671e commit 8caf755

21 files changed

+162
-115
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ RUN pip install --prefix="/install" --no-warn-script-location \
2626
# ruamel is used in startup_scripts
2727
'ruamel.yaml>=0.15,<0.16' \
2828
# django_auth_ldap is required for ldap
29-
django_auth_ldap
29+
django_auth_ldap \
30+
# django-storages was introduced in 2.7 and is optional
31+
django-storages
3032

3133
ARG NETBOX_PATH
3234
COPY ${NETBOX_PATH}/requirements.txt /

configuration/configuration.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def read_secret(secret_name):
3737
# PostgreSQL password
3838
'HOST': os.environ.get('DB_HOST', 'localhost'), # Database server
3939
'PORT': os.environ.get('DB_PORT', ''), # Database port (leave blank for default)
40-
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
40+
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
4141
# Database connection SSLMODE
42-
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
42+
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
4343
# Database connection persistence
4444
}
4545

@@ -51,13 +51,22 @@ def read_secret(secret_name):
5151

5252
# Redis database settings. The Redis database is used for caching and background processing such as webhooks
5353
REDIS = {
54-
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
55-
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
56-
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
57-
'DATABASE': os.environ.get('REDIS_DATABASE', '0'),
58-
'CACHE_DATABASE': os.environ.get('REDIS_CACHE_DATABASE', '1'),
59-
'DEFAULT_TIMEOUT': os.environ.get('REDIS_TIMEOUT', '300'),
60-
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
54+
'webhooks': {
55+
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
56+
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
57+
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
58+
'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
59+
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
60+
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
61+
},
62+
'caching': {
63+
'HOST': os.environ.get('REDIS_CACHE_HOST', os.environ.get('REDIS_HOST', 'localhost')),
64+
'PORT': int(os.environ.get('REDIS_CACHE_PORT', os.environ.get('REDIS_PORT', 6379))),
65+
'PASSWORD': os.environ.get('REDIS_CACHE_PASSWORD', os.environ.get('REDIS_PASSWORD', read_secret('redis_cache_password'))),
66+
'DATABASE': int(os.environ.get('REDIS_CACHE_DATABASE', 1)),
67+
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_CACHE_TIMEOUT', os.environ.get('REDIS_TIMEOUT', 300))),
68+
'SSL': os.environ.get('REDIS_CACHE_SSL', os.environ.get('REDIS_SSL', 'False')).lower() == 'true',
69+
},
6170
}
6271

6372
#########################
@@ -172,10 +181,6 @@ def read_secret(secret_name):
172181
# Time zone (default: UTC)
173182
TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC')
174183

175-
# The Webhook event backend is disabled by default. Set this to True to enable it. Note that this requires a Redis
176-
# database be configured and accessible by NetBox (see `REDIS` below).
177-
WEBHOOKS_ENABLED = os.environ.get('WEBHOOKS_ENABLED', 'False').lower() == 'true'
178-
179184
# Date/time formatting. See the following link for supported formats:
180185
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
181186
DATE_FORMAT = os.environ.get('DATE_FORMAT', 'N j, Y')

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
depends_on:
66
- postgres
77
- redis
8+
- redis-cache
89
- netbox-worker
910
env_file: env/netbox.env
1011
user: '101'
@@ -50,6 +51,13 @@ services:
5051
env_file: env/redis.env
5152
volumes:
5253
- netbox-redis-data:/data
54+
redis-cache:
55+
image: redis:5-alpine
56+
command:
57+
- sh
58+
- -c # this is to evaluate the $REDIS_PASSWORD from the env
59+
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
60+
env_file: env/redis.env
5361
volumes:
5462
netbox-static-files:
5563
driver: local

env/netbox.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ MAX_PAGE_SIZE=1000
1717
REDIS_HOST=redis
1818
REDIS_PASSWORD=H733Kdjndks81
1919
REDIS_DATABASE=0
20-
REDIS_CACHE_DATABASE=1
2120
REDIS_SSL=false
21+
REDIS_CACHE_HOST=redis-cache
22+
REDIS_CACHE_PASSWORD=t4Ph722qJ5QHeQ1qfu36
23+
REDIS_CACHE_DATABASE=0
24+
REDIS_CACHE_SSL=false
2225
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
2326
SKIP_STARTUP_SCRIPTS=false
2427
SKIP_SUPERUSER=false

env/redis-cache.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REDIS_PASSWORD=t4Ph722qJ5QHeQ1qfu36

initializers/custom_fields.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## Possible Choices:
2+
## type:
3+
## - text
4+
## - integer
5+
## - boolean
6+
## - date
7+
## - url
8+
## - select
9+
## filter_logic:
10+
## - disabled
11+
## - loose
12+
## - exact
13+
##
14+
## Examples:
15+
116
# text_field:
217
# type: text
318
# label: Custom Text
@@ -22,8 +37,8 @@
2237
# weight: 10
2338
# on_objects:
2439
# - tenancy.models.Tenant
25-
# selection_field:
26-
# type: selection
40+
# select_field:
41+
# type: select
2742
# label: Choose between items
2843
# required: false
2944
# filter_logic: exact
@@ -41,8 +56,8 @@
4156
# weight: 50
4257
# - value: Fourth Item
4358
# weight: 40
44-
# selection_field_auto_weight:
45-
# type: selection
59+
# select_field_auto_weight:
60+
# type: select
4661
# label: Choose between items
4762
# required: false
4863
# filter_logic: loose

initializers/dcim_interfaces.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
## Possible Choices:
2+
## type:
3+
## - virtual
4+
## - lag
5+
## - 1000base-t
6+
## - ... and many more. See for yourself:
7+
## https://github.com/netbox-community/netbox/blob/295d4f0394b431351c0cb2c3ecc791df68c6c2fb/netbox/dcim/choices.py#L510
8+
##
9+
## Examples:
10+
111
# - device: server01
212
# enabled: true
3-
# type: Virtual
13+
# type: virtual
414
# name: to-server02
515
# - device: server02
616
# enabled: true
7-
# type: Virtual
17+
# type: virtual
818
# name: to-server01

initializers/devices.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
## Possible Choices:
2+
## face:
3+
## - front
4+
## - rear
5+
## status:
6+
## - offline
7+
## - active
8+
## - planned
9+
## - staged
10+
## - failed
11+
## - inventory
12+
## - decommissioning
13+
##
14+
## Examples:
15+
116
# - name: server01
217
# device_role: server
318
# device_type: Other
419
# site: AMS 1
520
# rack: rack-01
6-
# face: Front
21+
# face: front
722
# position: 1
823
# custom_fields:
924
# text_field: Description
@@ -12,7 +27,7 @@
1227
# device_type: Other
1328
# site: AMS 2
1429
# rack: rack-02
15-
# face: Front
30+
# face: front
1631
# position: 2
1732
# custom_fields:
1833
# text_field: Description
@@ -21,7 +36,7 @@
2136
# device_type: Other
2237
# site: SING 1
2338
# rack: rack-03
24-
# face: Front
39+
# face: front
2540
# position: 3
2641
# custom_fields:
2742
# text_field: Description

initializers/ip_addresses.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1+
## Possible Choices:
2+
## status:
3+
## - active
4+
## - reserved
5+
## - deprecated
6+
## - dhcp
7+
## role:
8+
## - loopback
9+
## - secondary
10+
## - anycast
11+
## - vip
12+
## - vrrp
13+
## - hsrp
14+
## - glbp
15+
## - carp
16+
##
17+
## Examples:
18+
119
# - address: 10.1.1.1/24
220
# device: server01
321
# interface: to-server02
4-
# status: Active
22+
# status: active
523
# vrf: vrf1
624
# - address: 2001:db8:a000:1::1/64
725
# device: server01
826
# interface: to-server02
9-
# status: Active
27+
# status: active
1028
# vrf: vrf1
1129
# - address: 10.1.1.2/24
1230
# device: server02
1331
# interface: to-server01
14-
# status: Active
32+
# status: active
1533
# - address: 2001:db8:a000:1::2/64
1634
# device: server02
1735
# interface: to-server01
18-
# status: Active
36+
# status: active
1937
# - address: 10.1.1.10/24
2038
# description: reserved IP
21-
# status: Reserved
39+
# status: reserved
2240
# tenant: tenant1
2341
# - address: 2001:db8:a000:1::10/64
2442
# description: reserved IP
25-
# status: Reserved
43+
# status: reserved
2644
# tenant: tenant1

initializers/prefixes.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1+
## Possible Choices:
2+
## status:
3+
## - container
4+
## - active
5+
## - reserved
6+
## - deprecated
7+
##
8+
## Examples:
9+
110
# - description: prefix1
211
# prefix: 10.1.1.0/24
312
# site: AMS 1
4-
# status: Active
13+
# status: active
514
# tenant: tenant1
615
# vlan: vlan1
716
# - description: prefix2
817
# prefix: 10.1.2.0/24
918
# site: AMS 2
10-
# status: Active
19+
# status: active
1120
# tenant: tenant2
1221
# vlan: vlan2
1322
# is_pool: true
1423
# vrf: vrf2
1524
# - description: ipv6 prefix1
1625
# prefix: 2001:db8:a000:1::/64
1726
# site: AMS 2
18-
# status: Active
27+
# status: active
1928
# tenant: tenant2
2029
# vlan: vlan2

0 commit comments

Comments
 (0)