Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import django_tables2 as tables
from django_tables2.utils import Accessor
from django.conf import settings

from dcim.models import (
ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceRole, FrontPort, Interface, InventoryItem, Platform,
Expand Down Expand Up @@ -127,11 +128,18 @@ class DeviceTable(BaseTable):
verbose_name='Type',
text=lambda record: record.device_type.display_name
)
primary_ip = tables.Column(
linkify=True,
order_by=('primary_ip6', 'primary_ip4'),
verbose_name='IP Address'
)
if settings.PREFER_IPV4:
primary_ip = tables.Column(
linkify=True,
order_by=('primary_ip4', 'primary_ip6'),
verbose_name='IP Address'
)
else:
primary_ip = tables.Column(
linkify=True,
order_by=('primary_ip6', 'primary_ip4'),
verbose_name='IP Address'
)
primary_ip4 = tables.Column(
linkify=True,
verbose_name='IPv4 Address'
Expand Down
18 changes: 13 additions & 5 deletions netbox/virtualization/tables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import django_tables2 as tables

from django.conf import settings
from dcim.tables.devices import BaseInterfaceTable
from tenancy.tables import COL_TENANT
from utilities.tables import (
Expand Down Expand Up @@ -125,10 +125,18 @@ class VirtualMachineDetailTable(VirtualMachineTable):
linkify=True,
verbose_name='IPv6 Address'
)
primary_ip = tables.Column(
linkify=True,
verbose_name='IP Address'
)
if settings.PREFER_IPV4:
primary_ip = tables.Column(
linkify=True,
order_by=('primary_ip4', 'primary_ip6'),
verbose_name='IP Address'
)
else:
primary_ip = tables.Column(
linkify=True,
order_by=('primary_ip6', 'primary_ip4'),
verbose_name='IP Address'
)
tags = TagColumn(
url_name='virtualization:virtualmachine_list'
)
Expand Down