Skip to content

Commit

Permalink
Prepare for upgrade to NetBox v4.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
wkoot committed Jul 9, 2024
1 parent 230b3b5 commit 9577340
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"

- name: Install tools
run: pip install .[tools]
Expand Down
6 changes: 3 additions & 3 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VERSION=3.10
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-alpine AS compile-image

WORKDIR /build
Expand All @@ -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
2 changes: 1 addition & 1 deletion ci/Dockerfile-CI
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.7'
---
services:
netbox:
ports:
Expand Down
4 changes: 2 additions & 2 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
coverage==7.2.2
coverage==7.5.4
unittest-xml-reporting==3.2.0
2 changes: 1 addition & 1 deletion netbox_slm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from extras.plugins import PluginConfig
from netbox.plugins import PluginConfig

__version__ = "1.6.0"

Expand Down
20 changes: 12 additions & 8 deletions netbox_slm/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SoftwareLicenseSerializer(NetBoxModelSerializer):

class Meta:
model = SoftwareLicense
fields = [
fields = (
"id",
"display",
"url",
Expand All @@ -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}"
Expand All @@ -43,7 +44,7 @@ class SoftwareProductSerializer(NetBoxModelSerializer):

class Meta:
model = SoftwareProduct
fields = [
fields = (
"id",
"display",
"url",
Expand All @@ -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}"
Expand All @@ -69,7 +71,7 @@ class SoftwareProductInstallationSerializer(NetBoxModelSerializer):

class Meta:
model = SoftwareProductInstallation
fields = [
fields = (
"id",
"display",
"url",
Expand All @@ -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}"
Expand All @@ -95,7 +98,7 @@ class SoftwareProductVersionSerializer(NetBoxModelSerializer):

class Meta:
model = SoftwareProductVersion
fields = [
fields = (
"id",
"display",
"url",
Expand All @@ -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}"
14 changes: 3 additions & 11 deletions netbox_slm/forms/software_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -62,7 +63,7 @@ class Meta:

class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
model = SoftwareLicense
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)


Expand All @@ -85,13 +86,4 @@ class SoftwareLicenseBulkEditForm(NetBoxModelBulkEditForm):
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
installation = DynamicModelChoiceField(queryset=SoftwareProductInstallation.objects.all(), required=False)
model = SoftwareLicense
fieldsets = (
(
None,
(
"software_product",
"version",
"installation",
),
),
)
fieldsets = (FieldSet(None, ("software_product", "version", "installation")),)
3 changes: 2 additions & 1 deletion netbox_slm/forms/software_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -29,7 +30,7 @@ class Meta:

class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProduct
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)


Expand Down
13 changes: 3 additions & 10 deletions netbox_slm/forms/software_product_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -56,7 +57,7 @@ def clean_version(self):

class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductInstallation
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)


Expand All @@ -70,12 +71,4 @@ class SoftwareProductInstallationBulkEditForm(NetBoxModelBulkEditForm):
software_product = DynamicModelChoiceField(queryset=SoftwareProduct.objects.all(), required=False)
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
model = SoftwareProductInstallation
fieldsets = (
(
None,
(
"software_product",
"version",
),
),
)
fieldsets = (FieldSet(None, ("software_product", "version")),)
3 changes: 2 additions & 1 deletion netbox_slm/forms/software_product_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -39,7 +40,7 @@ class Meta:

class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductVersion
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)


Expand Down
11 changes: 1 addition & 10 deletions netbox_slm/navigation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from extras.plugins import PluginMenuButton, PluginMenuItem
from utilities.choices import ButtonColorChoices
from netbox.plugins import PluginMenuButton, PluginMenuItem

menu_items = (
PluginMenuItem(
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand Down
Loading

0 comments on commit 9577340

Please sign in to comment.