Compare commits
3
Commits
7d267ec05d
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d6b16c0e4 | ||
|
|
280c0e0315 | ||
|
|
713556a33e |
No files matched your search
@@ -41,6 +41,7 @@ Plugin settings:
|
|||||||
- The rack view of the optional [MrBlake NetBox Topology Views](https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views) plugin renders partial-width devices correctly.
|
- The rack view of the optional [MrBlake NetBox Topology Views](https://git.mrblake.cc/MrBlake/mrb-netbox-topology-views) plugin renders partial-width devices correctly.
|
||||||
- Upload multiple images at once in an object's **Images** tab.
|
- Upload multiple images at once in an object's **Images** tab.
|
||||||
- Install multiple modules of the same type into free module bays in one step.
|
- Install multiple modules of the same type into free module bays in one step.
|
||||||
|
- Export device types as YAML in the devicetype-library format (single type or the filtered list as ZIP).
|
||||||
- Optional bulk save for devices moved in NetBox Reorder Rack.
|
- Optional bulk save for devices moved in NetBox Reorder Rack.
|
||||||
- Rack widths are preserved by the optional [NetBox-Export](https://git.mrblake.cc/MrBlake/NetBox-Export) export/import.
|
- Rack widths are preserved by the optional [NetBox-Export](https://git.mrblake.cc/MrBlake/NetBox-Export) export/import.
|
||||||
- Cables and wireless links can be assigned to one or more VLANs.
|
- Cables and wireless links can be assigned to one or more VLANs.
|
||||||
@@ -666,6 +667,10 @@ interfaces, since both ends can use different interface modes.
|
|||||||
- An optional **VLAN group** field acts as a dynamic filter for the VLAN selection; it is not stored.
|
- An optional **VLAN group** field acts as a dynamic filter for the VLAN selection; it is not stored.
|
||||||
- Empty selections create no record; deleting a connection removes its VLAN assignment.
|
- Empty selections create no record; deleting a connection removes its VLAN assignment.
|
||||||
- With NetBox-Export installed, the assignments are exported and imported together with connections and VLANs.
|
- With NetBox-Export installed, the assignments are exported and imported together with connections and VLANs.
|
||||||
|
- Cable VLANs can be read and written through `/api/plugins/utilities/cable-vlans/`
|
||||||
|
(`cable` = cable ID, `vlans` = VLAN IDs, filter with `?cable_id=`; permissions
|
||||||
|
`netbox_utilities.*_cablevlanassignment`). NetBox Synchronizer uses it to keep
|
||||||
|
the cable VLANs of switch ports in step with the port.
|
||||||
|
|
||||||
### Multiple devices in one rack unit
|
### Multiple devices in one rack unit
|
||||||
|
|
||||||
@@ -763,6 +768,18 @@ error occurs, the whole rack stays unchanged. Every moved device still gets a
|
|||||||
normal changelog entry. Versions other than `1.1.4` are left untouched and only
|
normal changelog entry. Versions other than `1.1.4` are left untouched and only
|
||||||
produce a log message.
|
produce a log message.
|
||||||
|
|
||||||
|
### Exporting device types as YAML
|
||||||
|
|
||||||
|
Device type detail pages get an **Export YAML** button that downloads the type
|
||||||
|
in the [devicetype-library](https://github.com/netbox-community/devicetype-library)
|
||||||
|
format (manufacturer, model, slug, dimensions, airflow, weight and all component
|
||||||
|
templates: console/power ports, outlets, interfaces, front/rear ports incl. their
|
||||||
|
mapping, module/device bays and inventory items). Fields at their default value are
|
||||||
|
omitted. The file can be imported again via *Device Types → Import*.
|
||||||
|
|
||||||
|
The device type list gets the same button: it exports every type matching the
|
||||||
|
current filters as `device-types.zip`, laid out as `<Manufacturer>/<slug>.yaml`.
|
||||||
|
|
||||||
### Uploading multiple images
|
### Uploading multiple images
|
||||||
|
|
||||||
In the **Images** tab of supported objects, the single upload is replaced by
|
In the **Images** tab of supported objects, the single upload is replaced by
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from netbox.plugins import PluginConfig, get_plugin_config
|
from netbox.plugins import PluginConfig, get_plugin_config
|
||||||
|
|
||||||
__version__ = "0.29.1"
|
__version__ = "0.31.0"
|
||||||
|
|
||||||
|
|
||||||
class NetBoxUtilitiesConfig(PluginConfig):
|
class NetBoxUtilitiesConfig(PluginConfig):
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ from netbox.api.serializers import NetBoxModelSerializer
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from tenancy.api.serializers import TenantSerializer
|
from tenancy.api.serializers import TenantSerializer
|
||||||
|
|
||||||
from dcim.models import Device
|
from dcim.models import Cable, Device
|
||||||
|
from ipam.models import VLAN
|
||||||
|
|
||||||
from ..models import CPUModel, DeviceHardware, Disk, DiskBayLayout, DiskBayTemplate, RAIDGroup, SwitchStack
|
from ..models import CableVLANAssignment, CPUModel, DeviceHardware, Disk, DiskBayLayout, DiskBayTemplate, RAIDGroup, SwitchStack
|
||||||
|
|
||||||
LAYOUT_FIELDS = ("name", "weight", "slot_count", "rows", "first_slot", "numbering", "form_factor")
|
LAYOUT_FIELDS = ("name", "weight", "slot_count", "rows", "first_slot", "numbering", "form_factor")
|
||||||
|
|
||||||
@@ -215,3 +216,14 @@ class SwitchStackSerializer(serializers.ModelSerializer):
|
|||||||
if device is not None and any(member.pk == device.pk for member in data.get("members") or []):
|
if device is not None and any(member.pk == device.pk for member in data.get("members") or []):
|
||||||
raise serializers.ValidationError({"members": "Der Switch kann nicht sein eigenes Mitglied sein."})
|
raise serializers.ValidationError({"members": "Der Switch kann nicht sein eigenes Mitglied sein."})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class CableVLANAssignmentSerializer(serializers.ModelSerializer):
|
||||||
|
"""VLANs of a cable connection as VLAN IDs (one assignment per cable)."""
|
||||||
|
|
||||||
|
cable = serializers.PrimaryKeyRelatedField(queryset=Cable.objects.all())
|
||||||
|
vlans = serializers.PrimaryKeyRelatedField(queryset=VLAN.objects.all(), many=True, required=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = CableVLANAssignment
|
||||||
|
fields = ("id", "cable", "vlans", "updated")
|
||||||
@@ -12,5 +12,6 @@ router.register("disk-bay-templates", views.DiskBayTemplateViewSet)
|
|||||||
router.register("cpu-models", views.CPUModelViewSet)
|
router.register("cpu-models", views.CPUModelViewSet)
|
||||||
router.register("device-hardware", views.DeviceHardwareViewSet)
|
router.register("device-hardware", views.DeviceHardwareViewSet)
|
||||||
router.register("switch-stacks", views.SwitchStackViewSet)
|
router.register("switch-stacks", views.SwitchStackViewSet)
|
||||||
|
router.register("cable-vlans", views.CableVLANAssignmentViewSet)
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
@@ -3,7 +3,7 @@ from netbox.api.viewsets import NetBoxModelViewSet
|
|||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
from .. import disk_filtersets, hardware_filtersets
|
from .. import disk_filtersets, hardware_filtersets
|
||||||
from ..models import CPUModel, DeviceHardware, Disk, DiskBayLayout, DiskBayTemplate, RAIDGroup, SwitchStack
|
from ..models import CableVLANAssignment, CPUModel, DeviceHardware, Disk, DiskBayLayout, DiskBayTemplate, RAIDGroup, SwitchStack
|
||||||
from . import serializers
|
from . import serializers
|
||||||
|
|
||||||
|
|
||||||
@@ -58,3 +58,17 @@ class SwitchStackViewSet(ModelViewSet):
|
|||||||
if params.get("member_id"):
|
if params.get("member_id"):
|
||||||
queryset = queryset.filter(members__in=params.getlist("member_id")).distinct()
|
queryset = queryset.filter(members__in=params.getlist("member_id")).distinct()
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
class CableVLANAssignmentViewSet(ModelViewSet):
|
||||||
|
"""VLANs of cable connections; filter with ``?cable_id=``."""
|
||||||
|
|
||||||
|
queryset = CableVLANAssignment.objects.prefetch_related("vlans").order_by("pk")
|
||||||
|
serializer_class = serializers.CableVLANAssignmentSerializer
|
||||||
|
permission_classes = [TokenPermissions]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
queryset = super().get_queryset()
|
||||||
|
if self.request.query_params.get("cable_id"):
|
||||||
|
queryset = queryset.filter(cable_id__in=self.request.query_params.getlist("cable_id"))
|
||||||
|
return queryset
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
"""Export device types as YAML in the community devicetype-library format.
|
||||||
|
|
||||||
|
The output can be re-imported through NetBox's own "Device Types > Import"
|
||||||
|
form or contributed to https://github.com/netbox-community/devicetype-library.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
from django.apps import apps
|
||||||
|
from django.utils.text import slugify
|
||||||
|
|
||||||
|
# (YAML key, related manager on DeviceType, fields exported per component)
|
||||||
|
COMPONENTS = [
|
||||||
|
("console-ports", "consoleporttemplates", ["type"]),
|
||||||
|
("console-server-ports", "consoleserverporttemplates", ["type"]),
|
||||||
|
("power-ports", "powerporttemplates", ["type", "maximum_draw", "allocated_draw"]),
|
||||||
|
("power-outlets", "poweroutlettemplates", ["type", "power_port", "feed_leg"]),
|
||||||
|
("interfaces", "interfacetemplates", ["type", "mgmt_only", "poe_mode", "poe_type"]),
|
||||||
|
("rear-ports", "rearporttemplates", ["type", "color", "positions"]),
|
||||||
|
("front-ports", "frontporttemplates", ["type", "color", "positions"]),
|
||||||
|
("module-bays", "modulebaytemplates", ["position"]),
|
||||||
|
("device-bays", "devicebaytemplates", []),
|
||||||
|
("inventory-items", "inventoryitemtemplates", ["manufacturer", "part_id"]),
|
||||||
|
]
|
||||||
|
|
||||||
|
DEVICE_TYPE_FIELDS = [
|
||||||
|
"part_number",
|
||||||
|
"u_height",
|
||||||
|
"exclude_from_utilization",
|
||||||
|
"is_full_depth",
|
||||||
|
"subdevice_role",
|
||||||
|
"airflow",
|
||||||
|
"weight",
|
||||||
|
"weight_unit",
|
||||||
|
"description",
|
||||||
|
"comments",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Values that equal NetBox's defaults are dropped to keep the files short.
|
||||||
|
DEFAULTS = {
|
||||||
|
"exclude_from_utilization": False,
|
||||||
|
"mgmt_only": False,
|
||||||
|
"positions": 1,
|
||||||
|
"color": "",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _plain(value):
|
||||||
|
if value is None or value == "":
|
||||||
|
return None
|
||||||
|
if hasattr(value, "is_finite"): # Decimal
|
||||||
|
return int(value) if value == value.to_integral_value() else float(value)
|
||||||
|
if hasattr(value, "_meta"): # FK (power_port, manufacturer)
|
||||||
|
return getattr(value, "name", str(value))
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def _put(target, key, value):
|
||||||
|
value = _plain(value)
|
||||||
|
if value is None or DEFAULTS.get(key, object()) == value:
|
||||||
|
return
|
||||||
|
target[key] = value
|
||||||
|
|
||||||
|
|
||||||
|
def _front_port_mappings(device_type):
|
||||||
|
"""{front_port_id: (rear_port_name, rear_port_position)} for single mappings (NetBox >= 4.5)."""
|
||||||
|
try:
|
||||||
|
model = apps.get_model("dcim", "PortTemplateMapping")
|
||||||
|
except LookupError:
|
||||||
|
return {}
|
||||||
|
mappings = {}
|
||||||
|
for mapping in model.objects.filter(device_type=device_type).select_related("rear_port"):
|
||||||
|
mappings.setdefault(mapping.front_port_id, []).append(mapping)
|
||||||
|
return {
|
||||||
|
front_id: (items[0].rear_port.name, items[0].rear_port_position)
|
||||||
|
for front_id, items in mappings.items()
|
||||||
|
if len(items) == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def device_type_to_dict(device_type):
|
||||||
|
data = {
|
||||||
|
"manufacturer": device_type.manufacturer.name,
|
||||||
|
"model": device_type.model,
|
||||||
|
"slug": device_type.slug,
|
||||||
|
}
|
||||||
|
for field in DEVICE_TYPE_FIELDS:
|
||||||
|
_put(data, field, getattr(device_type, field, None))
|
||||||
|
|
||||||
|
mappings = None
|
||||||
|
for key, manager, fields in COMPONENTS:
|
||||||
|
items = []
|
||||||
|
for component in getattr(device_type, manager).all():
|
||||||
|
item = {"name": component.name}
|
||||||
|
label = getattr(component, "label", "")
|
||||||
|
if label:
|
||||||
|
item["label"] = label
|
||||||
|
for field in fields:
|
||||||
|
if hasattr(component, field):
|
||||||
|
_put(item, field, getattr(component, field))
|
||||||
|
if key == "front-ports":
|
||||||
|
if mappings is None:
|
||||||
|
mappings = _front_port_mappings(device_type)
|
||||||
|
legacy_rear = getattr(component, "rear_port", None)
|
||||||
|
if component.pk in mappings:
|
||||||
|
item["rear_port"], item["rear_port_position"] = mappings[component.pk]
|
||||||
|
elif legacy_rear is not None: # NetBox < 4.5
|
||||||
|
item["rear_port"] = legacy_rear.name
|
||||||
|
item["rear_port_position"] = component.rear_port_position
|
||||||
|
if component.description:
|
||||||
|
item["description"] = component.description
|
||||||
|
items.append(item)
|
||||||
|
if items:
|
||||||
|
data[key] = items
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def device_type_to_yaml(device_type):
|
||||||
|
return yaml.safe_dump(
|
||||||
|
device_type_to_dict(device_type),
|
||||||
|
sort_keys=False,
|
||||||
|
allow_unicode=True,
|
||||||
|
default_flow_style=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def filename(device_type):
|
||||||
|
return f"{device_type.slug or slugify(device_type.model)}.yaml"
|
||||||
|
|
||||||
|
|
||||||
|
def device_types_to_zip(device_types):
|
||||||
|
"""ZIP laid out like the devicetype-library: <Manufacturer>/<slug>.yaml"""
|
||||||
|
buffer = io.BytesIO()
|
||||||
|
with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as archive:
|
||||||
|
for device_type in device_types:
|
||||||
|
archive.writestr(
|
||||||
|
f"{device_type.manufacturer.name}/{filename(device_type)}",
|
||||||
|
device_type_to_yaml(device_type),
|
||||||
|
)
|
||||||
|
return buffer.getvalue()
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
from dcim.filtersets import DeviceTypeFilterSet
|
||||||
|
from dcim.models import DeviceType
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.views import View
|
||||||
|
|
||||||
|
from . import devicetype_export
|
||||||
|
|
||||||
|
PREFETCH = [
|
||||||
|
"consoleporttemplates",
|
||||||
|
"consoleserverporttemplates",
|
||||||
|
"powerporttemplates",
|
||||||
|
"poweroutlettemplates__power_port",
|
||||||
|
"interfacetemplates",
|
||||||
|
"rearporttemplates",
|
||||||
|
"frontporttemplates",
|
||||||
|
"modulebaytemplates",
|
||||||
|
"devicebaytemplates",
|
||||||
|
"inventoryitemtemplates__manufacturer",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _queryset(request):
|
||||||
|
if not request.user.has_perm("dcim.view_devicetype"):
|
||||||
|
raise PermissionDenied
|
||||||
|
return DeviceType.objects.restrict(request.user, "view").select_related("manufacturer").prefetch_related(*PREFETCH)
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceTypeYAMLExportView(LoginRequiredMixin, View):
|
||||||
|
def get(self, request, pk):
|
||||||
|
device_type = get_object_or_404(_queryset(request), pk=pk)
|
||||||
|
response = HttpResponse(devicetype_export.device_type_to_yaml(device_type), content_type="application/yaml; charset=utf-8")
|
||||||
|
response["Content-Disposition"] = f'attachment; filename="{devicetype_export.filename(device_type)}"'
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceTypeBulkYAMLExportView(LoginRequiredMixin, View):
|
||||||
|
"""Exports the current (filtered) device type list, or ?id=... selections, as a ZIP."""
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
device_types = DeviceTypeFilterSet(request.GET, queryset=_queryset(request)).qs.order_by("manufacturer__name", "model")
|
||||||
|
response = HttpResponse(devicetype_export.device_types_to_zip(device_types), content_type="application/zip")
|
||||||
|
response["Content-Disposition"] = 'attachment; filename="device-types.zip"'
|
||||||
|
return response
|
||||||
@@ -564,6 +564,63 @@ a.nbu-disk-slot[draggable="true"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Client Software Übersicht */
|
/* Client Software Übersicht */
|
||||||
|
.nbu-sw-filter-footer {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
padding-top: 0.875rem;
|
||||||
|
border-top: 1px solid var(--tblr-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nbu-sw-roles {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nbu-sw-roles-label {
|
||||||
|
color: var(--tblr-secondary);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-right: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nbu-sw-role {
|
||||||
|
border: 1px solid var(--tblr-border-color);
|
||||||
|
background: var(--tblr-bg-surface);
|
||||||
|
color: var(--tblr-body-color);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nbu-sw-role:hover {
|
||||||
|
border-color: var(--tblr-primary);
|
||||||
|
color: var(--tblr-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-check:checked + .nbu-sw-role {
|
||||||
|
background: var(--tblr-primary);
|
||||||
|
border-color: var(--tblr-primary);
|
||||||
|
color: var(--tblr-primary-fg, #fff);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-check:focus-visible + .nbu-sw-role {
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(var(--tblr-primary-rgb), 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nbu-sw-filter-hint {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
}
|
||||||
|
|
||||||
.nbu-sw-kpi-label {
|
.nbu-sw-kpi-label {
|
||||||
color: var(--tblr-secondary);
|
color: var(--tblr-secondary);
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
|
|||||||
@@ -213,6 +213,29 @@ class ConnectionVLANContent(PluginTemplateExtension):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceTypeExportContent(PluginTemplateExtension):
|
||||||
|
models = ["dcim.devicetype"]
|
||||||
|
|
||||||
|
def _label(self, bulk=False):
|
||||||
|
german = (translation.get_language() or "").startswith("de")
|
||||||
|
return "YAML exportieren" if german else "Export YAML"
|
||||||
|
|
||||||
|
def buttons(self):
|
||||||
|
device_type = self.context["object"]
|
||||||
|
url = reverse("plugins:netbox_utilities:devicetype_yaml", kwargs={"pk": device_type.pk})
|
||||||
|
return self.render("netbox_utilities/devicetype_yaml_button.html", {"url": url, "label": self._label()})
|
||||||
|
|
||||||
|
def list_buttons(self):
|
||||||
|
request = self.context["request"]
|
||||||
|
url = reverse("plugins:netbox_utilities:devicetype_bulk_yaml")
|
||||||
|
query = request.GET.copy()
|
||||||
|
for key in ("page", "per_page", "sort", "export"):
|
||||||
|
query.pop(key, None)
|
||||||
|
if query:
|
||||||
|
url = f"{url}?{query.urlencode()}"
|
||||||
|
return self.render("netbox_utilities/devicetype_yaml_button.html", {"url": url, "label": self._label(True)})
|
||||||
|
|
||||||
|
|
||||||
class RackUtilitiesContent(PluginTemplateExtension):
|
class RackUtilitiesContent(PluginTemplateExtension):
|
||||||
models = ["dcim.rack"]
|
models = ["dcim.rack"]
|
||||||
|
|
||||||
@@ -235,6 +258,7 @@ template_extensions = [
|
|||||||
DeviceUtilitiesContent,
|
DeviceUtilitiesContent,
|
||||||
ConnectionVLANContent,
|
ConnectionVLANContent,
|
||||||
RackUtilitiesContent,
|
RackUtilitiesContent,
|
||||||
|
DeviceTypeExportContent,
|
||||||
ClusterHardwareContent,
|
ClusterHardwareContent,
|
||||||
VirtualMachineHardwareContent,
|
VirtualMachineHardwareContent,
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<a href="{{ url }}" class="btn btn-outline-secondary">
|
||||||
|
<i class="mdi mdi-file-code-outline" aria-hidden="true"></i>
|
||||||
|
{{ label }}
|
||||||
|
</a>
|
||||||
@@ -32,36 +32,47 @@
|
|||||||
<label class="form-label" for="{{ form.tenant_id.id_for_label }}">Mandant</label>
|
<label class="form-label" for="{{ form.tenant_id.id_for_label }}">Mandant</label>
|
||||||
{{ form.tenant_id }}
|
{{ form.tenant_id }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-6 col-xl-2">
|
<div class="col-12 col-md-8 col-xl-4">
|
||||||
<span class="form-label d-block">Gerätrolle</span>
|
|
||||||
{% for choice in form.role_id %}
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
{{ choice.tag }}
|
|
||||||
<label class="form-check-label" for="{{ choice.id_for_label }}">{{ choice.choice_label }}</label>
|
|
||||||
</div>
|
|
||||||
{% empty %}
|
|
||||||
<div class="text-danger small">Keine Client-Rolle gefunden (<code>software_device_roles</code>)</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-md-6 col-xl-2">
|
|
||||||
<label class="form-label" for="id_q">Software suchen</label>
|
<label class="form-label" for="id_q">Software suchen</label>
|
||||||
<input type="search" name="q" id="id_q" value="{{ form.q.value|default:'' }}" class="form-control"
|
<div class="input-icon">
|
||||||
placeholder="Produkt, Hersteller, Version">
|
<span class="input-icon-addon"><i class="mdi mdi-magnify" aria-hidden="true"></i></span>
|
||||||
|
<input type="search" name="q" id="id_q" value="{{ form.q.value|default:'' }}" class="form-control"
|
||||||
|
placeholder="Produkt, Hersteller oder Version">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-xl-2 d-flex gap-2">
|
<div class="col-12 col-md-4 col-xl-2 d-flex gap-2">
|
||||||
<button type="submit" class="btn btn-primary flex-grow-1"><i class="mdi mdi-filter" aria-hidden="true"></i> Anwenden</button>
|
<button type="submit" class="btn btn-primary flex-grow-1">
|
||||||
<a href="{% url 'plugins:netbox_utilities:software_overview' %}" class="btn btn-outline-secondary" title="Filter zurücksetzen">
|
<i class="mdi mdi-filter" aria-hidden="true"></i> Anwenden
|
||||||
<i class="mdi mdi-backspace" aria-hidden="true"></i>
|
</button>
|
||||||
|
<a href="{% url 'plugins:netbox_utilities:software_overview' %}" class="btn btn-outline-secondary btn-icon"
|
||||||
|
title="Filter zurücksetzen" aria-label="Filter zurücksetzen">
|
||||||
|
<i class="mdi mdi-filter-remove-outline" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-text mt-2">
|
|
||||||
{% if scope_label %}
|
<div class="nbu-sw-filter-footer">
|
||||||
<i class="mdi mdi-filter-check text-primary" aria-hidden="true"></i>
|
<div class="nbu-sw-roles" role="group" aria-label="Gerätrolle">
|
||||||
Es gilt der globale Mandantenfilter <strong>{{ scope_label }}</strong>. Eine eigene Auswahl hier hat Vorrang.
|
<span class="nbu-sw-roles-label">Gerätrolle</span>
|
||||||
{% else %}
|
{% for choice in form.role_id %}
|
||||||
Mandantengruppen schließen alle Untergruppen ein. Ohne Gerätrolle werden alle Geräte berücksichtigt.
|
<input type="checkbox" class="btn-check" name="{{ form.role_id.html_name }}" value="{{ choice.data.value }}"
|
||||||
{% endif %}
|
id="{{ choice.id_for_label }}" autocomplete="off" onchange="this.form.requestSubmit()"
|
||||||
|
{% if choice.data.selected %}checked{% endif %}>
|
||||||
|
<label class="btn btn-sm btn-pill nbu-sw-role" for="{{ choice.id_for_label }}">
|
||||||
|
<i class="mdi mdi-laptop" aria-hidden="true"></i> {{ choice.choice_label }}
|
||||||
|
</label>
|
||||||
|
{% empty %}
|
||||||
|
<span class="text-danger small">Keine Client-Rolle gefunden – <code>software_device_roles</code> prüfen.</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="nbu-sw-filter-hint">
|
||||||
|
{% if scope_label %}
|
||||||
|
<span class="badge bg-primary-lt"><i class="mdi mdi-filter-check" aria-hidden="true"></i> Globaler Filter: {{ scope_label }}</span>
|
||||||
|
<span class="text-secondary">Eigene Auswahl hat Vorrang.</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-secondary">Gruppen schließen Untergruppen ein. Ohne Rollenauswahl: alle Client-Rollen.</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -194,7 +205,12 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="card"><div class="card-body text-center text-muted py-5">
|
<div class="card"><div class="card-body text-center text-muted py-5">
|
||||||
<i class="mdi mdi-package-variant-closed mdi-48px d-block mb-2" aria-hidden="true"></i>
|
<i class="mdi mdi-package-variant-closed mdi-48px d-block mb-2" aria-hidden="true"></i>
|
||||||
Für diese Auswahl ist keine Software erfasst.
|
<div class="fs-3 fw-semibold text-body mb-1">Für diese Auswahl ist keine Software erfasst</div>
|
||||||
|
<div class="mx-auto" style="max-width: 36rem;">
|
||||||
|
Softwarelisten des Windows-Agents und des NetBox Synchronizers werden beim Speichern eines Geräts übernommen.
|
||||||
|
Bereits vorhandene Berichte überträgt einmalig
|
||||||
|
<code>manage.py netbox_utilities_sync_software</code>.
|
||||||
|
</div>
|
||||||
{% if can_add %}<div class="mt-3"><a href="{% url 'plugins:netbox_slm:softwareproductinstallation_add' %}" class="btn btn-primary"><i class="mdi mdi-plus-thick" aria-hidden="true"></i> Installation erfassen</a></div>{% endif %}
|
{% if can_add %}<div class="mt-3"><a href="{% url 'plugins:netbox_slm:softwareproductinstallation_add' %}" class="btn btn-primary"><i class="mdi mdi-plus-thick" aria-hidden="true"></i> Installation erfassen</a></div>{% endif %}
|
||||||
</div></div>
|
</div></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from django.urls import include, path
|
|||||||
from netbox.plugins import get_plugin_config
|
from netbox.plugins import get_plugin_config
|
||||||
from utilities.urls import get_model_urls
|
from utilities.urls import get_model_urls
|
||||||
|
|
||||||
from . import disk_views, hardware_views, switch_port_views, views # noqa: F401 - hardware_views registers its model views
|
from . import devicetype_views, disk_views, hardware_views, switch_port_views, views # noqa: F401 - hardware_views registers its model views
|
||||||
|
|
||||||
app_name = "netbox_utilities"
|
app_name = "netbox_utilities"
|
||||||
|
|
||||||
@@ -17,6 +17,16 @@ urlpatterns = [
|
|||||||
views.RackElevationOfflineSVGView.as_view(),
|
views.RackElevationOfflineSVGView.as_view(),
|
||||||
name="rack_elevation_offline_svg",
|
name="rack_elevation_offline_svg",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"device-types/export-yaml/",
|
||||||
|
devicetype_views.DeviceTypeBulkYAMLExportView.as_view(),
|
||||||
|
name="devicetype_bulk_yaml",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"device-types/<int:pk>/export.yaml",
|
||||||
|
devicetype_views.DeviceTypeYAMLExportView.as_view(),
|
||||||
|
name="devicetype_yaml",
|
||||||
|
),
|
||||||
path("settings/", views.UtilitiesSettingsView.as_view(), name="settings"),
|
path("settings/", views.UtilitiesSettingsView.as_view(), name="settings"),
|
||||||
path("tenant/select/", views.SelectTenantView.as_view(), name="select_tenant"),
|
path("tenant/select/", views.SelectTenantView.as_view(), name="select_tenant"),
|
||||||
# Datenträger
|
# Datenträger
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "netbox-utilities"
|
name = "netbox-utilities"
|
||||||
version = "0.29.1"
|
version = "0.31.0"
|
||||||
description = "Navigation, tenant utilities, connection VLANs, partial-width racks, disks, CPU & RAM, switch port export and bulk operations for NetBox 4.6/4.7"
|
description = "Navigation, tenant utilities, connection VLANs, partial-width racks, disks, CPU & RAM, switch port export and bulk operations for NetBox 4.6/4.7"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
|
|||||||
Reference in new issue
Block a user