Skip to content

Commit

Permalink
Fixes: #18447 - Fix sorting by mac_address field
Browse files Browse the repository at this point in the history
* Disable sorting by `mac_address` for legacy `mac_address` field for Device and VM Interfaces
* Ensure `primary_mac_address` field is included in field list for Device and VM Interfaces
  • Loading branch information
DanSheps committed Jan 21, 2025
1 parent b913661 commit d191459
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ class DeviceInterfaceTable(InterfaceTable):
linkify=True,
verbose_name=_('LAG')
)
mac_address = tables.Column(
verbose_name=_('MAC Address'),
orderable=False,
)
actions = columns.ActionsColumn(
extra_buttons=INTERFACE_BUTTONS
)
Expand All @@ -705,10 +709,10 @@ class Meta(DeviceComponentTable.Meta):
model = models.Interface
fields = (
'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',
'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'actions',
'mgmt_only', 'mtu', 'mode', 'mac_address', 'primary_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', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mtu', 'mode', 'description', 'ip_addresses',
Expand Down
8 changes: 6 additions & 2 deletions netbox/virtualization/tables/virtualmachines.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,19 @@ class VMInterfaceTable(BaseInterfaceTable):
verbose_name=_('VRF'),
linkify=True
)
mac_address = tables.Column(
verbose_name=_('MAC Address'),
orderable=False,
)
tags = columns.TagColumn(
url_name='virtualization:vminterface_list'
)

class Meta(NetBoxTable.Meta):
model = VMInterface
fields = (
'pk', 'id', 'name', 'virtual_machine', 'enabled', 'mac_address', 'mtu', 'mode', 'description', 'tags',
'vrf', 'primary_mac_address', 'l2vpn', 'tunnel', 'ip_addresses', 'fhrp_groups', 'untagged_vlan',
'pk', 'id', 'name', 'virtual_machine', 'enabled', 'mtu', 'mode', 'description', 'tags', 'vrf',
'mac_address', 'primary_mac_address', 'l2vpn', 'tunnel', 'ip_addresses', 'fhrp_groups', 'untagged_vlan',
'tagged_vlans', 'qinq_svlan', 'created', 'last_updated',
)
default_columns = ('pk', 'name', 'virtual_machine', 'enabled', 'description')
Expand Down

0 comments on commit d191459

Please sign in to comment.