Skip to content
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

Show virtual ips in interfaces table #18075

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mskalecki
Copy link
Contributor

Fixes: #18070

Adds a column named Virtual IPs to the interfaces table.

The new column behaves almost exactly like the existing column for directly assigned IP addresses, except that it doesn't limit the number of virtual IPs displayed directly on the table. Since the virtual IPs could come from multiple FHRP Groups, I don't see an easy way to link to a filtered table of IPs that are virtual IPs of the interface.

If that is a problem, I can limit the number that are displayed and add an elipsis (or something to indicate that the list is cropped), or maybe someone with real django experience can figure it out.

@@ -557,6 +557,12 @@ class BaseInterfaceTable(NetBoxTable):
orderable=False,
verbose_name=_('IP Addresses')
)
virtual_ips = tables.TemplateColumn(
accessor=Accessor('fhrp_group_assignments'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
accessor=Accessor('fhrp_group_assignments'),
accessor=Accessor('fhrp_group_assignments__ip_addresses'),

We should reference the IP assignments directly to ensure they are prefetched when the table column is displayed.

@@ -557,6 +557,12 @@ class BaseInterfaceTable(NetBoxTable):
orderable=False,
verbose_name=_('IP Addresses')
)
virtual_ips = tables.TemplateColumn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a ManyToManyColumn with linkify_item=True IMO. We should avoid custom template code where possible.

@@ -557,6 +557,12 @@ class BaseInterfaceTable(NetBoxTable):
orderable=False,
verbose_name=_('IP Addresses')
)
virtual_ips = tables.TemplateColumn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest renaming this to fhrp_group_ips or similar, as "virtual" IPs may not be quite clear to the user.

@@ -675,7 +681,7 @@ class Meta(DeviceComponentTable.Meta):
'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', 'actions',
'virtual_ips', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'actions',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be added to VirtualMachineVMInterfaceTable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add column in Interfaces tables for Virtual IPs in assigned FHRP groups
2 participants