-
Notifications
You must be signed in to change notification settings - Fork 0
feat: multi-server librenms_id — track device origin per LibreNMS server #20
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
Changes from all commits
3518a6e
f1b1f45
b943969
c8fd7a7
5e3ad5c
5c6f9a9
3427ed9
8fc6b32
313e897
c33c91a
fbd6dc8
27b2242
e99896a
72be41a
f9ae8bd
b82b097
460c05c
e8aea5b
2e52600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| convert_speed_to_kbps, | ||
| format_mac_address, | ||
| get_interface_name_field, | ||
| get_librenms_device_id, | ||
| get_missing_vlan_warning, | ||
| get_table_paginate_count, | ||
| get_tagged_vlan_css_class, | ||
|
|
@@ -46,11 +47,12 @@ class Meta: | |
| "id": "librenms-interface-table", | ||
| } | ||
|
|
||
| def __init__(self, *args, device=None, interface_name_field=None, vlan_groups=None, **kwargs): | ||
| def __init__(self, *args, device=None, interface_name_field=None, vlan_groups=None, server_key="default", **kwargs): | ||
| """Initialize table with device context and interface name field.""" | ||
| self.device = device | ||
| self.interface_name_field = interface_name_field or get_interface_name_field() | ||
| self.vlan_groups = vlan_groups or [] | ||
| self.server_key = server_key | ||
|
Comment on lines
+50
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Make
Proposed hardening- def __init__(self, *args, device=None, interface_name_field=None, vlan_groups=None, server_key="default", **kwargs):
+ def __init__(self, *args, device=None, interface_name_field=None, vlan_groups=None, server_key=None, **kwargs):
"""Initialize table with device context and interface name field."""
self.device = device
self.interface_name_field = interface_name_field or get_interface_name_field()
self.vlan_groups = vlan_groups or []
- self.server_key = server_key
+ if server_key is None:
+ raise ValueError("server_key is required for LibreNMSInterfaceTable")
+ self.server_key = server_key🤖 Prompt for AI Agents |
||
|
|
||
| # Update column accessors after initialization | ||
| for column in ["selection", "name"]: | ||
|
|
@@ -360,7 +362,7 @@ def render_librenms_id(self, value, record): | |
| if not netbox_interface: | ||
| return mark_safe(f'<span class="text-danger">{value}</span>') | ||
|
|
||
| netbox_librenms_id = netbox_interface.custom_field_data.get("librenms_id") | ||
| netbox_librenms_id = get_librenms_device_id(netbox_interface, self.server_key, auto_save=False) | ||
|
|
||
| if netbox_librenms_id is None: | ||
| return mark_safe( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.