2020-10-16 10:39:13 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
from dcim.models import PowerFeed, PowerPanel
|
2022-10-18 13:47:14 -07:00
|
|
|
from tenancy.tables import ContactsColumnMixin
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-10-18 13:47:14 -07:00
|
|
|
|
2020-10-16 11:11:41 -04:00
|
|
|
from .devices import CableTerminationTable
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'PowerFeedTable',
|
|
|
|
'PowerPanelTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Power panels
|
|
|
|
#
|
|
|
|
|
2022-10-18 13:47:14 -07:00
|
|
|
class PowerPanelTable(ContactsColumnMixin, NetBoxTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
site = tables.Column(
|
|
|
|
linkify=True
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
2022-08-01 10:32:05 -04:00
|
|
|
location = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
powerfeed_count = columns.LinkedCountColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
viewname='dcim:powerfeed_list',
|
|
|
|
url_params={'power_panel_id': 'pk'},
|
|
|
|
verbose_name='Feeds'
|
|
|
|
)
|
2022-11-04 08:28:09 -04:00
|
|
|
comments = columns.MarkdownColumn()
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:powerpanel_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2020-10-16 10:39:13 -04:00
|
|
|
model = PowerPanel
|
2022-08-01 10:32:05 -04:00
|
|
|
fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'pk', 'id', 'name', 'site', 'location', 'powerfeed_count', 'contacts', 'description', 'comments', 'tags',
|
|
|
|
'created', 'last_updated',
|
2022-08-01 10:32:05 -04:00
|
|
|
)
|
2021-03-03 13:30:33 -05:00
|
|
|
default_columns = ('pk', 'name', 'site', 'location', 'powerfeed_count')
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Power feeds
|
|
|
|
#
|
|
|
|
|
2020-10-16 11:41:24 -04:00
|
|
|
# We're not using PathEndpointTable for PowerFeed because power connections
|
|
|
|
# cannot traverse pass-through ports.
|
2020-10-16 11:11:41 -04:00
|
|
|
class PowerFeedTable(CableTerminationTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
power_panel = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
rack = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
|
|
|
type = columns.ChoiceFieldColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
max_utilization = tables.TemplateColumn(
|
|
|
|
template_code="{{ value }}%"
|
|
|
|
)
|
|
|
|
available_power = tables.Column(
|
|
|
|
verbose_name='Available power (VA)'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
tags = columns.TagColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
url_name='dcim:powerfeed_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2020-10-16 10:39:13 -04:00
|
|
|
model = PowerFeed
|
|
|
|
fields = (
|
2021-11-02 16:21:34 -04:00
|
|
|
'pk', 'id', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase',
|
2023-01-20 08:18:27 -08:00
|
|
|
'max_utilization', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'available_power',
|
2022-11-04 08:28:09 -04:00
|
|
|
'description', 'comments', 'tags', 'created', 'last_updated',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'cable',
|
2021-10-13 14:04:53 -04:00
|
|
|
'link_peer',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|