Add a Certificate model alongside software licenses with type, common name, SANs, issuer, serial number, fingerprint, validity period, auto renewal, certificate file and storage locations. Certificates can be assigned to software products, installations, devices, virtual machines and tenants. Extract the expiration reminder settings and logic into a shared ExpirationNotificationModel base and a generic notification job, so certificates get the same default/custom reminders, NetBox notifications and optional SMTP emails as licenses (separate event type, log model and email permission). Includes UI views, filters, table, bulk import/edit, REST API endpoint, migration 0015, German translations, tests and README/CHANGELOG updates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from rest_framework.routers import APIRootView
|
|
|
|
from netbox.api.viewsets import NetBoxModelViewSet
|
|
from netbox_slm.api.serializers import (
|
|
SoftwareProductSerializer,
|
|
SoftwareProductVersionSerializer,
|
|
SoftwareProductInstallationSerializer,
|
|
SoftwareLicenseSerializer,
|
|
CertificateSerializer,
|
|
)
|
|
from netbox_slm.filtersets import (
|
|
SoftwareProductFilterSet,
|
|
SoftwareProductVersionFilterSet,
|
|
SoftwareProductInstallationFilterSet,
|
|
SoftwareLicenseFilterSet,
|
|
CertificateFilterSet,
|
|
)
|
|
from netbox_slm.models import (
|
|
SoftwareProduct,
|
|
SoftwareProductVersion,
|
|
SoftwareProductInstallation,
|
|
SoftwareLicense,
|
|
Certificate,
|
|
)
|
|
|
|
|
|
class NetboxSLMRootView(APIRootView):
|
|
def get_view_name(self):
|
|
return "NetboxSLM"
|
|
|
|
|
|
class SoftwareProductViewSet(NetBoxModelViewSet):
|
|
queryset = SoftwareProduct.objects.all().order_by("id")
|
|
serializer_class = SoftwareProductSerializer
|
|
filterset_class = SoftwareProductFilterSet
|
|
|
|
|
|
class SoftwareProductVersionViewSet(NetBoxModelViewSet):
|
|
queryset = SoftwareProductVersion.objects.all().order_by("id")
|
|
serializer_class = SoftwareProductVersionSerializer
|
|
filterset_class = SoftwareProductVersionFilterSet
|
|
|
|
|
|
class SoftwareProductInstallationViewSet(NetBoxModelViewSet):
|
|
queryset = SoftwareProductInstallation.objects.all().order_by("id")
|
|
serializer_class = SoftwareProductInstallationSerializer
|
|
filterset_class = SoftwareProductInstallationFilterSet
|
|
|
|
|
|
class SoftwareLicenseViewSet(NetBoxModelViewSet):
|
|
queryset = SoftwareLicense.objects.all().order_by("id")
|
|
serializer_class = SoftwareLicenseSerializer
|
|
filterset_class = SoftwareLicenseFilterSet
|
|
|
|
|
|
class CertificateViewSet(NetBoxModelViewSet):
|
|
queryset = Certificate.objects.all().order_by("id")
|
|
serializer_class = CertificateSerializer
|
|
filterset_class = CertificateFilterSet
|