From 27108384e8988b5d856a238e5770194826057dc6 Mon Sep 17 00:00:00 2001
From: wkoot <3715211+wkoot@users.noreply.github.com>
Date: Tue, 9 Jul 2024 12:45:11 +0200
Subject: [PATCH] Prepare for upgrade to v4.0.6
---
ci/Dockerfile | 6 +-
ci/Dockerfile-CI | 2 +-
ci/docker-compose.ci.yml | 2 +-
ci/docker-compose.yml | 4 +-
netbox_slm/__init__.py | 2 +-
netbox_slm/api/serializers.py | 20 ++--
netbox_slm/forms/software_license.py | 14 +--
netbox_slm/forms/software_product.py | 5 +-
.../forms/software_product_installation.py | 13 +--
netbox_slm/forms/software_product_version.py | 5 +-
netbox_slm/navigation.py | 11 +--
.../templates/netbox_slm/softwarelicense.html | 96 +++++++++----------
.../templates/netbox_slm/softwareproduct.html | 54 +++++------
.../softwareproductinstallation.html | 46 +++++----
.../netbox_slm/softwareproductversion.html | 74 +++++++-------
15 files changed, 170 insertions(+), 184 deletions(-)
diff --git a/ci/Dockerfile b/ci/Dockerfile
index fd82aa7..bc4ef09 100644
--- a/ci/Dockerfile
+++ b/ci/Dockerfile
@@ -1,4 +1,4 @@
-ARG PYTHON_VERSION=3.10
+ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-alpine AS compile-image
WORKDIR /build
@@ -11,7 +11,7 @@ RUN pip install -U .[build]
RUN python -m build
RUN pip install --no-index /build
-FROM netboxcommunity/netbox:v3.7.2
+FROM netboxcommunity/netbox:v4.0.6
-ARG PYTHON_VERSION=3.10
+ARG PYTHON_VERSION=3.11
COPY --from=compile-image /opt/netbox/venv/lib/python${PYTHON_VERSION}/site-packages/netbox_slm /opt/netbox/venv/lib/python${PYTHON_VERSION}/site-packages/netbox_slm
diff --git a/ci/Dockerfile-CI b/ci/Dockerfile-CI
index 7be4eeb..c21d0b3 100644
--- a/ci/Dockerfile-CI
+++ b/ci/Dockerfile-CI
@@ -1,4 +1,4 @@
-FROM netboxcommunity/netbox:v3.7.2
+FROM netboxcommunity/netbox:v4.0.6
RUN mkdir /ci && chmod go+w /ci
COPY ../ci/requirements_ci.txt /ci/
diff --git a/ci/docker-compose.ci.yml b/ci/docker-compose.ci.yml
index 0939273..30b49e3 100644
--- a/ci/docker-compose.ci.yml
+++ b/ci/docker-compose.ci.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+---
services:
netbox:
ports:
diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml
index 67ffe55..f7965b9 100644
--- a/ci/docker-compose.yml
+++ b/ci/docker-compose.yml
@@ -1,7 +1,7 @@
-version: '3.7'
+---
services:
netbox: &netbox
- image: netboxcommunity/netbox:${VERSION-v3.7.2}
+ image: netboxcommunity/netbox:${VERSION-v4.0.6}
depends_on:
- postgres
- redis
diff --git a/netbox_slm/__init__.py b/netbox_slm/__init__.py
index 127d809..fc15c18 100644
--- a/netbox_slm/__init__.py
+++ b/netbox_slm/__init__.py
@@ -1,4 +1,4 @@
-from extras.plugins import PluginConfig
+from netbox.plugins import PluginConfig
__version__ = "1.6.0"
diff --git a/netbox_slm/api/serializers.py b/netbox_slm/api/serializers.py
index 7b2f508..e6e1e0f 100644
--- a/netbox_slm/api/serializers.py
+++ b/netbox_slm/api/serializers.py
@@ -10,7 +10,7 @@ class SoftwareLicenseSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareLicense
- fields = [
+ fields = (
"id",
"display",
"url",
@@ -31,7 +31,8 @@ class Meta:
"custom_field_data",
"created",
"last_updated",
- ]
+ )
+ brief_fields = ("id", "display", "url", "name", "description")
def get_display(self, obj):
return f"{obj}"
@@ -43,7 +44,7 @@ class SoftwareProductSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProduct
- fields = [
+ fields = (
"id",
"display",
"url",
@@ -55,7 +56,8 @@ class Meta:
"custom_field_data",
"created",
"last_updated",
- ]
+ )
+ brief_fields = ("id", "display", "url", "name", "description")
def get_display(self, obj):
return f"{obj.manufacturer} - {obj}"
@@ -69,7 +71,7 @@ class SoftwareProductInstallationSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProductInstallation
- fields = [
+ fields = (
"id",
"display",
"url",
@@ -83,7 +85,8 @@ class Meta:
"custom_field_data",
"created",
"last_updated",
- ]
+ )
+ brief_fields = ("id", "display", "url", "name")
def get_display(self, obj):
return f"{obj}"
@@ -95,7 +98,7 @@ class SoftwareProductVersionSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProductVersion
- fields = [
+ fields = (
"id",
"display",
"url",
@@ -113,7 +116,8 @@ class Meta:
"custom_field_data",
"created",
"last_updated",
- ]
+ )
+ brief_fields = ("id", "display", "url", "name")
def get_display(self, obj):
return f"{obj}"
diff --git a/netbox_slm/forms/software_license.py b/netbox_slm/forms/software_license.py
index 1c35d00..a6c593d 100644
--- a/netbox_slm/forms/software_license.py
+++ b/netbox_slm/forms/software_license.py
@@ -4,6 +4,7 @@
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField, LaxURLField
+from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect, DatePicker
@@ -62,7 +63,9 @@ class Meta:
class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
model = SoftwareLicense
- fieldsets = ((None, ("q", "tag")),)
+ fieldsets = (
+ FieldSet(None, ("q", "tag")),
+ )
tag = TagFilterField(model)
@@ -86,12 +89,5 @@ class SoftwareLicenseBulkEditForm(NetBoxModelBulkEditForm):
installation = DynamicModelChoiceField(queryset=SoftwareProductInstallation.objects.all(), required=False)
model = SoftwareLicense
fieldsets = (
- (
- None,
- (
- "software_product",
- "version",
- "installation",
- ),
- ),
+ FieldSet(None, ("software_product", "version", "installation")),
)
diff --git a/netbox_slm/forms/software_product.py b/netbox_slm/forms/software_product.py
index 8705344..e9167e7 100644
--- a/netbox_slm/forms/software_product.py
+++ b/netbox_slm/forms/software_product.py
@@ -4,6 +4,7 @@
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
+from utilities.forms.rendering import FieldSet
class SoftwareProductForm(NetBoxModelForm):
@@ -29,7 +30,9 @@ class Meta:
class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProduct
- fieldsets = ((None, ("q", "tag")),)
+ fieldsets = (
+ FieldSet(None, ("q", "tag")),
+ )
tag = TagFilterField(model)
diff --git a/netbox_slm/forms/software_product_installation.py b/netbox_slm/forms/software_product_installation.py
index 24c2546..36bf60d 100644
--- a/netbox_slm/forms/software_product_installation.py
+++ b/netbox_slm/forms/software_product_installation.py
@@ -5,6 +5,7 @@
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
+from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect
from virtualization.models import VirtualMachine, Cluster
@@ -56,7 +57,9 @@ def clean_version(self):
class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductInstallation
- fieldsets = ((None, ("q", "tag")),)
+ fieldsets = (
+ FieldSet(None, ("q", "tag")),
+ )
tag = TagFilterField(model)
@@ -71,11 +74,5 @@ class SoftwareProductInstallationBulkEditForm(NetBoxModelBulkEditForm):
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
model = SoftwareProductInstallation
fieldsets = (
- (
- None,
- (
- "software_product",
- "version",
- ),
- ),
+ FieldSet(None, ("software_product", "version")),
)
diff --git a/netbox_slm/forms/software_product_version.py b/netbox_slm/forms/software_product_version.py
index 34ff1f4..b3bedbe 100644
--- a/netbox_slm/forms/software_product_version.py
+++ b/netbox_slm/forms/software_product_version.py
@@ -4,6 +4,7 @@
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
+from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect, DatePicker
@@ -39,7 +40,9 @@ class Meta:
class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductVersion
- fieldsets = ((None, ("q", "tag")),)
+ fieldsets = (
+ FieldSet(None, ("q", "tag")),
+ )
tag = TagFilterField(model)
diff --git a/netbox_slm/navigation.py b/netbox_slm/navigation.py
index 13b1423..07ccccc 100644
--- a/netbox_slm/navigation.py
+++ b/netbox_slm/navigation.py
@@ -1,5 +1,4 @@
-from extras.plugins import PluginMenuButton, PluginMenuItem
-from utilities.choices import ButtonColorChoices
+from netbox.plugins import PluginMenuButton, PluginMenuItem
menu_items = (
PluginMenuItem(
@@ -10,14 +9,12 @@
"plugins:netbox_slm:softwareproduct_add",
"Add",
"mdi mdi-plus-thick",
- ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproduct"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproduct_import",
"Import",
"mdi mdi-upload",
- ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproduct"],
),
),
@@ -30,14 +27,12 @@
"plugins:netbox_slm:softwareproductversion_add",
"Add",
"mdi mdi-plus-thick",
- ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproductversion"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductversion_import",
"Import",
"mdi mdi-upload",
- ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproductversion"],
),
),
@@ -50,14 +45,12 @@
"plugins:netbox_slm:softwareproductinstallation_add",
"Add",
"mdi mdi-plus-thick",
- ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproductinstallation"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductinstallation_import",
"Import",
"mdi mdi-upload",
- ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproductinstallation"],
),
),
@@ -70,14 +63,12 @@
"plugins:netbox_slm:softwarelicense_add",
"Add",
"mdi mdi-plus-thick",
- ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwarelicense"],
),
PluginMenuButton(
"plugins:netbox_slm:softwarelicense_import",
"Import",
"mdi mdi-upload",
- ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwarelicense"],
),
),
diff --git a/netbox_slm/templates/netbox_slm/softwarelicense.html b/netbox_slm/templates/netbox_slm/softwarelicense.html
index 372c713..b70bf91 100644
--- a/netbox_slm/templates/netbox_slm/softwarelicense.html
+++ b/netbox_slm/templates/netbox_slm/softwarelicense.html
@@ -11,58 +11,56 @@
-
-
-
- Name |
- {{ object.name }} |
-
-
- Description |
- {{ object.description }} |
-
-
- Type |
- {{ object.type }} |
-
-
- Stored location |
+
+
+ Name |
+ {{ object.name }} |
+
+
+ Description |
+ {{ object.description }} |
+
+
+ Type |
+ {{ object.type }} |
+
+
+ Stored location |
{% if object.stored_location_url %}
- {{ object.stored_location_txt }} |
+ {{ object.stored_location_txt }} |
{% else %}
- {{ object.stored_location_txt }} |
+ {{ object.stored_location_txt }} |
{% endif %}
-
-
- Start date |
- {{ object.start_date }} |
-
-
- Expiration date |
- {{ object.expiration_date }} |
-
-
- Software Product |
- {{ object.software_product }} |
-
-
- Version |
- {{ object.version }} |
-
-
- Support |
- {{ object.support }} |
-
-
- License amount |
- {{ object.license_amount }} |
-
-
- Installation |
- {{ object.installation }} |
-
-
-
+
+
+ Start date |
+ {{ object.start_date }} |
+
+
+ Expiration date |
+ {{ object.expiration_date }} |
+
+
+ Software Product |
+ {{ object.software_product }} |
+
+
+ Version |
+ {{ object.version }} |
+
+
+ Support |
+ {{ object.support }} |
+
+
+ License amount |
+ {{ object.license_amount }} |
+
+
+ Installation |
+ {{ object.installation }} |
+
+
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
diff --git a/netbox_slm/templates/netbox_slm/softwareproduct.html b/netbox_slm/templates/netbox_slm/softwareproduct.html
index 089c25b..65cc24a 100644
--- a/netbox_slm/templates/netbox_slm/softwareproduct.html
+++ b/netbox_slm/templates/netbox_slm/softwareproduct.html
@@ -11,34 +11,32 @@
-
-
-
- Name |
- {{ object.name }} |
-
-
- Description |
- {{ object.description }} |
-
-
- Manufacturer |
- {{ object.manufacturer }} |
-
-
- Versions |
-
- {% for version in object.softwareproduct_versions.all %}
-
- {{ version }}
-
- {% empty %}
- n/a
- {% endfor %}
- |
-
-
-
+
+
+ Name |
+ {{ object.name }} |
+
+
+ Description |
+ {{ object.description }} |
+
+
+ Manufacturer |
+ {{ object.manufacturer }} |
+
+
+ Versions |
+
+ {% for version in object.softwareproduct_versions.all %}
+
+ {{ version }}
+
+ {% empty %}
+ n/a
+ {% endfor %}
+ |
+
+
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
diff --git a/netbox_slm/templates/netbox_slm/softwareproductinstallation.html b/netbox_slm/templates/netbox_slm/softwareproductinstallation.html
index 4819d50..735e7f5 100644
--- a/netbox_slm/templates/netbox_slm/softwareproductinstallation.html
+++ b/netbox_slm/templates/netbox_slm/softwareproductinstallation.html
@@ -11,34 +11,32 @@
-
-
+
{% if object.device %}
-
- Device |
- {{ object.device }} |
-
+
+ Device |
+ {{ object.device }} |
+
{% elif object.virtualmachine %}
-
- Virtualmachine |
- {{ object.virtualmachine }} |
-
+
+ Virtualmachine |
+ {{ object.virtualmachine }} |
+
{% else %}
-
- Cluster |
- {{ object.cluster }} |
-
+
+ Cluster |
+ {{ object.cluster }} |
+
{% endif %}
-
- Software Product |
- {{ object.software_product }} |
-
-
- Version |
- {{ object.version }} |
-
-
-
+
+ Software Product |
+ {{ object.software_product }} |
+
+
+ Version |
+ {{ object.version }} |
+
+
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
diff --git a/netbox_slm/templates/netbox_slm/softwareproductversion.html b/netbox_slm/templates/netbox_slm/softwareproductversion.html
index 0e4055f..5477351 100644
--- a/netbox_slm/templates/netbox_slm/softwareproductversion.html
+++ b/netbox_slm/templates/netbox_slm/softwareproductversion.html
@@ -11,50 +11,48 @@
-
-
-
- Name |
- {{ object.name }} |
-
-
- Release date |
- {{ object.release_date }} |
-
-
- Documentation url |
+
+
+ Name |
+ {{ object.name }} |
+
+
+ Release date |
+ {{ object.release_date }} |
+
+
+ Documentation url |
{% if object.documentation_url %}
- {{ object.documentation_url }} |
+ {{ object.documentation_url }} |
{% else %}
- {{ object.documentation_url }} |
+ {{ object.documentation_url }} |
{% endif %}
-
-
- End of support |
- {{ object.end_of_support }} |
-
-
- Filename |
+
+
+ End of support |
+ {{ object.end_of_support }} |
+
+
+ Filename |
{% if object.file_link %}
- {{ object.filename }} |
+ {{ object.filename }} |
{% else %}
- {{ object.filename }} |
+ {{ object.filename }} |
{% endif %}
-
-
- File checksum |
- {{ object.file_checksum }} |
-
-
- Release type |
- {{ object.get_release_type_display }} |
-
-
- Installations |
- {{ object.get_installation_count }} |
-
-
-
+
+
+ File checksum |
+ {{ object.file_checksum }} |
+
+
+ Release type |
+ {{ object.get_release_type_display }} |
+
+
+ Installations |
+ {{ object.get_installation_count }} |
+
+
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}