Closed jamiereid closed 1 year ago
Hi @jamiereid, please provide the following:
Download the netboxcommunity/netbox-docker files for modification
git clone -b release https://github.com/netbox-community/netbox-docker.git
cd netbox-docker
Add 'Validity' plugin to plugin_requirements.txt
echo 'netbox-validity==1.3.1' >> plugin_requirements.txt
Create Dockerfile-Plugins
for custom container with the following contents
FROM netboxcommunity/netbox:latest
COPY ./plugin_requirements.txt /opt/netbox RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/plugin_requirements.txt
4. Create `docker-compose.override.yml` with the following contents
```yml
version: '3.4' # This is NOT the version of NetBox! No need to adjust :)
services:
netbox:
image: netbox:latest-plugins
ports:
- 8000:8080
build:
context: .
dockerfile: Dockerfile-Plugins
netbox-worker:
image: netbox:latest-plugins
build:
context: .
dockerfile: Dockerfile-Plugins
netbox-housekeeping:
image: netbox:latest-plugins
build:
context: .
dockerfile: Dockerfile-Plugins
Enable 'Validity' plugin in configuration/plugins.py
echo 'PLUGINS = ["validity"]' >> configuration/plugins.py
Start the containers
docker compose up
Once the container is 'healthy' (seen in docker ps
) you can create an admin user
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
Log into Netbox as the super user you just created and add a git repo to Validity.
Attempt to sync the git repo by either clicking the "Sync" button, or running the validity_git
script
Internal Server Error: /extras/scripts/validity_git/SyncGitRepos/
Traceback (most recent call last):
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/netbox/netbox/utilities/views.py", line 53, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
return handler(request, *args, **kwargs)
File "/opt/netbox/netbox/extras/views.py", line 1073, in post
module = get_object_or_404(ScriptModule.objects.restrict(request.user), file_path__startswith=module)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/shortcuts.py", line 85, in get_object_or_404
return queryset.get(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 653, in get
raise self.model.MultipleObjectsReturned(
extras.models.scripts.ScriptModule.MultipleObjectsReturned: get() returned more than one ScriptModule -- it returned 2!
I noticed there were some .pyc
files in the netbox/scripts
directory:
__init__.cpython-310.pyc
validity_git.cpython-310.pyc
validity_run_tests.cpython-310.pyc
After deleting these, I am able to run the script to sync.
Yeah, the problem was these .pyc files should not become script modules but they actually did. The easiest way to fix it is just manual deletion of these .pyc modules from netbox UI as you've mentioned. I've fixed it and they won't appear in the scripts section starting from the next validity version
Netbox Version: 3.5.8 Validity Version: 1.3.1
When attempting to sync git repos, the following exception is raised.
If there is more information I can provide to help narrow down the issue, please let me know.