feat: client software overview based on netbox-slm
New page "Client Software Übersicht" in a "Software" group of the netbox-inventory menu (fallback: own Hardware menu). It shows, per tenant or tenant group including subgroups, the software products recorded with netbox-slm, their versions and the clients they are installed on: key figures, charts of the most widespread products and their version distribution, a sortable and searchable product list, a drill-down per product/version with the list of clients, and a CSV export. Without an own selection the global tenant filter applies; the device role filter is pre-set to the configured client roles. Devices with a client role (software_device_roles, default "Clients") get a "Software" tab listing their installations with add, edit and delete actions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5d6c4c9cd8
commit
63b3b31763
15 files changed
+1209
-3
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""Hooks the client software overview into NetBox: device tab and "Software" group in the Inventory menu."""
|
||||
|
||||
from django.core.signals import request_started
|
||||
|
||||
SOFTWARE_GROUP_LABEL = "Software"
|
||||
INVENTORY_MENU_LABEL = "Inventory"
|
||||
FALLBACK_MENU_LABEL = "Hardware"
|
||||
|
||||
|
||||
def software_menu_items():
|
||||
from netbox.plugins import PluginMenuButton, PluginMenuItem
|
||||
|
||||
return (
|
||||
PluginMenuItem(
|
||||
link="plugins:netbox_utilities:software_overview",
|
||||
link_text="Client Software Übersicht",
|
||||
permissions=["netbox_slm.view_softwareproductinstallation"],
|
||||
buttons=(
|
||||
PluginMenuButton(
|
||||
link="plugins:netbox_slm:softwareproductinstallation_add",
|
||||
title="Installation erfassen",
|
||||
icon_class="mdi mdi-plus-thick",
|
||||
permissions=["netbox_slm.add_softwareproductinstallation"],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def add_software_group(menus):
|
||||
"""
|
||||
Append the "Software" group to the Inventory menu of netbox-inventory.
|
||||
|
||||
Falls back to the plugin's own "Hardware" menu if netbox-inventory has no top-level menu.
|
||||
Returns the menu that received the group, or None.
|
||||
"""
|
||||
from netbox.navigation import MenuGroup
|
||||
|
||||
menus = list(menus)
|
||||
target = next((menu for menu in menus if str(menu.label) == INVENTORY_MENU_LABEL), None)
|
||||
target = target or next((menu for menu in menus if str(menu.label) == FALLBACK_MENU_LABEL), None)
|
||||
if target is None:
|
||||
return None
|
||||
groups = list(target.groups)
|
||||
if any(str(group.label) == SOFTWARE_GROUP_LABEL for group in groups):
|
||||
return target
|
||||
groups.append(MenuGroup(SOFTWARE_GROUP_LABEL, software_menu_items()))
|
||||
target.groups = groups
|
||||
return target
|
||||
|
||||
|
||||
def _install_menu_on_first_request(**kwargs):
|
||||
# All plugins have registered their menus once the first request arrives.
|
||||
request_started.disconnect(dispatch_uid=__name__)
|
||||
from netbox.registry import registry
|
||||
|
||||
add_software_group(registry["plugins"]["menus"])
|
||||
|
||||
|
||||
def install_software_support():
|
||||
# Registers the device "Software" tab before NetBox builds the dcim URLs.
|
||||
from . import software_views # noqa: F401
|
||||
|
||||
request_started.connect(_install_menu_on_first_request, dispatch_uid=__name__)
|
||||
Reference in new issue
Block a user