From 4d3515f08e838b0531f41e332f096d48caf972e2 Mon Sep 17 00:00:00 2001 From: Matt Skalecki Date: Thu, 21 Nov 2024 12:57:51 -0500 Subject: [PATCH 1/2] add `virtual ips` column to interfaces table --- netbox/dcim/tables/devices.py | 10 ++++++++-- netbox/dcim/tables/template_code.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 70b2973662a..d00095b8383 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -557,6 +557,12 @@ class BaseInterfaceTable(NetBoxTable): orderable=False, verbose_name=_('IP Addresses') ) + virtual_ips = tables.TemplateColumn( + accessor=Accessor('fhrp_group_assignments'), + template_code=INTERFACE_VIRTUAL_IPS, + orderable=False, + verbose_name=_('Virtual IPs') + ) fhrp_groups = tables.TemplateColumn( accessor=Accessor('fhrp_group_assignments'), template_code=INTERFACE_FHRPGROUPS, @@ -637,7 +643,7 @@ class Meta(DeviceComponentTable.Meta): 'speed', 'speed_formatted', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', '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', 'vdcs', 'vrf', 'l2vpn', - 'tunnel', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'inventory_items', 'created', + 'tunnel', 'ip_addresses', 'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'inventory_items', 'created', 'last_updated', ) default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description') @@ -674,7 +680,7 @@ class Meta(DeviceComponentTable.Meta): 'pk', 'id', 'name', 'module_bay', 'module', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', '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', 'vdcs', 'vrf', 'l2vpn', 'tunnel', 'ip_addresses', + 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn', 'tunnel', 'ip_addresses', 'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions', ) default_columns = ( diff --git a/netbox/dcim/tables/template_code.py b/netbox/dcim/tables/template_code.py index 96ab803e6a7..ce15457e4e7 100644 --- a/netbox/dcim/tables/template_code.py +++ b/netbox/dcim/tables/template_code.py @@ -48,6 +48,18 @@ {% endif %} """ +INTERFACE_VIRTUAL_IPS = """ + {% for fhrp_assignment in value.all %} + {% for ip in fhrp_assignment.group.ip_addresses.all %} + {% if ip.status != 'active' %} + {{ ip }} + {% else %} + {{ ip }} + {% endif %} + {% endfor %} + {% endfor %} +""" + INTERFACE_FHRPGROUPS = """ {% for assignment in value.all %} {{ assignment.group.get_protocol_display }}: {{ assignment.group.group_id }} From ba4814858d1c3be070d8980e8f207f524ea8e3c5 Mon Sep 17 00:00:00 2001 From: Matt Skalecki Date: Fri, 22 Nov 2024 13:03:08 -0500 Subject: [PATCH 2/2] rebalance line lengths for fields list --- netbox/dcim/tables/devices.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index d00095b8383..13247b27147 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -643,8 +643,8 @@ class Meta(DeviceComponentTable.Meta): 'speed', 'speed_formatted', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', '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', 'vdcs', 'vrf', 'l2vpn', - 'tunnel', 'ip_addresses', 'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'inventory_items', 'created', - 'last_updated', + 'tunnel', 'ip_addresses', 'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'inventory_items', + 'created', 'last_updated', ) default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description') @@ -680,8 +680,8 @@ class Meta(DeviceComponentTable.Meta): 'pk', 'id', 'name', 'module_bay', 'module', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', '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', 'vdcs', 'vrf', 'l2vpn', 'tunnel', 'ip_addresses', 'virtual_ips', - 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions', + 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn', 'tunnel', 'ip_addresses', + 'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions', ) default_columns = ( 'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mtu', 'mode', 'description', 'ip_addresses',