Просмотр исходного кода

Closes #7884: Add FHRP groups column to interface tables

jeremystretch 4 лет назад
Родитель
Сommit
cd128e557c

+ 1 - 0
docs/release-notes/version-3.1.md

@@ -14,6 +14,7 @@
 * [#7775](https://github.com/netbox-community/netbox/issues/7775) - Enable dynamic config for `CHANGELOG_RETENTION`, `CUSTOM_VALIDATORS`, and `GRAPHQL_ENABLED`
 * [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments
 * [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions
+* [#7884](https://github.com/netbox-community/netbox/issues/7884) - Add FHRP groups column to interface tables
 
 ### Bug Fixes
 

+ 10 - 4
netbox/dcim/tables/devices.py

@@ -475,6 +475,12 @@ class BaseInterfaceTable(BaseTable):
         orderable=False,
         verbose_name='IP Addresses'
     )
+    fhrp_groups = tables.TemplateColumn(
+        accessor=Accessor('fhrp_group_assignments'),
+        template_code=INTERFACE_FHRPGROUPS,
+        orderable=False,
+        verbose_name='FHRP Groups'
+    )
     untagged_vlan = tables.Column(linkify=True)
     tagged_vlans = TemplateColumn(
         template_code=INTERFACE_TAGGED_VLANS,
@@ -509,7 +515,7 @@ class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable
             'pk', 'id', 'name', 'device', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'mode', 'mac_address', 'wwn',
             'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description',
             'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection',
-            'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans',
+            'tags', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans',
         )
         default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description')
 
@@ -542,9 +548,9 @@ class DeviceInterfaceTable(InterfaceTable):
         model = Interface
         fields = (
             'pk', 'id', 'name', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', 'mgmt_only', 'mtu', 'mode',
-            'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_width', 'tx_power', 'description',
-            'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection',
-            'tags', 'ip_addresses', 'untagged_vlan', 'tagged_vlans', 'actions',
+            'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power',
+            'description', 'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer',
+            'connection', 'tags', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions',
         )
         order_by = ('name',)
         default_columns = (

+ 8 - 0
netbox/dcim/tables/template_code.py

@@ -50,6 +50,14 @@ INTERFACE_IPADDRESSES = """
 </div>
 """
 
+INTERFACE_FHRPGROUPS = """
+<div class="table-badge-group">
+  {% for assignment in value.all %}
+    <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.group_id }} ({{ assignment.group.get_protocol_display }})</a>
+  {% endfor %}
+</div>
+"""
+
 INTERFACE_TAGGED_VLANS = """
 {% if record.mode == 'tagged' %}
     {% for vlan in record.tagged_vlans.all %}

+ 2 - 2
netbox/virtualization/tables.py

@@ -171,7 +171,7 @@ class VMInterfaceTable(BaseInterfaceTable):
         model = VMInterface
         fields = (
             'pk', 'id', 'name', 'virtual_machine', 'enabled', 'mac_address', 'mtu', 'mode', 'description', 'tags',
-            'ip_addresses', 'untagged_vlan', 'tagged_vlans',
+            'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans',
         )
         default_columns = ('pk', 'name', 'virtual_machine', 'enabled', 'description')
 
@@ -193,7 +193,7 @@ class VirtualMachineVMInterfaceTable(VMInterfaceTable):
         model = VMInterface
         fields = (
             'pk', 'id', 'name', 'enabled', 'parent', 'bridge', 'mac_address', 'mtu', 'mode', 'description', 'tags',
-            'ip_addresses', 'untagged_vlan', 'tagged_vlans', 'actions',
+            'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions',
         )
         default_columns = (
             'pk', 'name', 'enabled', 'mac_address', 'mtu', 'mode', 'description', 'ip_addresses', 'actions',