# Conflicts:
#	README.md
#	netbox_slm/__init__.py
This commit is contained in:
MrBlake committed 2026-10-21 14:06:20 +02:00
commit 8e18ae82b8
6 files changed
+166 -184

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
### Fixed
* Add the missing migration for the platform constraint's error message (verified against NetBox 4.7.2)
* Make the required single platform destination explicit when creating an installation
* Fix installation form submission on NetBox v4.6.5 when form mixins return no cleaned-data value
* Prevent the notification log creation flag from shadowing Django's translation function during email delivery
+144 -158
View File
@@ -1,105 +1,74 @@
# NetBox SLM
NetBox SLM erweitert NetBox um die Verwaltung von Softwareprodukten, Versionen, Installationen, Lizenzen und
Zertifikaten.
Lizenzen können optional einer NetBox-Mandantengruppe und einem Mandanten zugeordnet werden.
Software lifecycle and license management for NetBox: software products,
versions, installations, licenses and certificates — with expiry notifications
and optional tenant assignment.
Diese Variante ist für **NetBox 4.6.5** vorgesehen.
| | |
|---|---|
| **Plugin name** | `netbox_slm` |
| **Package** | `netbox-slm` |
| **NetBox** | `4.6.5` – `4.7.x` |
| **Python** | `>=3.11` |
| **Repository** | <https://git.mrblake.cc/MrBlake/NetBox-SLM> |
Die Oberfläche ist auf Englisch und Deutsch verfügbar. Die Sprache richtet sich nach der in NetBox für den
Benutzer ausgewählten Sprache.
## Features
## Funktionen
- Manage software products and manufacturers
- Track versions, release types and support periods
- Assign installations to devices, virtual machines or clusters
- Manage software licenses including term, scope and storage location
- Lifetime licenses or renewal intervals in days, months or years
- Store license files, license keys and links to the vendor portal
- Expiry warnings one month and one week before license end by default
- Additional custom warning period in days, weeks or months
- NetBox notifications and optional e-mail via NetBox's SMTP configuration
- Assign licenses to tenant groups and tenants
- Manage certificates with common name, SANs, issuer, serial number, fingerprint and validity period
- Assign certificates to software products, installations, devices, virtual machines and tenants
- Store certificate files and storage locations (private keys are intentionally not stored)
- Full NetBox UI and REST API
- Filters, bulk import and bulk edit
- UI available in English and German (follows the user's NetBox language)
- Softwareprodukte und Hersteller verwalten
- Versionen, Release-Typen und Supportzeiträume erfassen
- Installationen Geräten, virtuellen Maschinen oder Clustern zuordnen
- Softwarelizenzen einschließlich Laufzeit, Umfang und Ablageort verwalten
- Lifetime-Lizenzen oder Erneuerungsintervalle in Tagen, Monaten oder Jahren erfassen
- Lizenzdateien, Lizenzschlüssel und Links zum Anbieterportal hinterlegen
- Ablaufwarnungen standardmäßig einen Monat und eine Woche vor Lizenzende
- Zusätzliche eigene Vorwarnzeit in Tagen, Wochen oder Monaten
- NetBox-Benachrichtigungen und optionaler E-Mail-Versand über die NetBox-SMTP-Konfiguration
- Lizenzen Mandantengruppen und Mandanten zuordnen
- Zertifikate mit Common Name, SANs, Aussteller, Seriennummer, Fingerabdruck und Gültigkeitszeitraum verwalten
- Zertifikate Softwareprodukten, Installationen, Geräten, virtuellen Maschinen und Mandanten zuordnen
- Zertifikatsdateien und Ablageorte hinterlegen (keine privaten Schlüssel)
- Bedienung über die NetBox-Oberfläche und REST-API
- Filter, Bulk-Import und Bulk-Bearbeitung
> **Note:** License keys are stored in the NetBox database and license files in
> NetBox's media directory. Protect and back up the database, REST API and media
> directory accordingly.
> **Hinweis:** Lizenzschlüssel werden in der NetBox-Datenbank und Lizenzdateien im konfigurierten NetBox-
> Medienverzeichnis gespeichert. Der Zugriff auf Datenbank, REST-API und Medienverzeichnis sollte entsprechend
> geschützt und gesichert werden.
## Compatibility
- NetBox `4.6.5` – `4.7.x` (verified with 4.7.2)
- Python `>=3.11`
## Installation
NetBox installiert lokale Erweiterungen aus `/opt/netbox/local_requirements.txt`. Die Git-URL muss dort dauerhaft
eingetragen werden, damit das Plugin bei einem späteren NetBox-Upgrade erneut installiert wird.
All paths assume a standard installation under `/opt/netbox`.
### 1. Git-Repository als lokale Anforderung eintragen
```bash
echo "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git" >> /opt/netbox/local_requirements.txt
```
Vorher kann geprüft werden, ob der Eintrag bereits vorhanden ist:
```bash
grep -qxF "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git" /opt/netbox/local_requirements.txt || \
echo "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git" >> /opt/netbox/local_requirements.txt
```
### 2. Plugin mit Pip installieren
Die Installation muss im Python-Virtual-Environment von NetBox erfolgen:
### 1. Install the package
```bash
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
"git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git"
"git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git@master"
```
Alternativ können alle lokalen Anforderungen installiert werden:
For reproducible production installs, replace `master` with a release tag or a
full commit ID.
### 2. Add the plugin to `local_requirements.txt`
This makes `upgrade.sh` reinstall the plugin automatically on every NetBox upgrade:
```bash
/opt/netbox/venv/bin/pip install -r /opt/netbox/local_requirements.txt
grep -qxF "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git@master" /opt/netbox/local_requirements.txt \
|| echo "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git@master" | sudo tee -a /opt/netbox/local_requirements.txt
```
Die installierte Version kann anschließend geprüft werden:
If the repository is private, the NetBox server needs a read-only deploy token
or an SSH key. Do not store credentials in `local_requirements.txt`.
```bash
/opt/netbox/venv/bin/pip show netbox-slm
```
### 3. Enable the plugin
Für diese Variante muss dort mindestens Version `1.12.0` stehen.
## Ablaufbenachrichtigungen
Für Lizenzen und Zertifikate mit Ablaufdatum sind Benachrichtigungen standardmäßig aktiviert. Beide Objekttypen
verwenden dieselben Einstellungen; die folgenden Abschnitte gelten daher für Zertifikate entsprechend. Die Standardtermine liegen einen
Monat und eine Woche vor dem Ablaufdatum. Pro Lizenz kann zusätzlich eine eigene Vorwarnzeit festgelegt oder die
Standardtermine deaktiviert werden.
Empfänger entscheiden selbst, ob sie informiert werden: Vertrieb, zuständiger Techniker oder andere Benutzer öffnen
die Lizenz und wählen die NetBox-Aktion **Abonnieren**. Mit **Abonnement beenden** können sie die Meldungen wieder
abschalten. Ohne Abonnenten wird keine Nachricht versendet.
Die NetBox-Nachricht wird immer erzeugt. Wird an der Lizenz zusätzlich **E-Mail-Benachrichtigungen** aktiviert, sendet
das Plugin auch eine E-Mail an die im Benutzerkonto hinterlegte Adresse. Dafür muss der SMTP-Versand in NetBox
konfiguriert sein.
Die Aktivierung des E-Mail-Versands darf nur durch Administratoren oder Benutzer mit der Berechtigung
`netbox_slm.manage_softwarelicense_email_notifications` (Lizenzen) bzw.
`netbox_slm.manage_certificate_email_notifications` (Zertifikate) geändert werden. Die eigentlichen SMTP-Zugangsdaten werden
ausschließlich in der NetBox-Serverkonfiguration gepflegt und sind im Plugin nicht einsehbar.
Die Prüfung läuft einmal täglich als NetBox-Systemjob (je ein Job für Lizenzen und Zertifikate). Sobald der erste konfigurierte Erinnerungstermin erreicht ist,
werden die Abonnenten bei jedem Joblauf erneut informiert: immer über NetBox und bei aktivierter E-Mail-Option
zusätzlich per SMTP. Dies wird bis einschließlich des Ablaufdatums wiederholt. Der NetBox-RQ-Worker muss dafür mit
Scheduler-Unterstützung laufen; dies ist bei der regulären NetBox-Installation mit `rqworker` standardmäßig der Fall.
### 3. Plugin in NetBox aktivieren
In `/opt/netbox/netbox/netbox/configuration.py` ergänzen:
In `/opt/netbox/netbox/netbox/configuration.py`:
```python
PLUGINS = [
@@ -107,105 +76,122 @@ PLUGINS = [
]
```
Falls bereits andere Plugins eingetragen sind, wird `"netbox_slm"` lediglich zur vorhandenen Liste hinzugefügt.
Eine zusätzliche `PLUGINS_CONFIG`-Konfiguration ist für den Standardbetrieb nicht erforderlich.
If other plugins are already configured, add `netbox_slm` to the existing list.
No `PLUGINS_CONFIG` is required for standard operation.
### 4. Datenbank migrieren und statische Dateien aktualisieren
### 4. Apply migrations, collect static files, restart
```bash
cd /opt/netbox/netbox
/opt/netbox/venv/bin/python manage.py migrate
/opt/netbox/venv/bin/python manage.py migrate netbox_slm
/opt/netbox/venv/bin/python manage.py collectstatic --no-input
```
### 5. NetBox-Dienste neu starten
Bei einer üblichen systemd-Installation:
```bash
sudo systemctl restart netbox netbox-rq
```
Je nach Installation können die Namen der Dienste abweichen.
Check the installed version:
## Aktualisierung
```bash
/opt/netbox/venv/bin/pip show netbox-slm
```
## Update
```bash
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
"git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git"
"git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git@master"
cd /opt/netbox/netbox
/opt/netbox/venv/bin/python manage.py migrate
/opt/netbox/venv/bin/python manage.py migrate netbox_slm
/opt/netbox/venv/bin/python manage.py collectstatic --no-input
sudo systemctl restart netbox netbox-rq
```
Der Eintrag in `/opt/netbox/local_requirements.txt` bleibt dabei bestehen.
`--force-reinstall` makes pip pick up branch changes even if the package
version has not been bumped.
## Deinstallation
When NetBox itself is upgraded, `upgrade.sh` reinstalls the plugin from
`local_requirements.txt` and runs migrations and `collectstatic`:
1. `"netbox_slm"` aus der `PLUGINS`-Liste entfernen.
2. Die Git-Zeile aus `/opt/netbox/local_requirements.txt` entfernen.
3. Das Python-Paket deinstallieren:
```bash
sudo /opt/netbox/upgrade.sh
sudo systemctl restart netbox netbox-rq
```
## Uninstall
1. Remove `"netbox_slm"` from `PLUGINS`.
2. Remove the line from `/opt/netbox/local_requirements.txt`.
3. Uninstall the package and restart NetBox:
```bash
/opt/netbox/venv/bin/pip uninstall netbox-slm
```
Die Plugin-Tabellen werden dabei nicht automatisch aus der Datenbank gelöscht.
## Ursprung und Lizenz
Dieses Repository basiert auf dem ursprünglichen Projekt
[ICTU/netbox_slm](https://github.com/ICTU/netbox_slm). **ICTU** ist der ursprüngliche Autor und Herausgeber.
[Mart Visser](https://github.com/MartVisser) wird im Originalprojekt als Ansprechpartner genannt.
Die Anpassungen in diesem Fork werden unter
[git.mrblake.cc/MrBlake/NetBox-SLM](https://git.mrblake.cc/MrBlake/NetBox-SLM) gepflegt.
Das Projekt steht unter der [Apache License 2.0](LICENSE). Die Hinweise auf die ursprünglichen Urheber bleiben
erhalten.
## Certificates (English)
In addition to software licenses, NetBox SLM manages certificates (menu **Licences → Certificates**).
### Fields
- Name, description and type (TLS server, TLS client, certificate authority, code signing, S/MIME email, other)
- Common name, subject alternative names (one DNS name or IP address per line), issuer, serial number and SHA-256
fingerprint
- Validity period (valid from / valid until) and an automatic renewal flag
- Certificate file, stored location (with optional URL) and provider portal URL
- Optional assignment to a software product, installation, device, virtual machine, tenant group and tenant
> **Note:** Private keys are intentionally not stored. Keep them in a dedicated secret store and reference that
> location through the stored location fields if needed.
### Expiration notifications
Certificates use the same reminder settings as licenses:
- Reminders are enabled by default one month and one week before the expiration date.
- An additional custom interval in days, weeks or months can be configured, and the default intervals can be disabled.
- Users opt in by opening a certificate and choosing **Subscribe**. Without subscribers no message is sent.
- A NetBox notification is always created. If **Email notifications** is enabled on the certificate, an email is sent
as well via the SMTP settings configured in NetBox.
- Changing the email option requires the permission `netbox_slm.manage_certificate_email_notifications`
(licenses use `netbox_slm.manage_softwarelicense_email_notifications`).
- The check runs once a day as the NetBox system job **Certificate Expiration Notifications**. Once the first reminder
date is reached, subscribers are notified on every run up to and including the expiration date.
### REST API
Certificates are available at `/api/plugins/slm/certificates/` and support filtering, e.g. by `type`, `common_name`,
`issuer`, `device_id`, `virtualmachine_id`, `tenant_id`, `expiration_date__lte` and `expiration_date__gte`.
### Upgrading
The feature adds the migration `0015_certificate`. After upgrading the plugin run:
```bash
cd /opt/netbox/netbox
/opt/netbox/venv/bin/python manage.py migrate
sudo systemctl restart netbox netbox-rq
```
The plugin's database tables are not dropped automatically.
## Usage
### Expiry notifications
Notifications are enabled by default for licenses and certificates with an
expiry date. Both use the same settings, so this section applies to
certificates as well. The
default reminders are one month and one week before expiry. Per license, an
additional custom warning period can be set or the defaults can be disabled.
Recipients decide themselves whether they are notified: sales, the responsible
technician or other users open the license and click the NetBox **Subscribe**
action (**Unsubscribe** stops it). Without subscribers no message is sent.
A NetBox notification is always created. If **E-mail notifications** is enabled
on the license, the plugin also sends an e-mail to the address stored in the
user account; NetBox SMTP must be configured for this.
Enabling e-mail delivery can only be changed by administrators or users with
the permission `netbox_slm.manage_softwarelicense_email_notifications`
(licenses) or `netbox_slm.manage_certificate_email_notifications`
(certificates). SMTP
credentials are maintained only in the NetBox server configuration and are not
visible in the plugin.
The check runs once a day as a NetBox system job (one job each for licenses
and certificates). Once the first configured
reminder date is reached, subscribers are notified on every job run up to and
including the expiry date. The NetBox RQ worker must run with scheduler support,
which is the default for a standard NetBox installation with `rqworker`.
### Certificates
Certificates are managed under **Licences → Certificates**. Each certificate
stores:
- Name, description and type (TLS server, TLS client, certificate authority,
code signing, S/MIME email, other)
- Common name, subject alternative names (one DNS name or IP address per line),
issuer, serial number and SHA-256 fingerprint
- Validity period (valid from / valid until) and an automatic renewal flag
- Certificate file, storage location (with optional URL) and provider portal URL
- Optional assignment to a software product, installation, device, virtual
machine, tenant group and tenant
> **Note:** Private keys are intentionally not stored. Keep them in a dedicated
> secret store and reference that location through the storage location fields.
Certificates are available in the REST API at `/api/plugins/slm/certificates/`
and can be filtered by e.g. `type`, `common_name`, `issuer`, `device_id`,
`virtualmachine_id`, `tenant_id`, `expiration_date__lte` and
`expiration_date__gte`.
## Origin and license
This repository is based on the original project
[ICTU/netbox_slm](https://github.com/ICTU/netbox_slm). **ICTU** is the original
author and publisher; [Mart Visser](https://github.com/MartVisser) is named as
the contact in the original project.
The changes in this fork are maintained at
[git.mrblake.cc/MrBlake/NetBox-SLM](https://git.mrblake.cc/MrBlake/NetBox-SLM).
Licensed under the [Apache License 2.0](LICENSE). Notices of the original
authors are retained.
@@ -0,0 +1,18 @@
# Generated by Django 6.1.1 on 2026-10-13 12:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('netbox_slm', '0014_softwarelicense_email_notification_permission'),
]
operations = [
migrations.AlterConstraint(
model_name='softwareproductinstallation',
name='netbox_slm_softwareproductinstallation_platform',
constraint=models.CheckConstraint(condition=models.Q(models.Q(('cluster__isnull', True), ('device__isnull', False), ('virtualmachine__isnull', True)), models.Q(('cluster__isnull', True), ('device__isnull', True), ('virtualmachine__isnull', False)), models.Q(('cluster__isnull', False), ('device__isnull', True), ('virtualmachine__isnull', True)), _connector='OR'), name='netbox_slm_softwareproductinstallation_platform', violation_error_message='Select exactly one platform destination: device, virtual machine, or cluster.'),
),
]
@@ -15,7 +15,7 @@ class Migration(migrations.Migration):
("extras", "0001_initial"),
("tenancy", "0001_initial"),
("virtualization", "0001_initial"),
("netbox_slm", "0014_softwarelicense_email_notification_permission"),
("netbox_slm", "0015_platform_constraint_message"),
]
operations = [
+2 -20
View File
@@ -17,8 +17,8 @@ class SlmBaseTestCase(TestCase):
software_product_installation: SoftwareProductInstallation
@classmethod
def setUpClass(cls):
super().setUpClass()
def setUpTestData(cls):
# setUpTestData rolls back after the class and gives every test its own copy of these objects.
manufacturer = Manufacturer.objects.create(name="test manufacturer")
device_type = DeviceType.objects.create(model="test device type", manufacturer=manufacturer)
device_role = DeviceRole.objects.create(name="test device role")
@@ -46,21 +46,3 @@ class SlmBaseTestCase(TestCase):
tenant_group=cls.tenant_group,
tenant=cls.tenant,
)
@classmethod
def tearDownClass(cls):
SoftwareLicense.objects.all().delete()
SoftwareProductInstallation.objects.all().delete()
SoftwareProductVersion.objects.all().delete()
SoftwareProduct.objects.all().delete()
Tenant.objects.all().delete()
TenantGroup.objects.all().delete()
Cluster.objects.all().delete()
ClusterType.objects.all().delete()
VirtualMachine.objects.all().delete()
Device.objects.all().delete()
Site.objects.all().delete()
DeviceRole.objects.all().delete()
DeviceType.objects.all().delete()
Manufacturer.objects.all().delete()
super().tearDownClass()
-5
View File
@@ -12,11 +12,6 @@ class FunctionalTestCase(SlmBaseTestCase):
test_user, _ = get_user_model().objects.get_or_create(username="test", is_superuser=True)
self.client.force_login(test_user)
@classmethod
def tearDownClass(cls):
get_user_model().objects.all().delete()
super().tearDownClass()
def test_template_content(self):
cluster_response = self.client.get(f"/virtualization/clusters/{self.cluster.pk}/")
self.assertContains(cluster_response, f'<a href="/plugins/slm/installations/add/?cluster={self.cluster.pk}"')