SYS Plugin for Netbox
A Netbox plugin for Create Virtual Machine Process.
Installation
1. Install our development environment
Requirements:
-
Python 3.11 (See Python best practices)
-
Netbox (Get it from https://github.com/netbox-community/netbox)
- Place it in your "PROJECTS" folder
- Change to version 3.6.9 (Checkout tag v3.6.9)
2. Prepare the plugin
2.1 - Reference the plugin to netbox
Add the plugin to the configuration file in netbox:
projects/netbox/netbox/netbox/configuration.py
PLUGINS = ['netbox_sys_plugin']
And check that the configurations for the database and redis match the ones in
projects/netbox-sys-plugin/netbox_configuration/configuration_testing.py
2.2 - Install the plugin
#Clone plugin repo
git clone https://code.europa.eu/digit-c4/netbox/netbox-sys-plugin.git
#Source virtual env from netbox
source netbox/venv/bin/activate
#Go to the plugin folder
cd ../netbox_sys_plugin
#Install poetry
pip install poetry
#Install the plugin
poetry install
3. Start Docker
#Start database and redis
docker compose up -d
4. Run Migrations
#Changes to the database
../netbox/netbox/manage.py migrate netbox_sys_plugin
5. Create User
#Changes to the database
../netbox/netbox/manage.py createsuperuser
6. Start Netbox
#Start Netbox
../netbox/netbox/manage.py runserver 0.0.0.0:8000 --insecure
Visit http://localhost:8000/ Use the credentials for the user you created
Run tests
After installing you development environment, you can run the tests plugin (you don't need to start the Netbox instance):
Run tests:
../netbox/netbox/manage.py test netbox_sys_plugin
Modification to the command:
To keep the testing database add the --keepdb
To keep the add console logs add the -v
and 1,2 or 3 to increase the detail
With code coverage Install coverage.py then run the tests and print the report:
coverage run --include='*/netbox-sys-plugin/*' ./../netbox/netbox/manage.py test netbox_sys_plugin.tests
coverage report -m