Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @leoparente @ltucker @mfiedorowicz
* @jajeffries @leoparente @ltucker @mfiedorowicz @MicahParks
15 changes: 13 additions & 2 deletions .github/workflows/lint-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
strategy:
matrix:
python: [ "3.10" ]
netbox: [ "", "v4.2.3" ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -40,15 +41,25 @@ jobs:
pip install .[dev]
pip install .[test]
- name: Lint with Ruff
id: lint
run: |
ruff check --output-format=github netbox_diode_plugin/
continue-on-error: true
- name: Test
id: test
run: |
make docker-compose-netbox-plugin-test-cover
make NETBOX_VERSION=${{ matrix.netbox }} docker-compose-netbox-plugin-test-cover
continue-on-error: true
- name: Check results
if: always()
run: |
if [[ "${{ steps.lint.outcome }}" == "failure" || "${{ steps.test.outcome }}" == "failure" ]]; then
echo "Either linting or tests failed"
exit 1
fi
- name: Coverage comment
uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2
if: github.event.pull_request.head.repo.full_name == github.repository
if: github.event.pull_request.head.repo.full_name == github.repository && matrix.netbox == ''
with:
coverageFile: ./docker/coverage/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dist/
# Docker
docker/coverage
!docker/netbox/env
!docker/*/netbox/env
docker/oauth2/secrets/*
!docker/oauth2/secrets/.gitkeep
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,42 @@ else
DOCKER_COMPOSE := docker-compose
endif

NETBOX_VERSION ?=
ifneq ($(NETBOX_VERSION),)
DOCKER_PATH := docker/$(NETBOX_VERSION)
TEST_SELECTOR := "/opt/netbox/netbox/netbox_diode_plugin/tests/$(NETBOX_VERSION)/tests/"
else
DOCKER_PATH := docker
TEST_SELECTOR = netbox_diode_plugin
endif

.PHONY: docker-compose-netbox-plugin-up
docker-compose-netbox-plugin-up:
@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml up -d --build
@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml up -d --build

.PHONY: docker-compose-netbox-plugin-down
docker-compose-netbox-plugin-down:
@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml down
@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml down

.PHONY: docker-compose-netbox-plugin-test
docker-compose-netbox-plugin-test:
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run -u root --rm netbox ./manage.py test $(TEST_FLAGS) --keepdb netbox_diode_plugin
-@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml -f $(DOCKER_PATH)/docker-compose.test.yaml run -u root --rm netbox ./manage.py test $(TEST_FLAGS) --keepdb $(TEST_SELECTOR)
@$(MAKE) docker-compose-netbox-plugin-down

.PHONY: docker-compose-netbox-plugin-test-lint
docker-compose-netbox-plugin-test-lint:
-@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml -f $(DOCKER_PATH)/docker-compose.test.yaml run -u root --rm netbox ruff check --output-format=github netbox_diode_plugin
@$(MAKE) docker-compose-netbox-plugin-down

.PHONY: docker-compose-netbox-plugin-test-cover
docker-compose-netbox-plugin-test-cover:
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run --rm -u root -e COVERAGE_FILE=/opt/netbox/netbox/coverage/.coverage netbox sh -c "coverage run --source=netbox_diode_plugin --omit=*/migrations/* ./manage.py test --keepdb netbox_diode_plugin && coverage xml -o /opt/netbox/netbox/coverage/report.xml && coverage report -m | tee /opt/netbox/netbox/coverage/report.txt"
-@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml -f $(DOCKER_PATH)/docker-compose.test.yaml run --rm -u root -e COVERAGE_FILE=/opt/netbox/netbox/coverage/.coverage netbox sh -c "coverage run --source=netbox_diode_plugin --omit=*/migrations/* ./manage.py test --keepdb $(TEST_SELECTOR) && coverage xml -o /opt/netbox/netbox/coverage/report.xml && coverage report -m | tee /opt/netbox/netbox/coverage/report.txt"
@$(MAKE) docker-compose-netbox-plugin-down

.PHONY: docker-compose-generate-matching-docs
docker-compose-generate-matching-docs:
@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml -f $(DOCKER_PATH)/docker-compose.test.yaml run --rm netbox python manage.py generate_matching_docs | awk '/Generating markdown documentation.../{p=1;next} p' > ./docs/matching-criteria-documentation.md

.PHONY: docker-compose-migrate
docker-compose-migrate:
@$(DOCKER_COMPOSE) -f $(DOCKER_PATH)/docker-compose.yaml -f $(DOCKER_PATH)/docker-compose.test.yaml run --rm netbox python manage.py migrate
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ cd /opt/netbox/netbox
make docker-compose-netbox-plugin-test
```

## Generating Documentation
Generates documentation on how diode entities are matched. The generated documentation is output to [here](./docs/matching-criteria-documentation.md).
```shell
make docker-compose-generate-matching-docs
```

## License

Distributed under the NetBox Limited Use License 1.0. See [LICENSE.md](./LICENSE.md) for more information.
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile-diode-netbox-plugin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM netboxcommunity/netbox:v4.2.3-3.1.1
FROM netboxcommunity/netbox:v4.3.3-3.3.0

COPY ./netbox/configuration/ /etc/netbox/config/
RUN chmod 755 /etc/netbox/config/* && \
Expand All @@ -9,4 +9,5 @@ RUN chmod 755 /opt/netbox/netbox/netbox/local_settings.py && \
chown unit:root /opt/netbox/netbox/netbox/local_settings.py

COPY ./requirements-diode-netbox-plugin.txt /opt/netbox/
RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/requirements-diode-netbox-plugin.txt
ENV VIRTUAL_ENV=/opt/netbox/venv
RUN /usr/local/bin/uv pip install -r /opt/netbox/requirements-diode-netbox-plugin.txt
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: diode-netbox-plugin
services:
netbox: &netbox
image: netboxcommunity/netbox:v4.2.3-3.1.1-diode-netbox-plugin
image: netboxcommunity/netbox:v4.3.3-3.3.0-diode-netbox-plugin
build:
context: .
dockerfile: Dockerfile-diode-netbox-plugin
Expand Down
4 changes: 2 additions & 2 deletions docker/requirements-diode-netbox-plugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Brotli==1.1.0
certifi==2024.7.4
coverage==7.6.0
grpcio==1.62.1
protobuf==5.28.1
protobuf==5.29.5
pytest==8.0.2
netboxlabs-netbox-branching==0.5.7
netboxlabs-netbox-branching==0.6.0
12 changes: 12 additions & 0 deletions docker/v4.2.3/Dockerfile-diode-netbox-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM netboxcommunity/netbox:v4.2.3-3.1.1

COPY ./netbox/configuration/ /etc/netbox/config/
RUN chmod 755 /etc/netbox/config/* && \
chown unit:root /etc/netbox/config/*

COPY ./netbox/local_settings.py /opt/netbox/netbox/netbox/local_settings.py
RUN chmod 755 /opt/netbox/netbox/netbox/local_settings.py && \
chown unit:root /opt/netbox/netbox/netbox/local_settings.py

COPY ./requirements-diode-netbox-plugin.txt /opt/netbox/
RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/requirements-diode-netbox-plugin.txt
5 changes: 5 additions & 0 deletions docker/v4.2.3/docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: diode-netbox-plugin-4.2.3
services:
netbox:
volumes:
- ./netbox/plugins_test.py:/etc/netbox/config/plugins.py:z,ro
92 changes: 92 additions & 0 deletions docker/v4.2.3/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: diode-netbox-plugin-4.2.3
services:
netbox: &netbox
image: netboxcommunity/netbox:v4.2.3-3.1.1-diode-netbox-plugin
build:
context: .
dockerfile: Dockerfile-diode-netbox-plugin
pull: true
depends_on:
- netbox-postgres
- netbox-redis
- netbox-redis-cache
env_file: netbox/env/netbox.env
user: 'unit:root'
healthcheck:
start_period: 60s
timeout: 3s
interval: 15s
test: "curl -f http://localhost:8080/netbox/api/ || exit 1"
volumes:
- ./netbox/docker-entrypoint.sh:/opt/netbox/docker-entrypoint.sh:z,ro
- ./netbox/nginx-unit.json:/opt/netbox/nginx-unit.json:z,ro
- ../../netbox_diode_plugin:/opt/netbox/netbox/netbox_diode_plugin:z,rw
- ../oauth2/secrets:/run/secrets:z,ro
- ./netbox/launch-netbox.sh:/opt/netbox/launch-netbox.sh:z,ro
- ./netbox/plugins_dev.py:/etc/netbox/config/plugins.py:z,ro
- ./coverage:/opt/netbox/netbox/coverage:z,rw
- netbox-media-files:/opt/netbox/netbox/media:rw
- netbox-reports-files:/opt/netbox/netbox/reports:rw
- netbox-scripts-files:/opt/netbox/netbox/scripts:rw
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8000:8080"

netbox-worker:
<<: *netbox
depends_on:
netbox:
condition: service_healthy
command:
- /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py
- rqworker
healthcheck:
test: ps -aux | grep -v grep | grep -q rqworker || exit 1
start_period: 20s
timeout: 3s
interval: 15s
ports: []

# postgres
netbox-postgres:
image: docker.io/postgres:16-alpine
env_file: netbox/env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data

# redis
netbox-redis:
image: docker.io/redis:7-alpine
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
env_file: netbox/env/redis.env
volumes:
- netbox-redis-data:/data

netbox-redis-cache:
image: docker.io/redis:7-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: netbox/env/redis-cache.env
volumes:
- netbox-redis-cache-data:/data

volumes:
netbox-media-files:
driver: local
netbox-postgres-data:
driver: local
netbox-redis-cache-data:
driver: local
netbox-redis-data:
driver: local
netbox-reports-files:
driver: local
netbox-scripts-files:
driver: local
Loading