2021-11-01 16:14:44 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
|
|
|
from ipam.models import *
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2021-11-01 16:14:44 -04:00
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'FHRPGroupTable',
|
|
|
|
'FHRPGroupAssignmentTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
IPADDRESSES = """
|
|
|
|
{% for ip in record.ip_addresses.all %}
|
|
|
|
<a href="{{ ip.get_absolute_url }}">{{ ip }}</a><br />
|
|
|
|
{% endfor %}
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class FHRPGroupTable(NetBoxTable):
|
2021-11-01 16:14:44 -04:00
|
|
|
group_id = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
2021-11-01 16:14:44 -04:00
|
|
|
ip_addresses = tables.TemplateColumn(
|
|
|
|
template_code=IPADDRESSES,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='IP Addresses'
|
|
|
|
)
|
2022-03-07 09:00:00 -05:00
|
|
|
member_count = tables.Column(
|
|
|
|
verbose_name='Members'
|
2021-11-01 16:14:44 -04:00
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-11-01 16:14:44 -04:00
|
|
|
url_name='ipam:fhrpgroup_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-11-01 16:14:44 -04:00
|
|
|
model = FHRPGroup
|
|
|
|
fields = (
|
2022-03-07 09:00:00 -05:00
|
|
|
'pk', 'group_id', 'protocol', 'auth_type', 'auth_key', 'description', 'ip_addresses', 'member_count',
|
2022-01-17 11:12:54 -05:00
|
|
|
'tags', 'created', 'last_updated',
|
2021-11-01 16:14:44 -04:00
|
|
|
)
|
2022-03-07 09:00:00 -05:00
|
|
|
default_columns = ('pk', 'group_id', 'protocol', 'auth_type', 'description', 'ip_addresses', 'member_count')
|
2021-11-01 16:14:44 -04:00
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class FHRPGroupAssignmentTable(NetBoxTable):
|
2021-11-04 10:05:47 -04:00
|
|
|
interface_parent = tables.Column(
|
2022-02-02 09:18:50 -05:00
|
|
|
accessor=tables.A('interface__parent_object'),
|
2021-11-02 09:05:56 -04:00
|
|
|
linkify=True,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Parent'
|
2021-11-01 16:14:44 -04:00
|
|
|
)
|
2021-11-02 15:10:02 -04:00
|
|
|
interface = tables.Column(
|
2021-11-01 16:14:44 -04:00
|
|
|
linkify=True,
|
|
|
|
orderable=False
|
|
|
|
)
|
|
|
|
group = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-03-14 13:45:21 -04:00
|
|
|
actions=('edit', 'delete')
|
2021-11-02 09:05:56 -04:00
|
|
|
)
|
2021-11-01 16:14:44 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-11-01 16:14:44 -04:00
|
|
|
model = FHRPGroupAssignment
|
2021-11-04 10:05:47 -04:00
|
|
|
fields = ('pk', 'group', 'interface_parent', 'interface', 'priority')
|
|
|
|
exclude = ('id',)
|