Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added top level menu option for config, and added bulk import to all 4 classes #44

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions netbox_slm/forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .software_license import SoftwareLicenseForm, SoftwareLicenseFilterForm
from .software_product import SoftwareProductForm, SoftwareProductFilterForm
from .software_product_installation import SoftwareProductInstallationForm, SoftwareProductInstallationFilterForm
from .software_product_version import SoftwareProductVersionForm, SoftwareProductVersionFilterForm
from .software_license import SoftwareLicenseForm, SoftwareLicenseFilterForm, SoftwareLicenseBulkImportForm
from .software_product import SoftwareProductForm, SoftwareProductFilterForm, SoftwareProductBulkImportForm
from .software_product_installation import SoftwareProductInstallationForm, SoftwareProductInstallationFilterForm, SoftwareProductInstallationBulkImportForm
from .software_product_version import SoftwareProductVersionForm, SoftwareProductVersionFilterForm, SoftwareProductVersionBulkImportForm
25 changes: 23 additions & 2 deletions netbox_slm/forms/software_license.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.forms import DateField
from django.urls import reverse_lazy

from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField, LaxURLField
from utilities.forms.rendering import FieldSet
Expand Down Expand Up @@ -46,14 +46,14 @@ class Meta:
fields = (
"name",
"description",
"software_product",
"type",
"stored_location",
"stored_location_url",
"start_date",
"expiration_date",
"support",
"license_amount",
"software_product",
"version",
"installation",
"tags",
Expand All @@ -65,3 +65,24 @@ class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
model = SoftwareLicense
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)


class SoftwareLicenseBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareLicense
fields = (
"name",
"description",
"software_product",
"type",
"stored_location",
"stored_location_url",
"start_date",
"expiration_date",
"support",
"license_amount",
"version",
"installation",
"tags",
"comments",
)
13 changes: 12 additions & 1 deletion netbox_slm/forms/software_product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dcim.models import Manufacturer
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
Expand Down Expand Up @@ -30,3 +30,14 @@ class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProduct
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)

class SoftwareProductBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProduct
fields = (
"name",
"description",
"manufacturer",
"tags",
"comments",
)
16 changes: 15 additions & 1 deletion netbox_slm/forms/software_product_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import reverse_lazy

from dcim.models import Device
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
Expand Down Expand Up @@ -59,3 +59,17 @@ class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductInstallation
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)

class SoftwareProductInstallationBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProductInstallation
fields = (
"device",
"virtualmachine",
"cluster",
"software_product",
"version",
"tags",
"comments",
)

21 changes: 19 additions & 2 deletions netbox_slm/forms/software_product_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.forms import DateField
from django.urls import reverse_lazy

from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
Expand All @@ -25,14 +25,14 @@ class Meta:
model = SoftwareProductVersion
fields = (
"name",
"software_product",
"release_date",
"documentation_url",
"end_of_support",
"filename",
"file_checksum",
"file_link",
"release_type",
"software_product",
"tags",
"comments",
)
Expand All @@ -42,3 +42,20 @@ class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductVersion
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)

class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProductVersion
fields = (
"name",
"software_product",
"release_date",
"documentation_url",
"end_of_support",
"filename",
"file_checksum",
"file_link",
"release_type",
"tags",
"comments",
)
42 changes: 40 additions & 2 deletions netbox_slm/navigation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from netbox.plugins import PluginMenuButton, PluginMenuItem
from netbox.plugins import PluginMenuButton, PluginMenuItem, PluginMenu
from django.conf import settings

menu_items = (
plugin_settings = settings.PLUGINS_CONFIG["netbox_slm"]

items = (
PluginMenuItem(
link="plugins:netbox_slm:softwareproduct_list",
link_text="Software Products",
Expand All @@ -12,6 +15,12 @@
"mdi mdi-plus-thick",
permissions=["netbox_slm.add_softwareproduct"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproduct_import",
"Import",
"mdi mdi-upload",
permissions=["netbox_slm.import_softwareproduct"],
),
),
),
PluginMenuItem(
Expand All @@ -25,6 +34,12 @@
"mdi mdi-plus-thick",
permissions=["netbox_slm.add_softwareproductversion"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductversion_import",
"Import",
"mdi mdi-upload",
permissions=["netbox_slm.import_softwareproductversion"],
),
),
),
PluginMenuItem(
Expand All @@ -38,6 +53,12 @@
"mdi mdi-plus-thick",
permissions=["netbox_slm.add_softwareproductinstallation"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductinstallation_import",
"Import",
"mdi mdi-upload",
permissions=["netbox_slm.import_softwareproductinstallation"],
),
),
),
PluginMenuItem(
Expand All @@ -51,6 +72,23 @@
"mdi mdi-plus-thick",
permissions=["netbox_slm.add_softwarelicense"],
),
PluginMenuButton(
"plugins:netbox_slm:softwarelicense_import",
"Import",
"mdi mdi-upload",
permissions=["netbox_slm.import_softwarelicense"],
),
),
),
)



