Skip to content

Commit

Permalink
netbox 3.6 support (#167)
Browse files Browse the repository at this point in the history
netbox 3.6 support thanks to @abhi1693 & @kbelokon
  • Loading branch information
ryanmerolle committed Mar 27, 2024
1 parent bc17018 commit f0b4616
Show file tree
Hide file tree
Showing 19 changed files with 315 additions and 332 deletions.
11 changes: 5 additions & 6 deletions .devcontainer/Dockerfile-plugin_dev
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
ARG NETBOX_VARIANT=v3.5
ARG NETBOX_VARIANT=v3.6

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

ARG NETBOX_INITIALIZERS_VARIANT=3.5.*
ARG NETBOX_INITIALIZERS_VARIANT=3.6.*

ARG DEBIAN_FRONTEND=noninteractive

# Install APT packages
# hadolint ignore=DL3008
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl git make openssh-client python3.10-dev sudo wget zsh \
&& apt-get -y install --no-install-recommends curl git make openssh-client python3.11-dev sudo wget zsh \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install development & ide dependencies
COPY requirements-dev.txt /tmp/pip-tmp/
RUN /opt/netbox/venv/bin/python3 -m pip install --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements-dev.txt \
&& rm -rf /tmp/*

ARG USERNAME=vscode
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN useradd -l -md /home/vscode -s /usr/bin/zsh -u $USER_UID $USERNAME \
&& usermod -aG sudo $USERNAME \
RUN usermod -aG sudo $USERNAME \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& mkdir /opt/netbox/netbox/netbox-acls \
&& chown $USERNAME:$USERNAME /opt/netbox /etc/netbox /opt/unit -R
Expand Down
363 changes: 194 additions & 169 deletions .devcontainer/configuration/configuration.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@
//"postAttachCommand": "source /opt/netbox/venv/bin/activate",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "ubuntu"
}
8 changes: 4 additions & 4 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ services:
interval: 15s
test: "curl -f http://localhost:8080/api/ || exit 1"
volumes:
- ./configuration:/etc/netbox/config:z,ro
#- ./reports:/etc/netbox/reports:z,ro
#- ./scripts:/etc/netbox/scripts:z,ro
#- netbox-media-files:/opt/netbox/netbox/media:z
- ./configuration:/etc/netbox/config:ro
#- netbox-media-files:/opt/netbox/netbox/media:rw
#- netbox-reports-files:/opt/netbox/netbox/reports:rw
#- netbox-scripts-files:/opt/netbox/netbox/scripts:rw
#netbox-worker:
# <<: *netbox
# depends_on:
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/env/netbox.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ REDIS_DATABASE=0
REDIS_HOST=redis
REDIS_INSECURE_SKIP_TLS_VERIFY=false
REDIS_PASSWORD=H733Kdjndks81
SECRET_KEY=r8OwDznj!!dciP9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNjaa
SECRET_KEY='r(m)9nLGnz$(_q3N4z1k(EFsMCjjjzx08x9VhNVcfd%6RF#r!6DE@+V5Zk2X'
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
SUPERUSER_EMAIL=admin@example.com
SUPERUSER_NAME=admin
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ body:
attributes:
label: NetBox access-list plugin version
description: What version of the NetBox access-list plugin are you currently running?
placeholder: v1.3.0
placeholder: v1.4.0
validations:
required: true
- type: input
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.5.4
placeholder: v3.6.3
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.5.4
placeholder: v3.6.3
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:

- id: docker-test
name: Test the image
run: ./test.sh snapshot
run: ./test.sh
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-docstring-first
- id: check-merge-conflict
Expand All @@ -21,24 +21,24 @@ repos:
- "--profile=black"
exclude: ^.devcontainer/
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
language_version: python3
exclude: ^.devcontainer/
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.5.1
rev: v3.1.0
hooks:
- id: add-trailing-comma
args:
- "--py36-plus"
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
exclude: ^.devcontainer/
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
rev: v3.15.0
hooks:
- id: pyupgrade
args:
Expand All @@ -59,11 +59,11 @@ repos:
# - id: htmlhint
# args: [--config, .htmlhintrc]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.35.0
rev: v0.37.0
hooks:
- id: markdownlint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272
rev: v0.0.292
hooks:
- id: ruff
#- repo: local
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG NETBOX_VARIANT=v3.5
ARG NETBOX_VARIANT=v3.6

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

RUN mkdir -pv /plugins/netbox-acls
COPY . /plugins/netbox-acls

RUN /opt/netbox/venv/bin/python3 /plugins/netbox-acls/setup.py develop && \
cp -rf /plugins/netbox-acls/netbox_acls/ /opt/netbox/venv/lib/python3.10/site-packages/netbox_acls
cp -rf /plugins/netbox-acls/netbox_acls/ /opt/netbox/venv/lib/python3.11/site-packages/netbox_acls
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ Each Plugin Version listed below has been tested with its corresponding NetBox V

| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
| 3.2 | 1.0.1 |
| 3.3 | 1.1.0 |
| 3.4 | 1.2.2 |
| 3.6 | 1.4.0 |
| 3.5 | 1.3.0 |
| 3.4 | 1.2.2 |
| 3.3 | 1.1.0 |
| 3.2 | 1.0.1 |

## Installing

Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ services:
build:
dockerfile: Dockerfile
context: .
args:
NETBOX_VARIANT: ${NETBOX_VARIANT}
depends_on:
- postgres
- redis
Expand All @@ -17,12 +15,12 @@ services:

# postgres
postgres:
image: postgres:14-alpine
image: postgres:15-alpine
env_file: env/postgres.env

# redis
redis:
image: redis:6-alpine
image: redis:7-alpine
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
Expand Down
2 changes: 1 addition & 1 deletion env/netbox.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ REDIS_DATABASE=0
REDIS_HOST=redis
REDIS_INSECURE_SKIP_TLS_VERIFY=false
REDIS_PASSWORD=H733Kdjndks81
SECRET_KEY=r8OwDznj!!dciP9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNjaa
SECRET_KEY='r(m)9nLGnz$(_q3N4z1k(EFsMCjjjzx08x9VhNVcfd%6RF#r!6DE@+V5Zk2X'
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
SUPERUSER_EMAIL=admin@example.com
SUPERUSER_NAME=admin
Expand Down
4 changes: 2 additions & 2 deletions netbox_acls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class NetBoxACLsConfig(PluginConfig):
version = __version__
description = "Manage simple ACLs in NetBox"
base_url = "access-lists"
min_version = "3.5.0"
max_version = "3.5.99"
min_version = "3.6.0"
max_version = "3.6.99"


config = NetBoxACLsConfig
13 changes: 6 additions & 7 deletions netbox_acls/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ipam.models import Prefix
from netbox.forms import NetBoxModelFilterSetForm
from utilities.forms.fields import (
ChoiceField,
DynamicModelChoiceField,
DynamicModelMultipleChoiceField,
TagFilterField,
Expand Down Expand Up @@ -74,11 +73,11 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
queryset=VirtualChassis.objects.all(),
required=False,
)
type = ChoiceField(
type = forms.ChoiceField(
choices=add_blank_choice(ACLTypeChoices),
required=False,
)
default_action = ChoiceField(
default_action = forms.ChoiceField(
choices=add_blank_choice(ACLActionChoices),
required=False,
label="Default Action",
Expand Down Expand Up @@ -158,7 +157,7 @@ class ACLInterfaceAssignmentFilterForm(NetBoxModelFilterSetForm):
},
label="Access List",
)
direction = ChoiceField(
direction = forms.ChoiceField(
choices=add_blank_choice(ACLAssignmentDirectionChoices),
required=False,
)
Expand Down Expand Up @@ -187,7 +186,7 @@ class ACLStandardRuleFilterForm(NetBoxModelFilterSetForm):
required=False,
label="Source Prefix",
)
action = ChoiceField(
action = forms.ChoiceField(
choices=add_blank_choice(ACLRuleActionChoices),
required=False,
)
Expand All @@ -211,7 +210,7 @@ class ACLExtendedRuleFilterForm(NetBoxModelFilterSetForm):
queryset=AccessList.objects.all(),
required=False,
)
action = ChoiceField(
action = forms.ChoiceField(
choices=add_blank_choice(ACLRuleActionChoices),
required=False,
)
Expand All @@ -225,7 +224,7 @@ class ACLExtendedRuleFilterForm(NetBoxModelFilterSetForm):
required=False,
label="Destination Prefix",
)
protocol = ChoiceField(
protocol = forms.ChoiceField(
choices=add_blank_choice(ACLProtocolChoices),
required=False,
)
Expand Down
Loading

0 comments on commit f0b4616

Please sign in to comment.