Merge pull request #557 from netbox-community/develop

Version 1.3.0: Compatibility with Netbox v3
This commit is contained in:
Tobias Genannt 2021-08-30 21:29:25 +02:00 committed by GitHub
commit 6c5434ee20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 34 additions and 41 deletions

View File

@ -19,7 +19,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- name: Lint Code Base - name: Lint Code Base
uses: github/super-linter@v3 uses: github/super-linter@v4
env: env:
DEFAULT_BRANCH: develop DEFAULT_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -11,7 +11,7 @@ RUN apk add --no-cache \
jpeg-dev \ jpeg-dev \
libevent-dev \ libevent-dev \
libffi-dev \ libffi-dev \
libressl-dev \ openssl-dev \
libxslt-dev \ libxslt-dev \
musl-dev \ musl-dev \
openldap-dev \ openldap-dev \
@ -45,12 +45,11 @@ RUN apk add --no-cache \
libevent \ libevent \
libffi \ libffi \
libjpeg-turbo \ libjpeg-turbo \
libressl \ openssl \
libxslt \ libxslt \
postgresql-libs \ postgresql-libs \
python3 \ python3 \
py3-pip \ py3-pip \
ttf-ubuntu-font-family \
unit \ unit \
unit-python3 unit-python3
@ -75,6 +74,8 @@ WORKDIR /opt/netbox/netbox
# to g+w so that pictures can be uploaded to netbox. # to g+w so that pictures can be uploaded to netbox.
RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
&& chmod -R g+w media /opt/unit/ \ && chmod -R g+w media /opt/unit/ \
&& cd /opt/netbox/ && /opt/netbox/venv/bin/python -m mkdocs build \
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input && SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ] ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ]

View File

@ -1 +1 @@
1.2.0 1.3.0

View File