if plugin_settings.get("top_level_menu"):
menu = PluginMenu(
label="Software Lifecycle",
groups=(("SOFTWARE Lifecycle", items),),
icon_class="mdi mdi-content-save",
)
else:
menu_items = items
5 changes: 5 additions & 0 deletions netbox_slm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@
name="softwarelicense_changelog",
kwargs={"model": SoftwareLicense},
),
path('software-products/import/', views.SoftwareProductBulkImportView.as_view(), name='softwareproduct_import'),
path('installations/import/', views.SoftwareProductInstallationBulkImportView.as_view(), name='softwareproductinstallation_import'),
path('versions/import/', views.SoftwareProductVersionBulkImportView.as_view(), name='softwareproductversion_import'),
path('licenses/import/', views.SoftwareLicenseBulkImportView.as_view(), name='softwarelicense_import'),

]
8 changes: 8 additions & 0 deletions netbox_slm/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@
SoftwareLicenseEditView,
SoftwareLicenseDeleteView,
SoftwareLicenseBulkDeleteView,
SoftwareLicenseBulkImportView,

)
from .software_product import (
SoftwareProductListView,
SoftwareProductView,
SoftwareProductEditView,
SoftwareProductDeleteView,
SoftwareProductBulkDeleteView,
SoftwareProductBulkImportView,

)
from .software_product_installation import (
SoftwareProductInstallationListView,
SoftwareProductInstallationView,
SoftwareProductInstallationEditView,
SoftwareProductInstallationDeleteView,
SoftwareProductInstallationBulkDeleteView,
SoftwareProductInstallationBulkImportView,

)
from .software_product_version import (
SoftwareProductVersionListView,
SoftwareProductVersionView,
SoftwareProductVersionEditView,
SoftwareProductVersionDeleteView,
SoftwareProductVersionBulkDeleteView,
SoftwareProductVersionBulkImportView,

)
8 changes: 8 additions & 0 deletions netbox_slm/views/software_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ class SoftwareLicenseDeleteView(generic.ObjectDeleteView):


class SoftwareLicenseBulkDeleteView(generic.BulkDeleteView):

queryset = SoftwareLicense.objects.all()
table = tables.SoftwareLicenseTable


class SoftwareLicenseBulkImportView(generic.BulkImportView):

queryset = SoftwareLicense.objects.all()
table = tables.SoftwareLicenseTable
model_form = forms.SoftwareLicenseBulkImportForm
11 changes: 9 additions & 2 deletions netbox_slm/views/software_product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from netbox.views import generic
from netbox_slm import filtersets, forms, tables
from netbox_slm import filtersets, forms, tables, models
from netbox_slm.models import SoftwareProduct


Expand Down Expand Up @@ -31,10 +31,17 @@ class SoftwareProductEditView(generic.ObjectEditView):

class SoftwareProductDeleteView(generic.ObjectDeleteView):
"""View for deleting a SoftwareProduct instance"""

queryset = SoftwareProduct.objects.all()


class SoftwareProductBulkDeleteView(generic.BulkDeleteView):

queryset = SoftwareProduct.objects.all()
table = tables.SoftwareProductTable


class SoftwareProductBulkImportView(generic.BulkImportView):

queryset = SoftwareProduct.objects.all()
table = tables.SoftwareProductTable
model_form = forms.SoftwareProductBulkImportForm
9 changes: 8 additions & 1 deletion netbox_slm/views/software_product_installation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from netbox.views import generic
from netbox_slm import filtersets, forms, tables
from netbox_slm import filtersets, forms, tables, models
from netbox_slm.models import SoftwareProductInstallation


Expand Down Expand Up @@ -32,5 +32,12 @@ class SoftwareProductInstallationDeleteView(generic.ObjectDeleteView):


class SoftwareProductInstallationBulkDeleteView(generic.BulkDeleteView):

queryset = SoftwareProductInstallation.objects.all()
table = tables.SoftwareProductInstallationTable

class SoftwareProductInstallationBulkImportView(generic.BulkImportView):

queryset = SoftwareProductInstallation.objects.all()
table = tables.SoftwareProductInstallationTable
model_form = forms.SoftwareProductInstallationBulkImportForm
10 changes: 9 additions & 1 deletion netbox_slm/views/software_product_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from netbox.views import generic
from netbox_slm import filtersets, forms, tables
from netbox_slm import filtersets, forms, tables, models
from netbox_slm.models import SoftwareProductVersion


Expand Down Expand Up @@ -36,5 +36,13 @@ class SoftwareProductVersionDeleteView(generic.ObjectDeleteView):


class SoftwareProductVersionBulkDeleteView(generic.BulkDeleteView):

queryset = SoftwareProductVersion.objects.all()
table = tables.SoftwareProductVersionTable


class SoftwareProductVersionBulkImportView(generic.BulkImportView):

queryset = SoftwareProductVersion.objects.all()
table = tables.SoftwareProductVersionTable
model_form = forms.SoftwareProductVersionBulkImportForm
Loading