class DeviceDeviceBayTable(DeviceBayTable): name = tables.TemplateColumn( template_code= '<i class="mdi mdi-circle{% if record.installed_device %}slice-8{% else %}outline{% endif %}' '"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>', attrs={"td": { "class": "text-nowrap" }}, ) actions = ButtonsColumn(model=DeviceBay, buttons=("edit", "delete"), prepend_template=DEVICEBAY_BUTTONS) class Meta(DeviceComponentTable.Meta): model = DeviceBay fields = ( "pk", "name", "label", "status", "installed_device", "description", "tags", "actions", ) default_columns = ( "pk", "name", "label", "status", "installed_device", "description", "actions", )
class RIRTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() is_private = BooleanColumn(verbose_name="Private") aggregate_count = LinkedCountColumn( viewname="ipam:aggregate_list", url_params={"rir": "slug"}, verbose_name="Aggregates", ) actions = ButtonsColumn(RIR, pk_field="slug") class Meta(BaseTable.Meta): model = RIR fields = ( "pk", "name", "slug", "is_private", "aggregate_count", "description", "actions", ) default_columns = ( "pk", "name", "is_private", "aggregate_count", "description", "actions", )
class DeviceInventoryItemTable(InventoryItemTable): name = tables.TemplateColumn( template_code='<a href="{{ record.get_absolute_url }}" style="padding-left: {{ record.level }}0px">' "{{ value }}</a>", attrs={"td": {"class": "text-nowrap"}}, ) actions = ButtonsColumn(model=InventoryItem, buttons=("edit", "delete")) class Meta(DeviceComponentTable.Meta): model = InventoryItem fields = ( "pk", "name", "label", "manufacturer", "part_id", "serial", "asset_tag", "description", "discovered", "tags", "actions", ) default_columns = ( "pk", "name", "label", "manufacturer", "part_id", "serial", "asset_tag", "description", "discovered", "actions", )
class RoleTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() prefix_count = LinkedCountColumn( viewname="ipam:prefix_list", url_params={"role": "slug"}, verbose_name="Prefixes", ) vlan_count = LinkedCountColumn(viewname="ipam:vlan_list", url_params={"role": "slug"}, verbose_name="VLANs") actions = ButtonsColumn(Role, pk_field="slug") class Meta(BaseTable.Meta): model = Role fields = ( "pk", "name", "slug", "prefix_count", "vlan_count", "description", "weight", "actions", ) default_columns = ( "pk", "name", "prefix_count", "vlan_count", "description", "actions", )
class VLANDevicesTable(VLANMembersTable): device = tables.LinkColumn() actions = ButtonsColumn(Interface, buttons=["edit"]) class Meta(BaseTable.Meta): model = Interface fields = ("device", "name", "tagged", "actions")
class RackReservationTable(BaseTable): pk = ToggleColumn() reservation = tables.Column(accessor="pk", linkify=True) site = tables.Column(accessor=Accessor("rack__site"), linkify=True) tenant = TenantColumn() rack = tables.Column(linkify=True) unit_list = tables.Column(orderable=False, verbose_name="Units") tags = TagColumn(url_name="dcim:rackreservation_list") actions = ButtonsColumn(RackReservation) class Meta(BaseTable.Meta): model = RackReservation fields = ( "pk", "reservation", "site", "rack", "unit_list", "user", "created", "tenant", "description", "tags", "actions", ) default_columns = ( "pk", "reservation", "site", "rack", "unit_list", "user", "description", "actions", )
class VLANVirtualMachinesTable(VLANMembersTable): virtual_machine = tables.LinkColumn() actions = ButtonsColumn(VMInterface, buttons=["edit"]) class Meta(BaseTable.Meta): model = VMInterface fields = ("virtual_machine", "name", "tagged", "actions")
class DeviceRearPortTable(RearPortTable): name = tables.TemplateColumn( template_code='<i class="mdi mdi-square-rounded{% if not record.cable %}-outline{% endif %}"></i> ' '<a href="{{ record.get_absolute_url }}">{{ value }}</a>', attrs={"td": {"class": "text-nowrap"}}, ) actions = ButtonsColumn(model=RearPort, buttons=("edit", "delete"), prepend_template=REARPORT_BUTTONS) class Meta(DeviceComponentTable.Meta): model = RearPort fields = ( "pk", "name", "label", "type", "positions", "description", "cable", "cable_peer", "tags", "actions", ) default_columns = ( "pk", "name", "label", "type", "positions", "description", "cable", "cable_peer", "actions", ) row_attrs = {"style": cable_status_color_css}
class DynamicGroupTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) members = tables.Column(accessor="count", verbose_name="Group Members", orderable=False) actions = ButtonsColumn(DynamicGroup, pk_field="slug") class Meta(BaseTable.Meta): # pylint: disable=too-few-public-methods """Resource Manager Meta.""" model = DynamicGroup fields = ( "pk", "name", "description", "content_type", "members", "actions", ) def render_members(self, value, record): """Provide a filtered URL to the group members (if any).""" # Only linkify if there are members. if not value: return value return format_html('<a href="{}">{}</a>', record.get_group_members_url(), value)
class GitRepositoryTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() remote_url = tables.Column(verbose_name="Remote URL") token_rendered = tables.Column(verbose_name="Token") last_sync_time = tables.DateTimeColumn( empty_values=(), format=settings.SHORT_DATETIME_FORMAT, verbose_name="Sync Time" ) last_sync_user = tables.Column(empty_values=(), verbose_name="Sync By") class JobResultColumn(tables.TemplateColumn): def render(self, record, table, value, bound_column, **kwargs): if record.name in table.context.get("job_results", {}): table.context.update({"result": table.context["job_results"][record.name]}) else: table.context.update({"result": None}) return super().render(record, table, value, bound_column, **kwargs) last_sync_status = JobResultColumn(template_name="extras/inc/job_label.html", verbose_name="Sync Status") provides = tables.TemplateColumn(GITREPOSITORY_PROVIDES) actions = ButtonsColumn(GitRepository, pk_field="slug", prepend_template=GITREPOSITORY_BUTTONS) class Meta(BaseTable.Meta): model = GitRepository fields = ( "pk", "name", "slug", "remote_url", "branch", "token_rendered", "provides", "last_sync_time", "last_sync_user", "last_sync_status", "actions", ) default_columns = ( "pk", "name", "remote_url", "branch", "provides", "last_sync_status", "actions", ) def render_last_sync_time(self, record): if record.name in self.context["job_results"]: return self.context["job_results"][record.name].completed return self.default def render_last_sync_user(self, record): if record.name in self.context["job_results"]: user = self.context["job_results"][record.name].user return user return self.default
class TagTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn(viewname="extras:tag", args=[Accessor("slug")]) color = ColorColumn() actions = ButtonsColumn(Tag, pk_field="slug") class Meta(BaseTable.Meta): model = Tag fields = ("pk", "name", "items", "slug", "color", "description", "actions")
class DeviceInterfaceTable(InterfaceTable): name = tables.TemplateColumn( template_code= '<i class="mdi mdi-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}drag-horizontal-variant' "{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}ethernet" '{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>', attrs={"td": { "class": "text-nowrap" }}, ) lag = tables.Column(linkify=True, verbose_name="LAG") actions = ButtonsColumn(model=Interface, buttons=("edit", "delete"), prepend_template=INTERFACE_BUTTONS) class Meta(DeviceComponentTable.Meta): model = Interface fields = ( "pk", "name", "label", "enabled", "type", "lag", "mgmt_only", "mtu", "mode", "mac_address", "description", "cable", "cable_peer", "connection", "tags", "ip_addresses", "untagged_vlan", "tagged_vlans", "actions", ) default_columns = ( "pk", "name", "label", "enabled", "type", "lag", "mtu", "mode", "description", "ip_addresses", "cable", "connection", "actions", ) row_attrs = { "style": cable_status_color_css, "data-name": lambda record: record.name, }
class AnotherExampleModelTable(BaseTable): """Table for list view of `AnotherExampleModel` objects.""" pk = ToggleColumn() name = tables.LinkColumn() actions = ButtonsColumn(AnotherExampleModel) class Meta(BaseTable.Meta): model = AnotherExampleModel fields = ["pk", "name", "number"]
class ClusterGroupTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() cluster_count = tables.Column(verbose_name="Clusters") actions = ButtonsColumn(ClusterGroup, pk_field="slug") class Meta(BaseTable.Meta): model = ClusterGroup fields = ("pk", "name", "slug", "cluster_count", "description", "actions") default_columns = ("pk", "name", "cluster_count", "description", "actions")
class RackGroupTable(BaseTable): pk = ToggleColumn() name = tables.TemplateColumn(template_code=MPTT_LINK, orderable=False, attrs={"td": {"class": "text-nowrap"}}) site = tables.LinkColumn(viewname="dcim:site", args=[Accessor("site__slug")], verbose_name="Site") rack_count = tables.Column(verbose_name="Racks") actions = ButtonsColumn(model=RackGroup, prepend_template=RACKGROUP_ELEVATIONS) class Meta(BaseTable.Meta): model = RackGroup fields = ("pk", "name", "site", "rack_count", "description", "slug", "actions") default_columns = ("pk", "name", "site", "rack_count", "description", "actions")
class DeviceBayTemplateTable(ComponentTemplateTable): actions = ButtonsColumn( model=DeviceBayTemplate, buttons=("edit", "delete"), return_url_extra="%23tab_devicebays", ) class Meta(BaseTable.Meta): model = DeviceBayTemplate fields = ("pk", "name", "label", "description", "actions") empty_text = "None"
class RelationshipAssociationTable(BaseTable): pk = ToggleColumn() actions = ButtonsColumn(Relationship, buttons=("delete", )) source = tables.Column(linkify=True) destination = tables.Column(linkify=True) class Meta(BaseTable.Meta): model = RelationshipAssociation fields = ("relationship", "source", "destination", "actions")
class ConsoleServerPortTemplateTable(ComponentTemplateTable): actions = ButtonsColumn( model=ConsoleServerPortTemplate, buttons=("edit", "delete"), return_url_extra="%23tab_consoleserverports", ) class Meta(BaseTable.Meta): model = ConsoleServerPortTemplate fields = ("pk", "name", "label", "type", "description", "actions") empty_text = "None"
class StatusTable(BaseTable): """Table for list view of `Status` objects.""" pk = ToggleColumn() name = tables.LinkColumn(viewname="extras:status", args=[Accessor("slug")]) color = ColorColumn() actions = ButtonsColumn(Status, pk_field="slug") content_types = ContentTypesColumn(truncate_words=15) class Meta(BaseTable.Meta): model = Status fields = ["pk", "name", "slug", "color", "content_types", "description"]
class InterfaceTemplateTable(ComponentTemplateTable): mgmt_only = BooleanColumn(verbose_name="Management Only") actions = ButtonsColumn( model=InterfaceTemplate, buttons=("edit", "delete"), return_url_extra="%23tab_interfaces", ) class Meta(BaseTable.Meta): model = InterfaceTemplate fields = ("pk", "name", "label", "mgmt_only", "type", "description", "actions") empty_text = "None"
class RelationshipTable(BaseTable): pk = ToggleColumn() actions = ButtonsColumn(Relationship, buttons=("edit", "delete")) class Meta(BaseTable.Meta): model = Relationship fields = ( "name", "description", "type", "source_type", "destination_type", "actions", )
class RegionTable(BaseTable): pk = ToggleColumn() name = tables.TemplateColumn(template_code=MPTT_LINK, orderable=False, attrs={"td": { "class": "text-nowrap" }}) site_count = tables.Column(verbose_name="Sites") actions = ButtonsColumn(Region) class Meta(BaseTable.Meta): model = Region fields = ("pk", "name", "slug", "site_count", "description", "actions") default_columns = ("pk", "name", "site_count", "description", "actions")
class RelationshipAssociationTable(BaseTable): pk = ToggleColumn() actions = ButtonsColumn(RelationshipAssociation, buttons=("delete", )) source_type = tables.Column() source = tables.Column(linkify=True, orderable=False) destination_type = tables.Column() destination = tables.Column(linkify=True, orderable=False) class Meta(BaseTable.Meta): model = RelationshipAssociation fields = ("pk", "relationship", "source_type", "source", "destination_type", "destination", "actions") default_columns = ("pk", "relationship", "source", "destination", "actions")
class ConfigContextSchemaTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() owner = tables.LinkColumn() actions = ButtonsColumn(ConfigContextSchema, pk_field="slug") class Meta(BaseTable.Meta): model = ConfigContextSchema fields = ( "pk", "name", "owner", "description", "actions", ) default_columns = ("pk", "name", "description", "actions")
class VLANGroupTable(BaseTable): pk = ToggleColumn() name = tables.Column(linkify=True) site = tables.LinkColumn(viewname="dcim:site", args=[Accessor("site__slug")]) vlan_count = LinkedCountColumn(viewname="ipam:vlan_list", url_params={"group": "slug"}, verbose_name="VLANs") actions = ButtonsColumn(model=VLANGroup, prepend_template=VLANGROUP_ADD_VLAN) class Meta(BaseTable.Meta): model = VLANGroup fields = ("pk", "name", "site", "vlan_count", "slug", "description", "actions") default_columns = ("pk", "name", "site", "vlan_count", "description", "actions")
class CircuitTypeTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() circuit_count = tables.Column(verbose_name="Circuits") actions = ButtonsColumn(CircuitType, pk_field="slug") class Meta(BaseTable.Meta): model = CircuitType fields = ("pk", "name", "circuit_count", "description", "slug", "actions") default_columns = ( "pk", "name", "circuit_count", "description", "slug", "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", "name", "rack_count", "color", "description", "slug", "actions") default_columns = ( "pk", "name", "rack_count", "color", "description", "actions", )
class DevicePowerOutletTable(PowerOutletTable): name = tables.TemplateColumn( template_code= '<i class="mdi mdi-power-socket"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>', attrs={"td": { "class": "text-nowrap" }}, ) actions = ButtonsColumn( model=PowerOutlet, buttons=("edit", "delete"), prepend_template=POWEROUTLET_BUTTONS, ) class Meta(DeviceComponentTable.Meta): model = PowerOutlet fields = ( "pk", "name", "label", "type", "power_port", "feed_leg", "description", "cable", "cable_peer", "connection", "tags", "actions", ) default_columns = ( "pk", "name", "label", "type", "power_port", "feed_leg", "description", "cable", "connection", "actions", ) row_attrs = {"style": cable_status_color_css}
class DevicePowerPortTable(PowerPortTable): name = tables.TemplateColumn( template_code= '<i class="mdi mdi-power-plug-outline"></i> <a href="{{ record.get_absolute_url }}">' "{{ value }}</a>", attrs={"td": { "class": "text-nowrap" }}, ) actions = ButtonsColumn(model=PowerPort, buttons=("edit", "delete"), prepend_template=POWERPORT_BUTTONS) class Meta(DeviceComponentTable.Meta): model = PowerPort fields = ( "pk", "name", "label", "type", "maximum_draw", "allocated_draw", "description", "cable", "cable_peer", "connection", "tags", "actions", ) default_columns = ( "pk", "name", "label", "type", "maximum_draw", "allocated_draw", "description", "cable", "connection", "actions", ) row_attrs = {"style": cable_status_color_css}
class TenantGroupTable(BaseTable): pk = ToggleColumn() name = tables.TemplateColumn(template_code=MPTT_LINK, orderable=False, attrs={"td": { "class": "text-nowrap" }}) tenant_count = LinkedCountColumn( viewname="tenancy:tenant_list", url_params={"group": "slug"}, verbose_name="Tenants", ) actions = ButtonsColumn(TenantGroup, pk_field="slug") class Meta(BaseTable.Meta): model = TenantGroup fields = ("pk", "name", "tenant_count", "description", "slug", "actions") default_columns = ("pk", "name", "tenant_count", "description", "actions")