class RearPortTable(DeviceComponentTable, CableTerminationTable): device = tables.Column(linkify={ 'viewname': 'dcim:device_rearports', 'args': [Accessor('device_id')], }) color = ColorColumn() tags = TagColumn(url_name='dcim:rearport_list') class Meta(DeviceComponentTable.Meta): model = RearPort fields = ( 'pk', 'name', 'device', 'label', 'type', 'color', 'positions', 'description', 'mark_connected', 'cable', 'cable_color', 'cable_peer', 'tags', ) default_columns = ('pk', 'name', 'device', 'label', 'type', 'color', 'description')
class FrontPortTable(DeviceComponentTable, CableTerminationTable): device = tables.Column( linkify={ 'viewname': 'dcim:device_frontports', 'args': [Accessor('device_id')], } ) color = ColorColumn() rear_port_position = tables.Column( verbose_name='Position' ) rear_port = tables.Column( linkify=True ) tags = TagColumn( url_name='dcim:frontport_list' ) class Meta(DeviceComponentTable.Meta): model = FrontPort fields = ( 'pk', 'id', 'name', 'device', 'label', 'type', 'color', 'rear_port', 'rear_port_position', 'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'created', 'last_updated', ) default_columns = ( 'pk', 'name', 'device', 'label', 'type', 'color', 'rear_port', 'rear_port_position', 'description', )
class DeviceRoleTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) device_count = LinkedCountColumn(viewname='dcim:device_list', url_params={'role_id': 'pk'}, verbose_name='Devices') vm_count = LinkedCountColumn(viewname='virtualization:virtualmachine_list', url_params={'role_id': 'pk'}, verbose_name='VMs') color = ColorColumn() vm_role = BooleanColumn() tags = TagColumn(url_name='dcim:devicerole_list') actions = ButtonsColumn(DeviceRole) class Meta(BaseTable.Meta): model = DeviceRole fields = ( 'pk', 'id', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'tags', 'actions', 'created', 'last_updated', ) default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'actions')
class TagTable(BaseTable): pk = ToggleColumn() color = ColorColumn() actions = ButtonsColumn(Tag, pk_field='slug') class Meta(BaseTable.Meta): model = Tag fields = ('pk', 'name', 'items', 'slug', 'color', 'description', 'actions')
class CableTable(BaseTable): pk = ToggleColumn() termination_a_parent = tables.TemplateColumn( template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_a'), orderable=False, verbose_name='Side A') termination_a = tables.Column(accessor=Accessor('termination_a'), orderable=False, linkify=True, verbose_name='Termination A') termination_b_parent = tables.TemplateColumn( template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_b'), orderable=False, verbose_name='Side B') termination_b = tables.Column(accessor=Accessor('termination_b'), orderable=False, linkify=True, verbose_name='Termination B') status = ChoiceFieldColumn() tenant = TenantColumn() length = TemplateColumn(template_code=CABLE_LENGTH, order_by=('_abs_length', 'length_unit')) color = ColorColumn() tags = TagColumn(url_name='dcim:cable_list') class Meta(BaseTable.Meta): model = Cable fields = ( 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', 'status', 'type', 'tenant', 'color', 'length', 'tags', 'created', 'last_updated', ) default_columns = ( 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', 'status', 'type', )
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, orderable=False, verbose_name='Cable Peer')
class RearPortTemplateTable(ComponentTemplateTable): color = ColorColumn() actions = ButtonsColumn(model=RearPortTemplate, buttons=('edit', 'delete')) class Meta(ComponentTemplateTable.Meta): model = RearPortTemplate fields = ('pk', 'name', 'label', 'type', 'color', 'positions', 'description', 'actions') empty_text = "None"
class CableTerminationTable(BaseTable): cable = tables.Column(linkify=True) cable_color = ColorColumn(accessor='cable.color', orderable=False, verbose_name='Cable Color') link_peer = TemplateColumn(accessor='_link_peer', template_code=LINKTERMINATION, orderable=False, verbose_name='Link Peer') mark_connected = BooleanColumn()
class TagTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) color = ColorColumn() actions = ButtonsColumn(Tag) class Meta(BaseTable.Meta): model = Tag fields = ('pk', 'name', 'items', 'slug', 'color', 'description', 'actions')
class RackRoleTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) rack_count = tables.Column(verbose_name='Racks') color = ColorColumn() actions = ButtonsColumn(RackRole) class Meta(BaseTable.Meta): model = RackRole fields = ('pk', 'id', 'name', 'rack_count', 'color', 'description', 'slug', 'actions') default_columns = ('pk', 'name', 'rack_count', 'color', 'description', 'actions')
class FrontPortTemplateTable(ComponentTemplateTable): rear_port_position = tables.Column(verbose_name='Position') color = ColorColumn() actions = ButtonsColumn(model=FrontPortTemplate, buttons=('edit', 'delete')) class Meta(ComponentTemplateTable.Meta): model = FrontPortTemplate fields = ('pk', 'name', 'label', 'type', 'color', 'rear_port', 'rear_port_position', 'description', 'actions') empty_text = "None"
class CableTable(BaseTable): pk = ToggleColumn() id = tables.LinkColumn(viewname='dcim:cable', args=[Accessor('pk')], verbose_name='ID') termination_a_parent = tables.TemplateColumn( template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_a'), orderable=False, verbose_name='Side A') termination_a = tables.LinkColumn(accessor=Accessor('termination_a'), orderable=False, verbose_name='Termination A') termination_b_parent = tables.TemplateColumn( template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_b'), orderable=False, verbose_name='Side B') termination_b = tables.LinkColumn(accessor=Accessor('termination_b'), orderable=False, verbose_name='Termination B') status = tables.TemplateColumn(template_code=STATUS_LABEL) length = tables.TemplateColumn(template_code=CABLE_LENGTH, order_by='_abs_length') color = ColorColumn() class Meta(BaseTable.Meta): model = Cable fields = ( 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', 'status', 'type', 'color', 'length', ) default_columns = ( 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', 'status', 'type', )
class TagTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn(viewname='extras:tag', args=[Accessor('slug')]) actions = tables.TemplateColumn( template_code=TAG_ACTIONS, attrs={'td': { 'class': 'text-right noprint' }}, verbose_name='') color = ColorColumn() class Meta(BaseTable.Meta): model = Tag fields = ('pk', 'name', 'items', 'slug', 'color', 'actions')
class RackRoleTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) rack_count = tables.Column(verbose_name='Racks') color = ColorColumn() tags = TagColumn( url_name='dcim:rackrole_list' ) actions = ButtonsColumn(RackRole) class Meta(BaseTable.Meta): model = RackRole fields = ( 'pk', 'id', 'name', 'rack_count', 'color', 'description', 'slug', 'tags', 'actions', 'created', 'last_updated', ) default_columns = ('pk', 'name', 'rack_count', 'color', 'description', 'actions')
class DeviceRoleTable(BaseTable): pk = ToggleColumn() device_count = LinkedCountColumn(viewname='dcim:device_list', url_params={'role': 'slug'}, verbose_name='Devices') vm_count = LinkedCountColumn(viewname='virtualization:virtualmachine_list', url_params={'role': 'slug'}, verbose_name='VMs') color = ColorColumn() vm_role = BooleanColumn() actions = ButtonsColumn(DeviceRole, pk_field='slug') class Meta(BaseTable.Meta): model = DeviceRole fields = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'actions') default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'actions')
class CableTable(BaseTable): # django-tables2 adds CSS `class="label"` which causes rendering issues pk = tables.LinkColumn( viewname='dcim:cable', args=[Accessor('pk')], verbose_name='PK' ) label_ = tables.Column( accessor=Accessor('label'), verbose_name='Label' ) device_a = tables.LinkColumn( viewname='dcim:device', accessor=Accessor('termination_a.device'), args=[Accessor('termination_a.device.pk')], orderable=False, verbose_name='Device A' ) termination_a = tables.Column( accessor=Accessor('termination_a.name'), orderable=False, verbose_name='Component' ) device_b = tables.LinkColumn( viewname='dcim:device', accessor=Accessor('termination_b.device'), args=[Accessor('termination_b.device.pk')], orderable=False, verbose_name='Device B' ) termination_b = tables.Column( accessor=Accessor('termination_b.name'), orderable=False, verbose_name='Component' ) length = tables.TemplateColumn( template_code=CABLE_LENGTH, order_by='_abs_length' ) color = ColorColumn() class Meta(BaseTable.Meta): model = Cable fields = ('pk', 'label_', 'device_a', 'termination_a', 'device_b', 'termination_b', 'status', 'type', 'color')