@ -49,7 +49,7 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
echo " DOCKERFILE The name of Dockerfile to use." echo " DOCKERFILE The name of Dockerfile to use."
echo " Default: Dockerfile" echo " Default: Dockerfile"
echo " DOCKER_FROM The base image to use." echo " DOCKER_FROM The base image to use."
echo " Default: 'alpine:3.13'" echo " Default: 'alpine:3.14'"
echo " DOCKER_TARGET A specific target to build." echo " DOCKER_TARGET A specific target to build."
echo " It's currently not possible to pass multiple targets." echo " It's currently not possible to pass multiple targets."
echo " Default: main ldap" echo " Default: main ldap"
@ -125,7 +125,7 @@ if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
( (
$DRY cd "${NETBOX_PATH}" $DRY cd "${NETBOX_PATH}"
# shellcheck disable=SC2030
if [ -n "${HTTP_PROXY}" ]; then if [ -n "${HTTP_PROXY}" ]; then
git config http.proxy "${HTTP_PROXY}" git config http.proxy "${HTTP_PROXY}"
fi fi
@ -157,7 +157,7 @@ fi
# Determining the value for DOCKER_FROM # Determining the value for DOCKER_FROM
### ###
if [ -z "$DOCKER_FROM" ]; then if [ -z "$DOCKER_FROM" ]; then
DOCKER_FROM="alpine:3.13" DOCKER_FROM="alpine:3.14"
fi fi
### ###
@ -345,6 +345,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
if [ -n "${DOCKER_FROM}" ]; then if [ -n "${DOCKER_FROM}" ]; then
DOCKER_BUILD_ARGS+=(--build-arg "FROM=${DOCKER_FROM}") DOCKER_BUILD_ARGS+=(--build-arg "FROM=${DOCKER_FROM}")
fi fi
# shellcheck disable=SC2031
if [ -n "${HTTP_PROXY}" ]; then if [ -n "${HTTP_PROXY}" ]; then
DOCKER_BUILD_ARGS+=(--build-arg "http_proxy=${HTTP_PROXY}") DOCKER_BUILD_ARGS+=(--build-arg "http_proxy=${HTTP_PROXY}")
DOCKER_BUILD_ARGS+=(--build-arg "https_proxy=${HTTPS_PROXY}") DOCKER_BUILD_ARGS+=(--build-arg "https_proxy=${HTTPS_PROXY}")

View File

@ -48,6 +48,8 @@ DATABASE = {
# Database connection SSLMODE # Database connection SSLMODE
'CONN_MAX_AGE': int(environ.get('DB_CONN_MAX_AGE', '300')), 'CONN_MAX_AGE': int(environ.get('DB_CONN_MAX_AGE', '300')),
# Max database connection age # Max database connection age
'DISABLE_SERVER_SIDE_CURSORS': environ.get('DB_DISABLE_SERVER_SIDE_CURSORS', 'False').lower() == 'true',
# Disable the use of server-side cursors transaction pooling
} }
# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate # Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate
@ -106,9 +108,6 @@ BANNER_LOGIN = environ.get('BANNER_LOGIN', '')
# BASE_PATH = 'netbox/' # BASE_PATH = 'netbox/'
BASE_PATH = environ.get('BASE_PATH', '') BASE_PATH = environ.get('BASE_PATH', '')
# Cache timeout in seconds. Set to 0 to dissable caching. Defaults to 900 (15 minutes)
CACHE_TIMEOUT = int(environ.get('CACHE_TIMEOUT', 900))
# Maximum number of days to retain logged changes. Set to 0 to retain changes indefinitely. (Default: 90) # Maximum number of days to retain logged changes. Set to 0 to retain changes indefinitely. (Default: 90)
CHANGELOG_RETENTION = int(environ.get('CHANGELOG_RETENTION', 90)) CHANGELOG_RETENTION = int(environ.get('CHANGELOG_RETENTION', 90))
@ -210,9 +209,6 @@ REMOTE_AUTH_HEADER = environ.get('REMOTE_AUTH_HEADER', 'HTTP_REMOTE_USER')
REMOTE_AUTH_AUTO_CREATE_USER = environ.get('REMOTE_AUTH_AUTO_CREATE_USER', 'True').lower() == 'true' REMOTE_AUTH_AUTO_CREATE_USER = environ.get('REMOTE_AUTH_AUTO_CREATE_USER', 'True').lower() == 'true'
REMOTE_AUTH_DEFAULT_GROUPS = list(filter(None, environ.get('REMOTE_AUTH_DEFAULT_GROUPS', '').split(' '))) REMOTE_AUTH_DEFAULT_GROUPS = list(filter(None, environ.get('REMOTE_AUTH_DEFAULT_GROUPS', '').split(' ')))
# This determines how often the GitHub API is called to check the latest release of NetBox. Must be at least 1 hour.
RELEASE_CHECK_TIMEOUT = int(environ.get('RELEASE_CHECK_TIMEOUT', 24 * 3600))
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the # 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. # version check or use the URL below to check for release in the official NetBox repository.
# https://api.github.com/repos/netbox-community/netbox/releases # https://api.github.com/repos/netbox-community/netbox/releases

View File

@ -20,7 +20,7 @@ services:
ports: ports:
- 8080 - 8080
postgres: postgres:
image: postgres:12-alpine image: postgres:13-alpine
env_file: env/postgres.env env_file: env/postgres.env
redis: redis:
image: redis:6-alpine image: redis:6-alpine

View File

@ -1,7 +1,7 @@
version: '3.4' version: '3.4'
services: services:
netbox: &netbox netbox: &netbox
image: netboxcommunity/netbox:${VERSION-latest} image: netboxcommunity/netbox:${VERSION-v3.0}
depends_on: depends_on:
- postgres - postgres
- redis - redis
@ -29,7 +29,7 @@ services:
# postgres # postgres
postgres: postgres:
image: postgres:12-alpine image: postgres:13-alpine
env_file: env/postgres.env env_file: env/postgres.env
volumes: volumes:
- netbox-postgres-data:/var/lib/postgresql/data - netbox-postgres-data:/var/lib/postgresql/data

View File

@ -15,7 +15,7 @@ source /opt/netbox/venv/bin/activate
DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3} DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3}
MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30} MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30}
CUR_DB_WAIT_TIME=0 CUR_DB_WAIT_TIME=0
while ! ./manage.py migrate 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do while ! ./manage.py showmigrations >/dev/null 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do
echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)" echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)"
sleep "${DB_WAIT_TIMEOUT}" sleep "${DB_WAIT_TIMEOUT}"
CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT)) CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT))
@ -24,6 +24,17 @@ if [ "${CUR_DB_WAIT_TIME}" -ge "${MAX_DB_WAIT_TIME}" ]; then
echo "❌ Waited ${MAX_DB_WAIT_TIME}s or more for the DB to become ready." echo "❌ Waited ${MAX_DB_WAIT_TIME}s or more for the DB to become ready."
exit 1 exit 1
fi fi
# Check if update is needed
if ! ./manage.py migrate --check >/dev/null 2>&1; then
echo "⚙️ Applying database migrations"
./manage.py migrate --no-input
echo "⚙️ Running trace_paths"
./manage.py trace_paths --no-input
echo "⚙️ Removing stale content types"
./manage.py remove_stale_contenttypes --no-input
echo "⚙️ Removing expired user sessions"
./manage.py clearsessions
fi
# Create Superuser if required # Create Superuser if required
if [ "$SKIP_SUPERUSER" == "true" ]; then if [ "$SKIP_SUPERUSER" == "true" ]; then

View File

@ -1,4 +0,0 @@
# - name: Super Secret Passwords
# slug: super-secret
# - name: SNMP Communities
# slug: snmp

View File

@ -20,6 +20,7 @@
# status: active # status: active
# facility: Amsterdam 3 # facility: Amsterdam 3
# asn: 67890 # asn: 67890
# tenant: tenant1
# custom_field_data: # custom_field_data:
# text_field: Description for AMS3 # text_field: Description for AMS3
# - name: SING 1 # - name: SING 1
@ -28,5 +29,6 @@
# status: active # status: active
# facility: Singapore 1 # facility: Singapore 1
# asn: 09876 # asn: 09876
# tenant: tenant2
# custom_field_data: # custom_field_data:
# text_field: Description for SING1 # text_field: Description for SING1

View File

@ -1,6 +1,7 @@
{ {
"extends": [ "extends": [
"config:base" "config:base",
":disableDependencyDashboard"
], ],
"enabled": true, "enabled": true,
"labels": ["maintenance"], "labels": ["maintenance"],

View File

@ -1,4 +1,4 @@
napalm==3.2.0 napalm==3.3.1
ruamel.yaml==0.17.4 ruamel.yaml==0.17.16
django-auth-ldap==2.4.0 django-auth-ldap==3.0.0
django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1

View File

@ -1,15 +0,0 @@
import sys
from secrets.models import SecretRole
from startup_script_utils import load_yaml
secret_roles = load_yaml("/opt/netbox/initializers/secret_roles.yml")
if secret_roles is None:
sys.exit()
for params in secret_roles:
secret_role, created = SecretRole.objects.get_or_create(**params)
if created:
print("🔑 Created Secret Role", secret_role.name)