Skip to content

Commit

Permalink
Merge pull request #209 from netbox-community/2.7-prep
Browse files Browse the repository at this point in the history
Prepare for Netbox 2.7
  • Loading branch information
cimnine authored Jan 20, 2020
2 parents 40ef427 + 27f671e commit 8caf755
Show file tree
Hide file tree
Showing 21 changed files with 162 additions and 115 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ RUN pip install --prefix="/install" --no-warn-script-location \
# ruamel is used in startup_scripts
'ruamel.yaml>=0.15,<0.16' \
# django_auth_ldap is required for ldap
django_auth_ldap
django_auth_ldap \
# django-storages was introduced in 2.7 and is optional
django-storages

ARG NETBOX_PATH
COPY ${NETBOX_PATH}/requirements.txt /
Expand Down
31 changes: 18 additions & 13 deletions configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def read_secret(secret_name):
# PostgreSQL password
'HOST': os.environ.get('DB_HOST', 'localhost'), # Database server
'PORT': os.environ.get('DB_PORT', ''), # Database port (leave blank for default)
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
# Database connection SSLMODE
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
# Database connection persistence
}

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

# Redis database settings. The Redis database is used for caching and background processing such as webhooks
REDIS = {
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
'DATABASE': os.environ.get('REDIS_DATABASE', '0'),
'CACHE_DATABASE': os.environ.get('REDIS_CACHE_DATABASE', '1'),
'DEFAULT_TIMEOUT': os.environ.get('REDIS_TIMEOUT', '300'),
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
'webhooks': {
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
},
'caching': {
'HOST': os.environ.get('REDIS_CACHE_HOST', os.environ.get('REDIS_HOST', 'localhost')),
'PORT': int(os.environ.get('REDIS_CACHE_PORT', os.environ.get('REDIS_PORT', 6379))),
'PASSWORD': os.environ.get('REDIS_CACHE_PASSWORD', os.environ.get('REDIS_PASSWORD', read_secret('redis_cache_password'))),
'DATABASE': int(os.environ.get('REDIS_CACHE_DATABASE', 1)),
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_CACHE_TIMEOUT', os.environ.get('REDIS_TIMEOUT', 300))),
'SSL': os.environ.get('REDIS_CACHE_SSL', os.environ.get('REDIS_SSL', 'False')).lower() == 'true',
},
}

#########################
Expand Down Expand Up @@ -172,10 +181,6 @@ def read_secret(secret_name):
# Time zone (default: UTC)
TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC')

# The Webhook event backend is disabled by default. Set this to True to enable it. Note that this requires a Redis
# database be configured and accessible by NetBox (see `REDIS` below).
WEBHOOKS_ENABLED = os.environ.get('WEBHOOKS_ENABLED', 'False').lower() == 'true'

# Date/time formatting. See the following link for supported formats:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = os.environ.get('DATE_FORMAT', 'N j, Y')
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
depends_on:
- postgres
- redis
- redis-cache
- netbox-worker
env_file: env/netbox.env
user: '101'
Expand Down Expand Up @@ -50,6 +51,13 @@ services:
env_file: env/redis.env
volumes:
- netbox-redis-data:/data
redis-cache:
image: redis:5-alpine
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
env_file: env/redis.env
volumes:
netbox-static-files:
driver: local
Expand Down
5 changes: 4 additions & 1 deletion env/netbox.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ MAX_PAGE_SIZE=1000
REDIS_HOST=redis
REDIS_PASSWORD=H733Kdjndks81
REDIS_DATABASE=0
REDIS_CACHE_DATABASE=1
REDIS_SSL=false
REDIS_CACHE_HOST=redis-cache
REDIS_CACHE_PASSWORD=t4Ph722qJ5QHeQ1qfu36
REDIS_CACHE_DATABASE=0
REDIS_CACHE_SSL=false
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
SKIP_STARTUP_SCRIPTS=false
SKIP_SUPERUSER=false
Expand Down
1 change: 1 addition & 0 deletions env/redis-cache.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REDIS_PASSWORD=t4Ph722qJ5QHeQ1qfu36
23 changes: 19 additions & 4 deletions initializers/custom_fields.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Possible Choices:
## type:
## - text
## - integer
## - boolean
## - date
## - url
## - select
## filter_logic:
## - disabled
## - loose
## - exact
##
## Examples:

# text_field:
# type: text
# label: Custom Text
Expand All @@ -22,8 +37,8 @@
# weight: 10
# on_objects:
# - tenancy.models.Tenant
# selection_field:
# type: selection
# select_field:
# type: select
# label: Choose between items
# required: false
# filter_logic: exact
Expand All @@ -41,8 +56,8 @@
# weight: 50
# - value: Fourth Item
# weight: 40
# selection_field_auto_weight:
# type: selection
# select_field_auto_weight:
# type: select
# label: Choose between items
# required: false
# filter_logic: loose
Expand Down
14 changes: 12 additions & 2 deletions initializers/dcim_interfaces.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
## Possible Choices:
## type:
## - virtual
## - lag
## - 1000base-t
## - ... and many more. See for yourself:
## https://github.com/netbox-community/netbox/blob/295d4f0394b431351c0cb2c3ecc791df68c6c2fb/netbox/dcim/choices.py#L510
##
## Examples:

