1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #1496: Added primary IP column to virtual machine list

This commit is contained in:
Jeremy Stretch
2017-09-15 11:47:29 -04:00
parent d053422657
commit 039c2a6d57
2 changed files with 18 additions and 2 deletions

View File

@ -24,6 +24,12 @@ VIRTUALMACHINE_STATUS = """
<span class="label label-{{ record.get_status_class }}">{{ record.get_status_display }}</span>
"""
VIRTUALMACHINE_PRIMARY_IP = """
{{ record.primary_ip6.address.ip|default:"" }}
{% if record.primary_ip6 and record.primary_ip4 %}<br />{% endif %}
{{ record.primary_ip4.address.ip|default:"" }}
"""
#
# Cluster types
@ -92,6 +98,16 @@ class VirtualMachineTable(BaseTable):
fields = ('pk', 'name', 'status', 'cluster', 'tenant', 'vcpus', 'memory', 'disk')
class VirtualMachineDetailTable(VirtualMachineTable):
primary_ip = tables.TemplateColumn(
orderable=False, verbose_name='IP Address', template_code=VIRTUALMACHINE_PRIMARY_IP
)
class Meta(BaseTable.Meta):
model = VirtualMachine
fields = ('pk', 'name', 'status', 'cluster', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip')
#
# VM components
#