|
|
@@ -44,20 +44,31 @@ __all__ = (
|
|
|
)
|
|
|
|
|
|
|
|
|
+def get_cabletermination_row_class(record):
|
|
|
+ if record.mark_connected:
|
|
|
+ return 'success'
|
|
|
+ elif record.cable:
|
|
|
+ return record.cable.get_status_class()
|
|
|
+ return ''
|
|
|
+
|
|
|
+
|
|
|
#
|
|
|
# Device roles
|
|
|
#
|
|
|
|
|
|
class DeviceRoleTable(BaseTable):
|
|
|
pk = ToggleColumn()
|
|
|
+ name = tables.Column(
|
|
|
+ linkify=True
|
|
|
+ )
|
|
|
device_count = LinkedCountColumn(
|
|
|
viewname='dcim:device_list',
|
|
|
- url_params={'role': 'slug'},
|
|
|
+ url_params={'role_id': 'pk'},
|
|
|
verbose_name='Devices'
|
|
|
)
|
|
|
vm_count = LinkedCountColumn(
|
|
|
viewname='virtualization:virtualmachine_list',
|
|
|
- url_params={'role': 'slug'},
|
|
|
+ url_params={'role_id': 'pk'},
|
|
|
verbose_name='VMs'
|
|
|
)
|
|
|
color = ColorColumn()
|
|
|
@@ -76,14 +87,17 @@ class DeviceRoleTable(BaseTable):
|
|
|
|
|
|
class PlatformTable(BaseTable):
|
|
|
pk = ToggleColumn()
|
|
|
+ name = tables.Column(
|
|
|
+ linkify=True
|
|
|
+ )
|
|
|
device_count = LinkedCountColumn(
|
|
|
viewname='dcim:device_list',
|
|
|
- url_params={'platform': 'slug'},
|
|
|
+ url_params={'platform_id': 'pk'},
|
|
|
verbose_name='Devices'
|
|
|
)
|
|
|
vm_count = LinkedCountColumn(
|
|
|
viewname='virtualization:virtualmachine_list',
|
|
|
- url_params={'platform': 'slug'},
|
|
|
+ url_params={'platform_id': 'pk'},
|
|
|
verbose_name='VMs'
|
|
|
)
|
|
|
actions = ButtonsColumn(Platform)
|
|
|
@@ -123,11 +137,13 @@ class DeviceTable(BaseTable):
|
|
|
device_role = ColoredLabelColumn(
|
|
|
verbose_name='Role'
|
|
|
)
|
|
|
- device_type = tables.LinkColumn(
|
|
|
- viewname='dcim:devicetype',
|
|
|
- args=[Accessor('device_type__pk')],
|
|
|
- verbose_name='Type',
|
|
|
- text=lambda record: record.device_type.display_name
|
|
|
+ manufacturer = tables.Column(
|
|
|
+ accessor=Accessor('device_type__manufacturer'),
|
|
|
+ linkify=True
|
|
|
+ )
|
|
|
+ device_type = tables.Column(
|
|
|
+ linkify=True,
|
|
|
+ verbose_name='Type'
|
|
|
)
|
|
|
if settings.PREFER_IPV4:
|
|
|
primary_ip = tables.Column(
|
|
|
@@ -149,13 +165,11 @@ class DeviceTable(BaseTable):
|
|
|
linkify=True,
|
|
|
verbose_name='IPv6 Address'
|
|
|
)
|
|
|
- cluster = tables.LinkColumn(
|
|
|
- viewname='virtualization:cluster',
|
|
|
- args=[Accessor('cluster__pk')]
|
|
|
+ cluster = tables.Column(
|
|
|
+ linkify=True
|
|
|
)
|
|
|
- virtual_chassis = tables.LinkColumn(
|
|
|
- viewname='dcim:virtualchassis',
|
|
|
- args=[Accessor('virtual_chassis__pk')]
|
|
|
+ virtual_chassis = tables.Column(
|
|
|
+ linkify=True
|
|
|
)
|
|
|
vc_position = tables.Column(
|
|
|
verbose_name='VC Position'
|
|
|
@@ -170,12 +184,13 @@ class DeviceTable(BaseTable):
|
|
|
class Meta(BaseTable.Meta):
|
|
|
model = Device
|
|
|
fields = (
|
|
|
- 'pk', 'name', 'status', 'tenant', 'device_role', 'device_type', 'platform', 'serial', 'asset_tag', 'site',
|
|
|
- 'location', 'rack', 'position', 'face', 'primary_ip', 'primary_ip4', 'primary_ip6', 'cluster',
|
|
|
- 'virtual_chassis', 'vc_position', 'vc_priority', 'tags',
|
|
|
+ 'pk', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
|
|
|
+ 'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'primary_ip4', 'primary_ip6',
|
|
|
+ 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'tags',
|
|
|
)
|
|
|
default_columns = (
|
|
|
- 'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'device_type', 'primary_ip',
|
|
|
+ 'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type',
|
|
|
+ 'primary_ip',
|
|
|
)
|
|
|
|
|
|
|
|
|
@@ -230,6 +245,11 @@ class CableTerminationTable(BaseTable):
|
|
|
cable = tables.Column(
|
|
|
linkify=True
|
|
|
)
|
|
|
+ cable_color = ColorColumn(
|
|
|
+ accessor='cable.color',
|
|
|
+ orderable=False,
|
|
|
+ verbose_name='Cable Color'
|
|
|
+ )
|
|
|
cable_peer = tables.TemplateColumn(
|
|
|
accessor='_cable_peer',
|
|
|
template_code=CABLETERMINATION,
|
|
|
@@ -241,7 +261,7 @@ class CableTerminationTable(BaseTable):
|
|
|
|
|
|
class PathEndpointTable(CableTerminationTable):
|
|
|
connection = tables.TemplateColumn(
|
|
|
- accessor='_path.destination',
|
|
|
+ accessor='_path.last_node',
|
|
|
template_code=CABLETERMINATION,
|
|
|
verbose_name='Connection',
|
|
|
orderable=False
|
|
|
@@ -249,6 +269,12 @@ class PathEndpointTable(CableTerminationTable):
|
|
|
|
|
|
|
|
|
class ConsolePortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_consoleports',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
tags = TagColumn(
|
|
|
url_name='dcim:consoleport_list'
|
|
|
)
|
|
|
@@ -256,8 +282,8 @@ class ConsolePortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
model = ConsolePort
|
|
|
fields = (
|
|
|
- 'pk', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_peer',
|
|
|
- 'connection', 'tags',
|
|
|
+ 'pk', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
|
|
+ 'cable_peer', 'connection', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'speed', 'description')
|
|
|
|
|
|
@@ -276,16 +302,22 @@ class DeviceConsolePortTable(ConsolePortTable):
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
model = ConsolePort
|
|
|
fields = (
|
|
|
- 'pk', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_peer',
|
|
|
- 'connection', 'tags', 'actions'
|
|
|
+ 'pk', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
|
|
+ 'cable_peer', 'connection', 'tags', 'actions'
|
|
|
)
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
class ConsoleServerPortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_consoleserverports',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
tags = TagColumn(
|
|
|
url_name='dcim:consoleserverport_list'
|
|
|
)
|
|
|
@@ -293,8 +325,8 @@ class ConsoleServerPortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
model = ConsoleServerPort
|
|
|
fields = (
|
|
|
- 'pk', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_peer',
|
|
|
- 'connection', 'tags',
|
|
|
+ 'pk', 'device', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
|
|
+ 'cable_peer', 'connection', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'speed', 'description')
|
|
|
|
|
|
@@ -314,16 +346,22 @@ class DeviceConsoleServerPortTable(ConsoleServerPortTable):
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
model = ConsoleServerPort
|
|
|
fields = (
|
|
|
- 'pk', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_peer',
|
|
|
- 'connection', 'tags', 'actions',
|
|
|
+ 'pk', 'name', 'label', 'type', 'speed', 'description', 'mark_connected', 'cable', 'cable_color',
|
|
|
+ 'cable_peer', 'connection', 'tags', 'actions',
|
|
|
)
|
|
|
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
class PowerPortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_powerports',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
tags = TagColumn(
|
|
|
url_name='dcim:powerport_list'
|
|
|
)
|
|
|
@@ -332,7 +370,7 @@ class PowerPortTable(DeviceComponentTable, PathEndpointTable):
|
|
|
model = PowerPort
|
|
|
fields = (
|
|
|
'pk', 'device', 'name', 'label', 'type', 'description', 'mark_connected', 'maximum_draw', 'allocated_draw',
|
|
|
- 'cable', 'cable_peer', 'connection', 'tags',
|
|
|
+ 'cable', 'cable_color', 'cable_peer', 'connection', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description')
|
|
|
|
|
|
@@ -353,18 +391,24 @@ class DevicePowerPortTable(PowerPortTable):
|
|
|
model = PowerPort
|
|
|
fields = (
|
|
|
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'mark_connected', 'cable',
|
|
|
- 'cable_peer', 'connection', 'tags', 'actions',
|
|
|
+ 'cable_color', 'cable_peer', 'connection', 'tags', 'actions',
|
|
|
)
|
|
|
default_columns = (
|
|
|
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'cable', 'connection',
|
|
|
'actions',
|
|
|
)
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
class PowerOutletTable(DeviceComponentTable, PathEndpointTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_poweroutlets',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
power_port = tables.Column(
|
|
|
linkify=True
|
|
|
)
|
|
|
@@ -376,7 +420,7 @@ class PowerOutletTable(DeviceComponentTable, PathEndpointTable):
|
|
|
model = PowerOutlet
|
|
|
fields = (
|
|
|
'pk', 'device', 'name', 'label', 'type', 'description', 'power_port', 'feed_leg', 'mark_connected', 'cable',
|
|
|
- 'cable_peer', 'connection', 'tags',
|
|
|
+ 'cable_color', 'cable_peer', 'connection', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description')
|
|
|
|
|
|
@@ -396,13 +440,13 @@ class DevicePowerOutletTable(PowerOutletTable):
|
|
|
model = PowerOutlet
|
|
|
fields = (
|
|
|
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'mark_connected', 'cable',
|
|
|
- 'cable_peer', 'connection', 'tags', 'actions',
|
|
|
+ 'cable_color', 'cable_peer', 'connection', 'tags', 'actions',
|
|
|
)
|
|
|
default_columns = (
|
|
|
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection', 'actions',
|
|
|
)
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -422,6 +466,12 @@ class BaseInterfaceTable(BaseTable):
|
|
|
|
|
|
|
|
|
class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_interfaces',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
mgmt_only = BooleanColumn()
|
|
|
tags = TagColumn(
|
|
|
url_name='dcim:interface_list'
|
|
|
@@ -431,7 +481,7 @@ class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable
|
|
|
model = Interface
|
|
|
fields = (
|
|
|
'pk', 'device', 'name', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'mode', 'mac_address',
|
|
|
- 'description', 'mark_connected', 'cable', 'cable_peer', 'connection', 'tags', 'ip_addresses',
|
|
|
+ 'description', 'mark_connected', 'cable', 'cable_color', 'cable_peer', 'connection', 'tags', 'ip_addresses',
|
|
|
'untagged_vlan', 'tagged_vlans',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'enabled', 'type', 'description')
|
|
|
@@ -462,7 +512,7 @@ class DeviceInterfaceTable(InterfaceTable):
|
|
|
model = Interface
|
|
|
fields = (
|
|
|
'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mgmt_only', 'mtu', 'mode', 'mac_address',
|
|
|
- 'description', 'mark_connected', 'cable', 'cable_peer', 'connection', 'tags', 'ip_addresses',
|
|
|
+ 'description', 'mark_connected', 'cable', 'cable_color', 'cable_peer', 'connection', 'tags', 'ip_addresses',
|
|
|
'untagged_vlan', 'tagged_vlans', 'actions',
|
|
|
)
|
|
|
default_columns = (
|
|
|
@@ -470,12 +520,18 @@ class DeviceInterfaceTable(InterfaceTable):
|
|
|
'cable', 'connection', 'actions',
|
|
|
)
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else '',
|
|
|
+ 'class': get_cabletermination_row_class,
|
|
|
'data-name': lambda record: record.name,
|
|
|
}
|
|
|
|
|
|
|
|
|
class FrontPortTable(DeviceComponentTable, CableTerminationTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_frontports',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
rear_port_position = tables.Column(
|
|
|
verbose_name='Position'
|
|
|
)
|
|
|
@@ -490,7 +546,7 @@ class FrontPortTable(DeviceComponentTable, CableTerminationTable):
|
|
|
model = FrontPort
|
|
|
fields = (
|
|
|
'pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'mark_connected',
|
|
|
- 'cable', 'cable_peer', 'tags',
|
|
|
+ 'cable', 'cable_color', 'cable_peer', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description')
|
|
|
|
|
|
@@ -511,18 +567,24 @@ class DeviceFrontPortTable(FrontPortTable):
|
|
|
model = FrontPort
|
|
|
fields = (
|
|
|
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'mark_connected', 'cable',
|
|
|
- 'cable_peer', 'tags', 'actions',
|
|
|
+ 'cable_color', 'cable_peer', 'tags', 'actions',
|
|
|
)
|
|
|
default_columns = (
|
|
|
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'cable_peer',
|
|
|
'actions',
|
|
|
)
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
class RearPortTable(DeviceComponentTable, CableTerminationTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_rearports',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
tags = TagColumn(
|
|
|
url_name='dcim:rearport_list'
|
|
|
)
|
|
|
@@ -531,7 +593,7 @@ class RearPortTable(DeviceComponentTable, CableTerminationTable):
|
|
|
model = RearPort
|
|
|
fields = (
|
|
|
'pk', 'device', 'name', 'label', 'type', 'positions', 'description', 'mark_connected', 'cable',
|
|
|
- 'cable_peer', 'tags',
|
|
|
+ 'cable_color', 'cable_peer', 'tags',
|
|
|
)
|
|
|
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
|
|
|
|
|
|
@@ -551,18 +613,24 @@ class DeviceRearPortTable(RearPortTable):
|
|
|
class Meta(DeviceComponentTable.Meta):
|
|
|
model = RearPort
|
|
|
fields = (
|
|
|
- 'pk', 'name', 'label', 'type', 'positions', 'description', 'mark_connected', 'cable', 'cable_peer', 'tags',
|
|
|
- 'actions',
|
|
|
+ 'pk', 'name', 'label', 'type', 'positions', 'description', 'mark_connected', 'cable', 'cable_color',
|
|
|
+ 'cable_peer', 'tags', 'actions',
|
|
|
)
|
|
|
default_columns = (
|
|
|
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'cable_peer', 'actions',
|
|
|
)
|
|
|
row_attrs = {
|
|
|
- 'class': lambda record: record.cable.get_status_class() if record.cable else ''
|
|
|
+ 'class': get_cabletermination_row_class
|
|
|
}
|
|
|
|
|
|
|
|
|
class DeviceBayTable(DeviceComponentTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_devicebays',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
status = tables.TemplateColumn(
|
|
|
template_code=DEVICEBAY_STATUS
|
|
|
)
|
|
|
@@ -602,6 +670,12 @@ class DeviceDeviceBayTable(DeviceBayTable):
|
|
|
|
|
|
|
|
|
class InventoryItemTable(DeviceComponentTable):
|
|
|
+ device = tables.Column(
|
|
|
+ linkify={
|
|
|
+ 'viewname': 'dcim:device_inventory',
|
|
|
+ 'args': [Accessor('device_id')],
|
|
|
+ }
|
|
|
+ )
|
|
|
manufacturer = tables.Column(
|
|
|
linkify=True
|
|
|
)
|