2016-03-01 11:23:03 -05:00
|
|
|
import django_tables2 as tables
|
|
|
|
from django_tables2.utils import Accessor
|
|
|
|
|
2018-01-30 11:57:21 -05:00
|
|
|
from tenancy.tables import COL_TENANT
|
2018-10-26 13:14:12 -04:00
|
|
|
from utilities.tables import BaseTable, BooleanColumn, ColorColumn, ToggleColumn
|
2016-05-18 16:02:53 -04:00
|
|
|
from .models import (
|
2018-12-05 16:53:58 -05:00
|
|
|
Cable, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
|
|
|
|
DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate,
|
2019-03-11 22:40:52 -04:00
|
|
|
InventoryItem, Manufacturer, Platform, PowerFeed, PowerOutlet, PowerOutletTemplate, PowerPanel, PowerPort,
|
|
|
|
PowerPortTemplate, Rack, RackGroup, RackReservation, RackRole, RearPort, RearPortTemplate, Region, Site,
|
|
|
|
VirtualChassis,
|
2016-05-18 16:02:53 -04:00
|
|
|
)
|
|
|
|
|
2017-02-28 14:15:15 -05:00
|
|
|
REGION_LINK = """
|
|
|
|
{% if record.get_children %}
|
2017-03-08 12:04:50 -05:00
|
|
|
<span style="padding-left: {{ record.get_ancestors|length }}0px "><i class="fa fa-caret-right"></i>
|
2017-02-28 14:15:15 -05:00
|
|
|
{% else %}
|
|
|
|
<span style="padding-left: {{ record.get_ancestors|length }}9px">
|
|
|
|
{% endif %}
|
2017-03-08 12:04:50 -05:00
|
|
|
<a href="{% url 'dcim:site_list' %}?region={{ record.slug }}">{{ record.name }}</a>
|
2017-02-28 14:15:15 -05:00
|
|
|
</span>
|
|
|
|
"""
|
|
|
|
|
|
|
|
SITE_REGION_LINK = """
|
|
|
|
{% if record.region %}
|
|
|
|
<a href="{% url 'dcim:site_list' %}?region={{ record.region.slug }}">{{ record.region }}</a>
|
|
|
|
{% else %}
|
|
|
|
—
|
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2016-08-10 22:20:09 -04:00
|
|
|
COLOR_LABEL = """
|
2018-12-19 12:17:40 -05:00
|
|
|
{% load helpers %}
|
|
|
|
<label class="label" style="color: {{ record.color|fgcolor }}; background-color: #{{ record.color }}">{{ record }}</label>
|
2016-08-10 22:20:09 -04:00
|
|
|
"""
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
DEVICE_LINK = """
|
2016-05-18 16:02:53 -04:00
|
|
|
<a href="{% url 'dcim:device' pk=record.pk %}">
|
|
|
|
{{ record.name|default:'<span class="label label-info">Unnamed device</span>' }}
|
|
|
|
</a>
|
2016-03-01 11:23:03 -05:00
|
|
|
"""
|
|
|
|
|
2017-02-28 12:11:43 -05:00
|
|
|
REGION_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:region_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2017-02-28 12:11:43 -05:00
|
|
|
{% if perms.dcim.change_region %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:region_edit' pk=record.pk %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2017-02-28 12:11:43 -05:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2016-07-28 15:04:27 -04:00
|
|
|
RACKGROUP_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:rackgroup_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2018-03-07 11:37:05 -05:00
|
|
|
<a href="{% url 'dcim:rack_elevation_list' %}?site={{ record.site.slug }}&group_id={{ record.pk }}" class="btn btn-xs btn-primary" title="View elevations">
|
|
|
|
<i class="fa fa-eye"></i>
|
|
|
|
</a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% if perms.dcim.change_rackgroup %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:rackgroup_edit' pk=record.pk %}?return_url={{ request.path }}" class="btn btn-xs btn-warning" title="Edit">
|
2018-03-07 11:37:05 -05:00
|
|
|
<i class="glyphicon glyphicon-pencil"></i>
|
|
|
|
</a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% endif %}
|
2016-03-30 12:26:37 -04:00
|
|
|
"""
|
|
|
|
|
2016-08-10 11:52:27 -04:00
|
|
|
RACKROLE_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:rackrole_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2016-08-10 11:52:27 -04:00
|
|
|
{% if perms.dcim.change_rackrole %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:rackrole_edit' pk=record.pk %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2016-08-10 11:52:27 -04:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2016-08-10 22:20:09 -04:00
|
|
|
RACK_ROLE = """
|
|
|
|
{% if record.role %}
|
2019-09-24 08:50:23 -05:00
|
|
|
{% load helpers %}
|
|
|
|
<label class="label" style="color: {{ record.role.color|fgcolor }}; background-color: #{{ record.role.color }}">{{ value }}</label>
|
2016-08-10 22:20:09 -04:00
|
|
|
{% else %}
|
|
|
|
—
|
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2018-02-02 17:46:23 -05:00
|
|
|
RACK_DEVICE_COUNT = """
|
|
|
|
<a href="{% url 'dcim:device_list' %}?rack_id={{ record.pk }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
2017-04-06 16:26:48 -04:00
|
|
|
RACKRESERVATION_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:rackreservation_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2017-04-06 16:26:48 -04:00
|
|
|
{% if perms.dcim.change_rackreservation %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:rackreservation_edit' pk=record.pk %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2017-04-06 16:26:48 -04:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2016-07-28 15:04:27 -04:00
|
|
|
MANUFACTURER_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:manufacturer_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% if perms.dcim.change_manufacturer %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:manufacturer_edit' slug=record.slug %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% endif %}
|
2016-05-13 15:22:31 -04:00
|
|
|
"""
|
|
|
|
|
2018-06-20 14:54:04 -04:00
|
|
|
DEVICEROLE_ACTIONS = """
|
|
|
|
<a href="{% url 'dcim:devicerole_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
|
|
|
{% if perms.dcim.change_devicerole %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:devicerole_edit' slug=record.slug %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2018-06-20 14:54:04 -04:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2018-02-02 17:46:23 -05:00
|
|
|
DEVICEROLE_DEVICE_COUNT = """
|
|
|
|
<a href="{% url 'dcim:device_list' %}?role={{ record.slug }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
|
|
|
DEVICEROLE_VM_COUNT = """
|
|
|
|
<a href="{% url 'virtualization:virtualmachine_list' %}?role={{ record.slug }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
2018-02-02 16:49:38 -05:00
|
|
|
PLATFORM_DEVICE_COUNT = """
|
|
|
|
<a href="{% url 'dcim:device_list' %}?platform={{ record.slug }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
|
|
|
PLATFORM_VM_COUNT = """
|
|
|
|
<a href="{% url 'virtualization:virtualmachine_list' %}?platform={{ record.slug }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
2016-07-28 15:04:27 -04:00
|
|
|
PLATFORM_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:platform_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% if perms.dcim.change_platform %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:platform_edit' slug=record.slug %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2016-05-18 16:02:53 -04:00
|
|
|
{% endif %}
|
2016-05-16 11:54:17 -04:00
|
|
|
"""
|
|
|
|
|
2016-08-10 22:20:09 -04:00
|
|
|
DEVICE_ROLE = """
|
2019-02-13 10:06:56 -05:00
|
|
|
{% load helpers %}
|
|
|
|
<label class="label" style="color: {{ record.device_role.color|fgcolor }}; background-color: #{{ record.device_role.color }}">{{ value }}</label>
|
2016-08-10 22:20:09 -04:00
|
|
|
"""
|
|
|
|
|
2018-01-25 13:07:04 -05:00
|
|
|
STATUS_LABEL = """
|
2017-05-08 13:55:19 -04:00
|
|
|
<span class="label label-{{ record.get_status_class }}">{{ record.get_status_display }}</span>
|
2016-05-10 15:00:38 -04:00
|
|
|
"""
|
|
|
|
|
2019-03-12 11:36:29 -04:00
|
|
|
TYPE_LABEL = """
|
|
|
|
<span class="label label-{{ record.get_type_class }}">{{ record.get_type_display }}</span>
|
|
|
|
"""
|
|
|
|
|
2017-02-28 16:46:44 -05:00
|
|
|
DEVICE_PRIMARY_IP = """
|
|
|
|
{{ record.primary_ip6.address.ip|default:"" }}
|
|
|
|
{% if record.primary_ip6 and record.primary_ip4 %}<br />{% endif %}
|
|
|
|
{{ record.primary_ip4.address.ip|default:"" }}
|
|
|
|
"""
|
|
|
|
|
2018-03-14 15:18:24 -04:00
|
|
|
DEVICETYPE_INSTANCES_TEMPLATE = """
|
|
|
|
<a href="{% url 'dcim:device_list' %}?manufacturer_id={{ record.manufacturer_id }}&device_type_id={{ record.pk }}">{{ record.instance_count }}</a>
|
|
|
|
"""
|
|
|
|
|
2016-07-20 13:22:20 -04:00
|
|
|
UTILIZATION_GRAPH = """
|
2016-07-20 13:56:17 -04:00
|
|
|
{% load helpers %}
|
2016-10-31 16:44:00 -04:00
|
|
|
{% utilization_graph value %}
|
2016-07-20 13:22:20 -04:00
|
|
|
"""
|
|
|
|
|
2017-11-17 16:47:26 -05:00
|
|
|
VIRTUALCHASSIS_ACTIONS = """
|
2018-06-20 14:54:04 -04:00
|
|
|
<a href="{% url 'dcim:virtualchassis_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
|
|
|
<i class="fa fa-history"></i>
|
|
|
|
</a>
|
2017-11-17 16:47:26 -05:00
|
|
|
{% if perms.dcim.change_virtualchassis %}
|
2019-04-08 14:10:55 -04:00
|
|
|
<a href="{% url 'dcim:virtualchassis_edit' pk=record.pk %}?return_url={{ request.path }}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
2017-11-17 16:47:26 -05:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2018-11-01 14:14:31 -04:00
|
|
|
CABLE_TERMINATION_PARENT = """
|
|
|
|
{% if value.device %}
|
|
|
|
<a href="{{ value.device.get_absolute_url }}">{{ value.device }}</a>
|
2019-11-26 16:56:11 -05:00
|
|
|
{% elif value.circuit %}
|
2018-11-01 14:14:31 -04:00
|
|
|
<a href="{{ value.circuit.get_absolute_url }}">{{ value.circuit }}</a>
|
2019-11-26 16:56:11 -05:00
|
|
|
{% elif value.power_panel %}
|
|
|
|
<a href="{{ value.power_panel.get_absolute_url }}">{{ value.power_panel }}</a>
|
2018-11-01 14:14:31 -04:00
|
|
|
{% endif %}
|
|
|
|
"""
|
|
|
|
|
2018-10-26 10:28:25 -04:00
|
|
|
CABLE_LENGTH = """
|
2018-12-11 13:47:24 -05:00
|
|
|
{% if record.length %}{{ record.length }} {{ record.get_length_unit_display }}{% else %}—{% endif %}
|
2018-10-26 10:28:25 -04:00
|
|
|
"""
|
|
|
|
|
2019-04-19 13:32:46 -04:00
|
|
|
POWERPANEL_POWERFEED_COUNT = """
|
|
|
|
<a href="{% url 'dcim:powerfeed_list' %}?power_panel_id={{ record.pk }}">{{ value }}</a>
|
|
|
|
"""
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2019-10-07 17:08:51 -04:00
|
|
|
def get_component_template_actions(model_name):
|
|
|
|
return """
|
|
|
|
{{% if perms.dcim.change_{model_name} %}}
|
|
|
|
<a href="{{% url 'dcim:{model_name}_edit' pk=record.pk %}}?return_url={{{{ request.path }}}}" class="btn btn-xs btn-warning">
|
|
|
|
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
|
|
|
|
</a>
|
|
|
|
{{% endif %}}
|
|
|
|
""".format(model_name=model_name).strip()
|
|
|
|
|
|
|
|
|
2017-02-28 12:11:43 -05:00
|
|
|
#
|
|
|
|
# Regions
|
|
|
|
#
|
|
|
|
|
|
|
|
class RegionTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2017-02-28 14:15:15 -05:00
|
|
|
name = tables.TemplateColumn(template_code=REGION_LINK, orderable=False)
|
2017-02-28 12:11:43 -05:00
|
|
|
site_count = tables.Column(verbose_name='Sites')
|
|
|
|
slug = tables.Column(verbose_name='Slug')
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=REGION_ACTIONS,
|
2019-03-05 15:42:47 -06:00
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
2017-02-28 12:11:43 -05:00
|
|
|
verbose_name=''
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Region
|
|
|
|
fields = ('pk', 'name', 'site_count', 'slug', 'actions')
|
|
|
|
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
#
|
|
|
|
# Sites
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class SiteTable(BaseTable):
|
2016-07-28 15:30:29 -04:00
|
|
|
pk = ToggleColumn()
|
2018-06-11 15:10:31 -04:00
|
|
|
name = tables.LinkColumn(order_by=('_nat1', '_nat2', '_nat3'))
|
2018-01-25 13:07:04 -05:00
|
|
|
status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status')
|
2017-03-29 16:05:23 -04:00
|
|
|
region = tables.TemplateColumn(template_code=SITE_REGION_LINK)
|
2018-01-30 11:57:21 -05:00
|
|
|
tenant = tables.TemplateColumn(template_code=COL_TENANT)
|
2017-07-12 16:42:45 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Site
|
2018-01-25 13:29:09 -05:00
|
|
|
fields = ('pk', 'name', 'status', 'facility', 'region', 'tenant', 'asn', 'description')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
2016-03-30 12:26:37 -04:00
|
|
|
#
|
|
|
|
# Rack groups
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class RackGroupTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-03-07 11:37:05 -05:00
|
|
|
name = tables.LinkColumn()
|
|
|
|
site = tables.LinkColumn(
|
|
|
|
viewname='dcim:site',
|
|
|
|
args=[Accessor('site.slug')],
|
|
|
|
verbose_name='Site'
|
|
|
|
)
|
|
|
|
rack_count = tables.Column(
|
|
|
|
verbose_name='Racks'
|
|
|
|
)
|
|
|
|
slug = tables.Column()
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=RACKGROUP_ACTIONS,
|
2019-03-05 15:42:47 -06:00
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
2018-03-07 11:37:05 -05:00
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-30 12:26:37 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-30 12:26:37 -04:00
|
|
|
model = RackGroup
|
2016-07-28 15:04:27 -04:00
|
|
|
fields = ('pk', 'name', 'site', 'rack_count', 'slug', 'actions')
|
2016-03-30 12:26:37 -04:00
|
|
|
|
|
|
|
|
2016-08-10 11:52:27 -04:00
|
|
|
#
|
|
|
|
# Rack roles
|
|
|
|
#
|
|
|
|
|
|
|
|
class RackRoleTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
rack_count = tables.Column(verbose_name='Racks')
|
2019-12-10 12:53:28 -05:00
|
|
|
color = tables.TemplateColumn(COLOR_LABEL)
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=RACKROLE_ACTIONS,
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-08-10 11:52:27 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
2018-11-09 09:46:30 -05:00
|
|
|
model = RackRole
|
2019-12-10 12:53:28 -05:00
|
|
|
fields = ('pk', 'name', 'rack_count', 'color', 'description', 'slug', 'actions')
|
2016-08-10 11:52:27 -04:00
|
|
|
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
#
|
|
|
|
# Racks
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class RackTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-06-11 15:10:31 -04:00
|
|
|
name = tables.LinkColumn(order_by=('_nat1', '_nat2', '_nat3'))
|
2017-03-29 16:05:23 -04:00
|
|
|
site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')])
|
2016-05-11 15:28:46 -04:00
|
|
|
group = tables.Column(accessor=Accessor('group.name'), verbose_name='Group')
|
2018-01-30 11:57:21 -05:00
|
|
|
tenant = tables.TemplateColumn(template_code=COL_TENANT)
|
2018-11-01 16:03:42 -04:00
|
|
|
status = tables.TemplateColumn(STATUS_LABEL)
|
2017-03-29 16:05:23 -04:00
|
|
|
role = tables.TemplateColumn(RACK_ROLE)
|
2016-07-26 16:46:22 -04:00
|
|
|
u_height = tables.TemplateColumn("{{ record.u_height }}U", verbose_name='Height')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Rack
|
2018-11-01 16:03:42 -04:00
|
|
|
fields = ('pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'u_height')
|
2017-03-29 16:05:23 -04:00
|
|
|
|
|
|
|
|
2017-07-12 16:42:45 -04:00
|
|
|
class RackDetailTable(RackTable):
|
2018-02-02 17:46:23 -05:00
|
|
|
device_count = tables.TemplateColumn(
|
|
|
|
template_code=RACK_DEVICE_COUNT,
|
|
|
|
verbose_name='Devices'
|
|
|
|
)
|
2019-06-19 10:51:53 -04:00
|
|
|
get_utilization = tables.TemplateColumn(
|
|
|
|
template_code=UTILIZATION_GRAPH,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Space'
|
|
|
|
)
|
|
|
|
get_power_utilization = tables.TemplateColumn(
|
|
|
|
template_code=UTILIZATION_GRAPH,
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Power'
|
|
|
|
)
|
2017-03-29 16:05:23 -04:00
|
|
|
|
2017-07-12 16:42:45 -04:00
|
|
|
class Meta(RackTable.Meta):
|
|
|
|
fields = (
|
2018-11-01 16:03:42 -04:00
|
|
|
'pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count',
|
2019-06-16 06:11:32 -04:00
|
|
|
'get_utilization', 'get_power_utilization',
|
2017-07-12 16:42:45 -04:00
|
|
|
)
|
2016-07-25 12:04:42 -04:00
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2017-04-06 16:26:48 -04:00
|
|
|
#
|
|
|
|
# Rack reservations
|
|
|
|
#
|
|
|
|
|
|
|
|
class RackReservationTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2019-05-17 23:24:58 +02:00
|
|
|
site = tables.LinkColumn(
|
|
|
|
viewname='dcim:site',
|
|
|
|
accessor=Accessor('rack.site'),
|
|
|
|
args=[Accessor('rack.site.slug')],
|
|
|
|
)
|
2019-03-05 08:10:10 -06:00
|
|
|
tenant = tables.TemplateColumn(template_code=COL_TENANT)
|
2017-04-06 16:26:48 -04:00
|
|
|
rack = tables.LinkColumn('dcim:rack', args=[Accessor('rack.pk')])
|
|
|
|
unit_list = tables.Column(orderable=False, verbose_name='Units')
|
|
|
|
actions = tables.TemplateColumn(
|
2019-03-05 15:42:47 -06:00
|
|
|
template_code=RACKRESERVATION_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name=''
|
2017-04-06 16:26:48 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = RackReservation
|
2019-05-17 23:24:58 +02:00
|
|
|
fields = ('pk', 'site', 'rack', 'unit_list', 'user', 'created', 'tenant', 'description', 'actions')
|
2017-04-06 16:26:48 -04:00
|
|
|
|
|
|
|
|
2016-05-13 15:22:31 -04:00
|
|
|
#
|
|
|
|
# Manufacturers
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class ManufacturerTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-05-29 15:20:36 -04:00
|
|
|
name = tables.LinkColumn()
|
|
|
|
devicetype_count = tables.Column(
|
|
|
|
verbose_name='Device Types'
|
|
|
|
)
|
|
|
|
inventoryitem_count = tables.Column(
|
|
|
|
verbose_name='Inventory Items'
|
|
|
|
)
|
|
|
|
platform_count = tables.Column(
|
|
|
|
verbose_name='Platforms'
|
|
|
|
)
|
|
|
|
slug = tables.Column()
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=MANUFACTURER_ACTIONS,
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-05-13 15:22:31 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-05-13 15:22:31 -04:00
|
|
|
model = Manufacturer
|
2019-05-29 15:20:36 -04:00
|
|
|
fields = ('pk', 'name', 'devicetype_count', 'inventoryitem_count', 'platform_count', 'slug', 'actions')
|
2016-05-13 15:22:31 -04:00
|
|
|
|
|
|
|
|
2016-03-04 14:39:39 -05:00
|
|
|
#
|
|
|
|
# Device types
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class DeviceTypeTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-03-14 15:18:24 -04:00
|
|
|
model = tables.LinkColumn(
|
|
|
|
viewname='dcim:devicetype',
|
|
|
|
args=[Accessor('pk')],
|
|
|
|
verbose_name='Device Type'
|
|
|
|
)
|
2018-06-29 12:05:56 -04:00
|
|
|
is_full_depth = BooleanColumn(verbose_name='Full Depth')
|
2018-03-14 15:18:24 -04:00
|
|
|
instance_count = tables.TemplateColumn(
|
|
|
|
template_code=DEVICETYPE_INSTANCES_TEMPLATE,
|
|
|
|
verbose_name='Instances'
|
|
|
|
)
|
2016-03-04 14:39:39 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 14:39:39 -05:00
|
|
|
model = DeviceType
|
2017-03-29 16:05:23 -04:00
|
|
|
fields = (
|
2018-10-26 14:48:22 -04:00
|
|
|
'pk', 'model', 'manufacturer', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
|
|
|
|
'instance_count',
|
2017-03-29 16:05:23 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-03-04 23:09:32 -05:00
|
|
|
#
|
|
|
|
# Device type components
|
|
|
|
#
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class ConsolePortTemplateTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('consoleporttemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-04 23:09:32 -05:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 23:09:32 -05:00
|
|
|
model = ConsolePortTemplate
|
2019-10-30 14:25:55 -04:00
|
|
|
fields = ('pk', 'name', 'type', 'actions')
|
2016-03-04 23:09:32 -05:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class ConsolePortImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = ConsolePort
|
|
|
|
fields = ('device', 'name', 'description')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class ConsoleServerPortTemplateTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('consoleserverporttemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-04 23:09:32 -05:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 23:09:32 -05:00
|
|
|
model = ConsoleServerPortTemplate
|
2019-10-07 17:08:51 -04:00
|
|
|
fields = ('pk', 'name', 'actions')
|
2016-03-04 23:09:32 -05:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class ConsoleServerPortImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = ConsoleServerPort
|
|
|
|
fields = ('device', 'name', 'description')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class PowerPortTemplateTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('powerporttemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-04 23:09:32 -05:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 23:09:32 -05:00
|
|
|
model = PowerPortTemplate
|
2019-11-06 15:30:54 -05:00
|
|
|
fields = ('pk', 'name', 'type', 'maximum_draw', 'allocated_draw', 'actions')
|
2016-03-04 23:09:32 -05:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class PowerPortImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerPort
|
|
|
|
fields = ('device', 'name', 'description', 'maximum_draw', 'allocated_draw')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class PowerOutletTemplateTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('poweroutlettemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-04 23:09:32 -05:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 23:09:32 -05:00
|
|
|
model = PowerOutletTemplate
|
2019-11-06 15:30:54 -05:00
|
|
|
fields = ('pk', 'name', 'type', 'power_port', 'feed_leg', 'actions')
|
2016-03-04 23:09:32 -05:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class PowerOutletImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerOutlet
|
|
|
|
fields = ('device', 'name', 'description', 'power_port', 'feed_leg')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class InterfaceTemplateTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2017-06-16 17:13:33 -04:00
|
|
|
mgmt_only = tables.TemplateColumn("{% if value %}OOB Management{% endif %}")
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('interfacetemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-03-04 23:09:32 -05:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-04 23:09:32 -05:00
|
|
|
model = InterfaceTemplate
|
2019-10-07 17:08:51 -04:00
|
|
|
fields = ('pk', 'name', 'mgmt_only', 'type', 'actions')
|
2016-03-04 23:09:32 -05:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class InterfaceImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
virtual_machine = tables.LinkColumn('virtualization:virtualmachine', args=[Accessor('virtual_machine.pk')], verbose_name='Virtual Machine')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Interface
|
|
|
|
fields = ('device', 'virtual_machine', 'name', 'description', 'lag', 'type', 'enabled', 'mac_address', 'mtu', 'mgmt_only', 'mode')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2018-10-25 12:08:13 -04:00
|
|
|
class FrontPortTemplateTable(BaseTable):
|
2018-10-03 14:04:16 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
rear_port_position = tables.Column(
|
|
|
|
verbose_name='Position'
|
|
|
|
)
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('frontporttemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2018-10-03 14:04:16 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
2018-10-25 12:08:13 -04:00
|
|
|
model = FrontPortTemplate
|
2019-10-07 17:08:51 -04:00
|
|
|
fields = ('pk', 'name', 'type', 'rear_port', 'rear_port_position', 'actions')
|
2018-10-03 14:04:16 -04:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class FrontPortImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = FrontPort
|
|
|
|
fields = ('device', 'name', 'description', 'type', 'rear_port', 'rear_port_position')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2018-10-25 12:08:13 -04:00
|
|
|
class RearPortTemplateTable(BaseTable):
|
2018-10-03 14:04:16 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('rearporttemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2018-10-03 14:04:16 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
2018-10-25 12:08:13 -04:00
|
|
|
model = RearPortTemplate
|
2019-10-07 17:08:51 -04:00
|
|
|
fields = ('pk', 'name', 'type', 'positions', 'actions')
|
2018-10-03 14:04:16 -04:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class RearPortImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = RearPort
|
|
|
|
fields = ('device', 'name', 'description', 'type', 'position')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class DeviceBayTemplateTable(BaseTable):
|
2016-07-01 17:12:43 -04:00
|
|
|
pk = ToggleColumn()
|
2019-10-07 17:08:51 -04:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=get_component_template_actions('devicebaytemplate'),
|
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-07-01 17:12:43 -04:00
|
|
|
|
2016-07-26 10:54:11 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-07-01 17:12:43 -04:00
|
|
|
model = DeviceBayTemplate
|
2019-10-07 17:08:51 -04:00
|
|
|
fields = ('pk', 'name', 'actions')
|
2016-07-01 17:12:43 -04:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2016-05-12 14:38:34 -04:00
|
|
|
#
|
|
|
|
# Device roles
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class DeviceRoleTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-02-02 17:46:23 -05:00
|
|
|
device_count = tables.TemplateColumn(
|
|
|
|
template_code=DEVICEROLE_DEVICE_COUNT,
|
|
|
|
accessor=Accessor('devices.count'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Devices'
|
|
|
|
)
|
|
|
|
vm_count = tables.TemplateColumn(
|
|
|
|
template_code=DEVICEROLE_VM_COUNT,
|
|
|
|
accessor=Accessor('virtual_machines.count'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='VMs'
|
|
|
|
)
|
2017-09-29 11:50:26 -04:00
|
|
|
color = tables.TemplateColumn(COLOR_LABEL, verbose_name='Label')
|
2016-05-12 14:38:34 -04:00
|
|
|
slug = tables.Column(verbose_name='Slug')
|
2018-02-02 17:46:23 -05:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=DEVICEROLE_ACTIONS,
|
2019-03-05 15:42:47 -06:00
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
2018-02-02 17:46:23 -05:00
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-05-12 14:38:34 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-05-12 14:38:34 -04:00
|
|
|
model = DeviceRole
|
2019-12-10 12:53:28 -05:00
|
|
|
fields = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'actions')
|
2016-05-12 14:38:34 -04:00
|
|
|
|
|
|
|
|
2016-05-16 11:54:17 -04:00
|
|
|
#
|
|
|
|
# Platforms
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class PlatformTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-02-02 17:46:23 -05:00
|
|
|
device_count = tables.TemplateColumn(
|
|
|
|
template_code=PLATFORM_DEVICE_COUNT,
|
|
|
|
accessor=Accessor('devices.count'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Devices'
|
|
|
|
)
|
|
|
|
vm_count = tables.TemplateColumn(
|
|
|
|
template_code=PLATFORM_VM_COUNT,
|
|
|
|
accessor=Accessor('virtual_machines.count'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='VMs'
|
|
|
|
)
|
2017-12-19 16:15:26 -05:00
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=PLATFORM_ACTIONS,
|
2019-03-05 15:42:47 -06:00
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
2017-12-19 16:15:26 -05:00
|
|
|
verbose_name=''
|
|
|
|
)
|
2016-05-16 11:54:17 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-05-16 11:54:17 -04:00
|
|
|
model = Platform
|
2018-01-19 10:54:26 -05:00
|
|
|
fields = ('pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'actions')
|
2016-05-16 11:54:17 -04:00
|
|
|
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
#
|
|
|
|
# Devices
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class DeviceTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2018-06-11 15:10:31 -04:00
|
|
|
name = tables.TemplateColumn(
|
|
|
|
order_by=('_nat1', '_nat2', '_nat3'),
|
|
|
|
template_code=DEVICE_LINK
|
|
|
|
)
|
2018-01-25 13:07:04 -05:00
|
|
|
status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status')
|
2018-01-30 11:57:21 -05:00
|
|
|
tenant = tables.TemplateColumn(template_code=COL_TENANT)
|
2017-03-29 16:05:23 -04:00
|
|
|
site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')])
|
|
|
|
rack = tables.LinkColumn('dcim:rack', args=[Accessor('rack.pk')])
|
2016-08-10 22:20:09 -04:00
|
|
|
device_role = tables.TemplateColumn(DEVICE_ROLE, verbose_name='Role')
|
2017-03-29 16:05:23 -04:00
|
|
|
device_type = tables.LinkColumn(
|
|
|
|
'dcim:devicetype', args=[Accessor('device_type.pk')], verbose_name='Type',
|
2019-02-06 10:23:30 -05:00
|
|
|
text=lambda record: record.device_type.display_name
|
2017-03-29 16:05:23 -04:00
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Device
|
2017-07-12 16:42:45 -04:00
|
|
|
fields = ('pk', 'name', 'status', 'tenant', 'site', 'rack', 'device_role', 'device_type')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
2017-07-12 16:42:45 -04:00
|
|
|
class DeviceDetailTable(DeviceTable):
|
|
|
|
primary_ip = tables.TemplateColumn(
|
|
|
|
orderable=False, verbose_name='IP Address', template_code=DEVICE_PRIMARY_IP
|
2017-03-29 16:05:23 -04:00
|
|
|
)
|
|
|
|
|
2017-07-12 16:42:45 -04:00
|
|
|
class Meta(DeviceTable.Meta):
|
2017-03-29 16:05:23 -04:00
|
|
|
model = Device
|
2017-07-12 16:42:45 -04:00
|
|
|
fields = ('pk', 'name', 'status', 'tenant', 'site', 'rack', 'device_role', 'device_type', 'primary_ip')
|
2017-03-29 16:05:23 -04:00
|
|
|
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class DeviceImportTable(BaseTable):
|
2016-03-01 11:23:03 -05:00
|
|
|
name = tables.TemplateColumn(template_code=DEVICE_LINK, verbose_name='Name')
|
2018-01-25 13:07:04 -05:00
|
|
|
status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status')
|
2018-01-30 11:57:21 -05:00
|
|
|
tenant = tables.TemplateColumn(template_code=COL_TENANT)
|
2017-02-17 14:48:00 -05:00
|
|
|
site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')], verbose_name='Site')
|
2016-03-01 11:23:03 -05:00
|
|
|
rack = tables.LinkColumn('dcim:rack', args=[Accessor('rack.pk')], verbose_name='Rack')
|
|
|
|
position = tables.Column(verbose_name='Position')
|
|
|
|
device_role = tables.Column(verbose_name='Role')
|
|
|
|
device_type = tables.Column(verbose_name='Type')
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Device
|
2017-05-09 10:25:30 -04:00
|
|
|
fields = ('name', 'status', 'tenant', 'site', 'rack', 'position', 'device_role', 'device_type')
|
2016-06-20 16:34:19 -04:00
|
|
|
empty_text = False
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
#
|
|
|
|
# Device components
|
|
|
|
#
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class DeviceComponentDetailTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
cable = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
order_by = ('device', 'name')
|
|
|
|
fields = ('pk', 'device', 'name', 'type', 'description', 'cable')
|
|
|
|
sequence = ('pk', 'device', 'name', 'type', 'description', 'cable')
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class ConsolePortTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = ConsolePort
|
2019-10-30 14:25:55 -04:00
|
|
|
fields = ('name', 'type')
|
2017-07-13 16:31:47 -04:00
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class ConsolePortDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, ConsolePortTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class ConsoleServerPortTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = ConsoleServerPort
|
2019-05-02 13:56:30 -04:00
|
|
|
fields = ('name', 'description')
|
2017-07-13 16:31:47 -04:00
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class ConsoleServerPortDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, ConsoleServerPortTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class PowerPortTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerPort
|
2019-11-06 15:30:54 -05:00
|
|
|
fields = ('name', 'type')
|
2017-07-13 16:31:47 -04:00
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class PowerPortDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, PowerPortTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class PowerOutletTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerOutlet
|
2019-11-06 15:30:54 -05:00
|
|
|
fields = ('name', 'type', 'description')
|
2017-07-13 16:31:47 -04:00
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class PowerOutletDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, PowerOutletTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class InterfaceTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Interface
|
2019-04-12 13:42:56 -04:00
|
|
|
fields = ('name', 'type', 'lag', 'enabled', 'mgmt_only', 'description')
|
2017-07-13 16:31:47 -04:00
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class InterfaceDetailTable(DeviceComponentDetailTable):
|
|
|
|
parent = tables.LinkColumn(order_by=('device', 'virtual_machine'))
|
|
|
|
|
|
|
|
class Meta(InterfaceTable.Meta):
|
|
|
|
order_by = ('parent', 'name')
|
|
|
|
fields = ('pk', 'parent', 'name', 'type', 'description', 'cable')
|
|
|
|
sequence = ('pk', 'parent', 'name', 'type', 'description', 'cable')
|
|
|
|
|
|
|
|
|
2018-10-25 12:08:13 -04:00
|
|
|
class FrontPortTable(BaseTable):
|
2018-10-03 14:04:16 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
2018-10-25 12:08:13 -04:00
|
|
|
model = FrontPort
|
2018-11-20 21:28:19 -05:00
|
|
|
fields = ('name', 'type', 'rear_port', 'rear_port_position', 'description')
|
2018-10-03 14:04:16 -04:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class FrontPortDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, FrontPortTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-10-25 12:08:13 -04:00
|
|
|
class RearPortTable(BaseTable):
|
2018-10-03 14:04:16 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
2018-10-25 12:08:13 -04:00
|
|
|
model = RearPort
|
2018-11-20 21:28:19 -05:00
|
|
|
fields = ('name', 'type', 'positions', 'description')
|
2018-10-03 14:04:16 -04:00
|
|
|
empty_text = "None"
|
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class RearPortDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceComponentDetailTable.Meta, RearPortTable.Meta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-07-13 16:31:47 -04:00
|
|
|
class DeviceBayTable(BaseTable):
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = DeviceBay
|
|
|
|
fields = ('name',)
|
|
|
|
|
|
|
|
|
2019-12-05 16:10:49 -06:00
|
|
|
class DeviceBayDetailTable(DeviceComponentDetailTable):
|
|
|
|
device = tables.LinkColumn()
|
|
|
|
installed_device = tables.LinkColumn()
|
|
|
|
|
|
|
|
class Meta(DeviceBayTable.Meta):
|
|
|
|
fields = ('pk', 'name', 'device', 'installed_device')
|
|
|
|
sequence = ('pk', 'name', 'device', 'installed_device')
|
|
|
|
exclude = ('cable',)
|
|
|
|
|
|
|
|
|
2019-12-05 21:36:11 +01:00
|
|
|
class DeviceBayImportTable(BaseTable):
|
|
|
|
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
|
|
|
installed_device = tables.LinkColumn('dcim:device', args=[Accessor('installed_device.pk')], verbose_name='Installed Device')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = DeviceBay
|
|
|
|
fields = ('device', 'name', 'installed_device', 'description')
|
|
|
|
empty_text = False
|
|
|
|
|
|
|
|
|
2018-10-24 14:24:02 -04:00
|
|
|
#
|
|
|
|
# Cables
|
|
|
|
#
|
|
|
|
|
|
|
|
class CableTable(BaseTable):
|
2018-11-01 13:19:24 -04:00
|
|
|
pk = ToggleColumn()
|
|
|
|
id = tables.LinkColumn(
|
2018-10-25 15:51:12 -04:00
|
|
|
viewname='dcim:cable',
|
|
|
|
args=[Accessor('pk')],
|
2018-11-01 13:19:24 -04:00
|
|
|
verbose_name='ID'
|
2018-10-24 14:59:46 -04:00
|
|
|
)
|
2018-11-01 14:14:31 -04:00
|
|
|
termination_a_parent = tables.TemplateColumn(
|
|
|
|
template_code=CABLE_TERMINATION_PARENT,
|
|
|
|
accessor=Accessor('termination_a'),
|
2018-10-24 14:59:46 -04:00
|
|
|
orderable=False,
|
2018-11-01 14:14:31 -04:00
|
|
|
verbose_name='Termination A'
|
2018-10-24 14:24:02 -04:00
|
|
|
)
|
2019-11-26 16:56:11 -05:00
|
|
|
termination_a = tables.LinkColumn(
|
2018-11-01 14:14:31 -04:00
|
|
|
accessor=Accessor('termination_a'),
|
2018-10-24 14:59:46 -04:00
|
|
|
orderable=False,
|
2018-11-01 14:14:31 -04:00
|
|
|
verbose_name=''
|
2018-10-24 14:24:02 -04:00
|
|
|
)
|
2018-11-01 14:14:31 -04:00
|
|
|
termination_b_parent = tables.TemplateColumn(
|
|
|
|
template_code=CABLE_TERMINATION_PARENT,
|
|
|
|
accessor=Accessor('termination_b'),
|
2018-10-24 14:59:46 -04:00
|
|
|
orderable=False,
|
2018-11-01 14:14:31 -04:00
|
|
|
verbose_name='Termination B'
|
2018-10-24 14:24:02 -04:00
|
|
|
)
|
2019-11-26 16:56:11 -05:00
|
|
|
termination_b = tables.LinkColumn(
|
2018-11-01 14:14:31 -04:00
|
|
|
accessor=Accessor('termination_b'),
|
2018-10-24 14:59:46 -04:00
|
|
|
orderable=False,
|
2018-11-01 14:14:31 -04:00
|
|
|
verbose_name=''
|
2018-10-24 14:24:02 -04:00
|
|
|
)
|
2019-02-20 11:36:55 -05:00
|
|
|
status = tables.TemplateColumn(
|
|
|
|
template_code=STATUS_LABEL
|
|
|
|
)
|
2018-10-26 10:28:25 -04:00
|
|
|
length = tables.TemplateColumn(
|
|
|
|
template_code=CABLE_LENGTH,
|
|
|
|
order_by='_abs_length'
|
|
|
|
)
|
2018-10-26 13:14:12 -04:00
|
|
|
color = ColorColumn()
|
2018-10-24 14:24:02 -04:00
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Cable
|
2018-11-01 13:19:24 -04:00
|
|
|
fields = (
|
2018-11-02 14:27:17 -04:00
|
|
|
'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b',
|
2018-11-01 14:14:31 -04:00
|
|
|
'status', 'type', 'color', 'length',
|
2018-11-01 13:19:24 -04:00
|
|
|
)
|
2018-10-24 14:24:02 -04:00
|
|
|
|
|
|
|
|
2016-03-01 11:23:03 -05:00
|
|
|
#
|
|
|
|
# Device connections
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class ConsoleConnectionTable(BaseTable):
|
2018-10-24 10:37:54 -04:00
|
|
|
console_server = tables.LinkColumn(
|
2018-11-01 10:51:38 -04:00
|
|
|
viewname='dcim:device',
|
2018-10-24 10:37:54 -04:00
|
|
|
accessor=Accessor('connected_endpoint.device'),
|
|
|
|
args=[Accessor('connected_endpoint.device.pk')],
|
2018-11-08 09:51:13 -05:00
|
|
|
verbose_name='Console Server'
|
2018-10-24 10:37:54 -04:00
|
|
|
)
|
2018-11-08 09:51:13 -05:00
|
|
|
connected_endpoint = tables.Column(
|
|
|
|
verbose_name='Port'
|
|
|
|
)
|
|
|
|
device = tables.LinkColumn(
|
|
|
|
viewname='dcim:device',
|
|
|
|
args=[Accessor('device.pk')]
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
verbose_name='Console Port'
|
2018-11-01 10:51:38 -04:00
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2018-12-05 16:53:58 -05:00
|
|
|
model = ConsolePort
|
2018-11-08 09:51:13 -05:00
|
|
|
fields = ('console_server', 'connected_endpoint', 'device', 'name', 'connection_status')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class PowerConnectionTable(BaseTable):
|
2018-10-24 11:00:13 -04:00
|
|
|
pdu = tables.LinkColumn(
|
2018-11-01 10:51:38 -04:00
|
|
|
viewname='dcim:device',
|
2018-10-24 11:00:13 -04:00
|
|
|
accessor=Accessor('connected_endpoint.device'),
|
|
|
|
args=[Accessor('connected_endpoint.device.pk')],
|
2019-08-19 11:27:36 -04:00
|
|
|
order_by='_connected_poweroutlet__device',
|
2018-10-24 11:00:13 -04:00
|
|
|
verbose_name='PDU'
|
|
|
|
)
|
2019-04-25 15:06:48 -04:00
|
|
|
outlet = tables.Column(
|
|
|
|
accessor=Accessor('_connected_poweroutlet'),
|
2018-11-08 09:51:13 -05:00
|
|
|
verbose_name='Outlet'
|
|
|
|
)
|
|
|
|
device = tables.LinkColumn(
|
|
|
|
viewname='dcim:device',
|
|
|
|
args=[Accessor('device.pk')]
|
|
|
|
)
|
|
|
|
name = tables.Column(
|
|
|
|
verbose_name='Power Port'
|
2018-11-01 10:51:38 -04:00
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2018-12-05 16:53:58 -05:00
|
|
|
model = PowerPort
|
2019-04-25 15:06:48 -04:00
|
|
|
fields = ('pdu', 'outlet', 'device', 'name', 'connection_status')
|
2016-03-01 11:23:03 -05:00
|
|
|
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class InterfaceConnectionTable(BaseTable):
|
2018-10-24 13:59:44 -04:00
|
|
|
device_a = tables.LinkColumn(
|
|
|
|
viewname='dcim:device',
|
|
|
|
accessor=Accessor('device'),
|
|
|
|
args=[Accessor('device.pk')],
|
|
|
|
verbose_name='Device A'
|
|
|
|
)
|
|
|
|
interface_a = tables.LinkColumn(
|
|
|
|
viewname='dcim:interface',
|
|
|
|
accessor=Accessor('name'),
|
|
|
|
args=[Accessor('pk')],
|
|
|
|
verbose_name='Interface A'
|
|
|
|
)
|
2018-11-05 14:41:51 -05:00
|
|
|
description_a = tables.Column(
|
|
|
|
accessor=Accessor('description'),
|
|
|
|
verbose_name='Description'
|
|
|
|
)
|
2018-10-24 13:59:44 -04:00
|
|
|
device_b = tables.LinkColumn(
|
|
|
|
viewname='dcim:device',
|
2019-04-26 16:41:01 -04:00
|
|
|
accessor=Accessor('_connected_interface.device'),
|
|
|
|
args=[Accessor('_connected_interface.device.pk')],
|
2018-10-24 13:59:44 -04:00
|
|
|
verbose_name='Device B'
|
|
|
|
)
|
|
|
|
interface_b = tables.LinkColumn(
|
|
|
|
viewname='dcim:interface',
|
2019-04-26 16:41:01 -04:00
|
|
|
accessor=Accessor('_connected_interface'),
|
|
|
|
args=[Accessor('_connected_interface.pk')],
|
2018-10-24 13:59:44 -04:00
|
|
|
verbose_name='Interface B'
|
|
|
|
)
|
2018-11-05 14:41:51 -05:00
|
|
|
description_b = tables.Column(
|
2019-04-26 16:41:01 -04:00
|
|
|
accessor=Accessor('_connected_interface.description'),
|
2018-11-05 14:41:51 -05:00
|
|
|
verbose_name='Description'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2018-12-05 16:53:58 -05:00
|
|
|
model = Interface
|
2018-11-08 09:51:13 -05:00
|
|
|
fields = (
|
|
|
|
'device_a', 'interface_a', 'description_a', 'device_b', 'interface_b', 'description_b', 'connection_status',
|
|
|
|
)
|
2017-11-17 16:47:26 -05:00
|
|
|
|
|
|
|
|
2018-01-30 17:46:00 -05:00
|
|
|
#
|
|
|
|
# InventoryItems
|
|
|
|
#
|
|
|
|
|
|
|
|
class InventoryItemTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
device = tables.LinkColumn('dcim:device_inventory', args=[Accessor('device.pk')])
|
|
|
|
manufacturer = tables.Column(accessor=Accessor('manufacturer.name'), verbose_name='Manufacturer')
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = InventoryItem
|
|
|
|
fields = ('pk', 'device', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description')
|
2018-01-31 11:13:17 -05:00
|
|
|
|
|
|
|
|
2017-11-17 16:47:26 -05:00
|
|
|
#
|
|
|
|
# Virtual chassis
|
|
|
|
#
|
|
|
|
|
|
|
|
class VirtualChassisTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
master = tables.LinkColumn()
|
|
|
|
member_count = tables.Column(verbose_name='Members')
|
|
|
|
actions = tables.TemplateColumn(
|
|
|
|
template_code=VIRTUALCHASSIS_ACTIONS,
|
2019-03-05 15:42:47 -06:00
|
|
|
attrs={'td': {'class': 'text-right noprint'}},
|
2017-11-17 16:47:26 -05:00
|
|
|
verbose_name=''
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = VirtualChassis
|
|
|
|
fields = ('pk', 'master', 'domain', 'member_count', 'actions')
|
2019-03-11 22:40:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Power panels
|
|
|
|
#
|
|
|
|
|
|
|
|
class PowerPanelTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
name = tables.LinkColumn()
|
2019-04-02 13:37:53 -04:00
|
|
|
site = tables.LinkColumn(
|
|
|
|
viewname='dcim:site',
|
|
|
|
args=[Accessor('site.slug')]
|
|
|
|
)
|
2019-04-19 13:32:46 -04:00
|
|
|
powerfeed_count = tables.TemplateColumn(
|
|
|
|
template_code=POWERPANEL_POWERFEED_COUNT,
|
2019-03-11 22:40:52 -04:00
|
|
|
verbose_name='Feeds'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerPanel
|
2019-03-12 11:36:29 -04:00
|
|
|
fields = ('pk', 'name', 'site', 'rack_group', 'powerfeed_count')
|
2019-03-11 22:40:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Power feeds
|
|
|
|
#
|
|
|
|
|
|
|
|
class PowerFeedTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
name = tables.LinkColumn()
|
2019-03-12 11:36:29 -04:00
|
|
|
power_panel = tables.LinkColumn(
|
2019-03-11 22:40:52 -04:00
|
|
|
viewname='dcim:powerpanel',
|
2019-04-02 14:49:40 -04:00
|
|
|
args=[Accessor('power_panel.pk')],
|
2019-03-22 21:58:45 -04:00
|
|
|
)
|
|
|
|
rack = tables.LinkColumn(
|
|
|
|
viewname='dcim:rack',
|
2019-04-02 14:49:40 -04:00
|
|
|
args=[Accessor('rack.pk')]
|
2019-03-11 22:40:52 -04:00
|
|
|
)
|
2019-03-12 11:36:29 -04:00
|
|
|
status = tables.TemplateColumn(
|
|
|
|
template_code=STATUS_LABEL
|
|
|
|
)
|
|
|
|
type = tables.TemplateColumn(
|
|
|
|
template_code=TYPE_LABEL
|
2019-03-11 22:40:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = PowerFeed
|
2019-03-12 11:36:29 -04:00
|
|
|
fields = ('pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase')
|