# - device: server01
# enabled: true
# type: Virtual
# type: virtual
# name: to-server02
# - device: server02
# enabled: true
# type: Virtual
# type: virtual
# name: to-server01
21 changes: 18 additions & 3 deletions initializers/devices.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
## Possible Choices:
## face:
## - front
## - rear
## status:
## - offline
## - active
## - planned
## - staged
## - failed
## - inventory
## - decommissioning
##
## Examples:

# - name: server01
# device_role: server
# device_type: Other
# site: AMS 1
# rack: rack-01
# face: Front
# face: front
# position: 1
# custom_fields:
# text_field: Description
Expand All @@ -12,7 +27,7 @@
# device_type: Other
# site: AMS 2
# rack: rack-02
# face: Front
# face: front
# position: 2
# custom_fields:
# text_field: Description
Expand All @@ -21,7 +36,7 @@
# device_type: Other
# site: SING 1
# rack: rack-03
# face: Front
# face: front
# position: 3
# custom_fields:
# text_field: Description
30 changes: 24 additions & 6 deletions initializers/ip_addresses.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
## Possible Choices:
## status:
## - active
## - reserved
## - deprecated
## - dhcp
## role:
## - loopback
## - secondary
## - anycast
## - vip
## - vrrp
## - hsrp
## - glbp
## - carp
##
## Examples:

# - address: 10.1.1.1/24
# device: server01
# interface: to-server02
# status: Active
# status: active
# vrf: vrf1
# - address: 2001:db8:a000:1::1/64
# device: server01
# interface: to-server02
# status: Active
# status: active
# vrf: vrf1
# - address: 10.1.1.2/24
# device: server02
# interface: to-server01
# status: Active
# status: active
# - address: 2001:db8:a000:1::2/64
# device: server02
# interface: to-server01
# status: Active
# status: active
# - address: 10.1.1.10/24
# description: reserved IP
# status: Reserved
# status: reserved
# tenant: tenant1
# - address: 2001:db8:a000:1::10/64
# description: reserved IP
# status: Reserved
# status: reserved
# tenant: tenant1
15 changes: 12 additions & 3 deletions initializers/prefixes.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
## Possible Choices:
## status:
## - container
## - active
## - reserved
## - deprecated
##
## Examples:

# - description: prefix1
# prefix: 10.1.1.0/24
# site: AMS 1
# status: Active
# status: active
# tenant: tenant1
# vlan: vlan1
# - description: prefix2
# prefix: 10.1.2.0/24
# site: AMS 2
# status: Active
# status: active
# tenant: tenant2
# vlan: vlan2
# is_pool: true
# vrf: vrf2
# - description: ipv6 prefix1
# prefix: 2001:db8:a000:1::/64
# site: AMS 2
# status: Active
# status: active
# tenant: tenant2
# vlan: vlan2
28 changes: 22 additions & 6 deletions initializers/racks.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
## Possible Choices:
## width:
## - 19
## - 23
## types:
## - 2-post-frame
## - 4-post-frame
## - 4-post-cabinet
## - wall-frame
## - wall-cabinet
## outer_unit:
## - mm
## - in
##
## Examples:

# - site: AMS 1
# name: rack-01
# role: Role 1
# type: 4-post cabinet
# width: 19 inches
# type: 4-post-cabinet
# width: 19
# u_height: 47
# custom_fields:
# text_field: Description
# - site: AMS 2
# name: rack-02
# role: Role 2
# type: 4-post cabinet
# width: 19 inches
# type: 4-post-cabinet
# width: 19
# u_height: 47
# custom_fields:
# text_field: Description
# - site: SING 1
# name: rack-03
# group: cage 101
# role: Role 3
# type: 4-post cabinet
# width: 19 inches
# type: 4-post-cabinet
# width: 19
# u_height: 47
# custom_fields:
# text_field: Description
12 changes: 10 additions & 2 deletions initializers/virtual_machines.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
## Possible Choices:
## status:
## - active
## - offline
## - staged
##
## Examples:

# - cluster: cluster1
# comments: VM1
# disk: 200
# memory: 4096
# name: virtual machine 1
# platform: Platform 2
# status: Active
# status: active
# tenant: tenant1
# vcpus: 8
# - cluster: cluster1
Expand All @@ -13,6 +21,6 @@
# memory: 2048
# name: virtual machine 2
# platform: Platform 2
# status: Active
# status: active
# tenant: tenant1
# vcpus: 8
12 changes: 10 additions & 2 deletions initializers/vlans.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
## Possible Choices:
## status:
## - active
## - reserved
## - deprecated
##
## Examples:

# - name: vlan1
# site: AMS 1
# status: Active
# status: active
# vid: 5
# role: Main Management
# description: VLAN 5 for MGMT
# - group: VLAN group 2
# name: vlan2
# site: AMS 1
# status: Active
# status: active
# vid: 1300
Loading

0 comments on commit 8caf755

Please sign in to comment.