Exemplo n.º 1
0
class WebhookTable(BaseTable):
    pk = ToggleColumn()
    name = tables.Column(linkify=True)
    content_types = tables.TemplateColumn(WEBHOOK_CONTENT_TYPES)
    enabled = BooleanColumn()
    type_create = BooleanColumn()
    type_update = BooleanColumn()
    type_delete = BooleanColumn()
    ssl_verification = BooleanColumn()

    class Meta(BaseTable.Meta):
        model = Webhook
        fields = (
            "pk",
            "name",
            "content_types",
            "payload_url",
            "http_content_type",
            "http_method",
            "enabled",
            "type_create",
            "type_update",
            "type_delete",
            "ssl_verification",
            "ca_file_path",
        )
        default_columns = (
            "pk",
            "name",
            "content_types",
            "payload_url",
            "http_content_type",
            "enabled",
        )
Exemplo n.º 2
0
class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable):
    mgmt_only = BooleanColumn()
    tags = TagColumn(url_name="dcim:interface_list")

    class Meta(DeviceComponentTable.Meta):
        model = Interface
        fields = (
            "pk",
            "device",
            "name",
            "label",
            "enabled",
            "type",
            "mgmt_only",
            "mtu",
            "mode",
            "mac_address",
            "description",
            "cable",
            "cable_peer",
            "connection",
            "tags",
            "ip_addresses",
            "untagged_vlan",
            "tagged_vlans",
        )
        default_columns = (
            "pk",
            "device",
            "name",
            "label",
            "enabled",
            "type",
            "description",
        )
Exemplo n.º 3
0
class CustomLinkTable(BaseTable):
    pk = ToggleColumn()
    name = tables.Column(linkify=True)
    new_window = BooleanColumn()

    class Meta(BaseTable.Meta):
        model = CustomLink
        fields = (
            "pk",
            "name",
            "content_type",
            "text",
            "target_url",
            "weight",
            "group_name",
            "button_class",
            "new_window",
        )
        default_columns = (
            "pk",
            "name",
            "content_type",
            "group_name",
            "weight",
        )
Exemplo n.º 4
0
class ConfigContextTable(BaseTable):
    pk = ToggleColumn()
    name = tables.LinkColumn()
    owner = tables.LinkColumn()
    is_active = BooleanColumn(verbose_name="Active")

    class Meta(BaseTable.Meta):
        model = ConfigContext
        fields = (
            "pk",
            "name",
            "owner",
            "weight",
            "is_active",
            "description",
            "regions",
            "sites",
            "roles",
            "platforms",
            "cluster_groups",
            "clusters",
            "tenant_groups",
            "tenants",
        )
        default_columns = ("pk", "name", "weight", "is_active", "description")
Exemplo n.º 5
0
class CustomFieldTable(BaseTable):
    pk = ToggleColumn()
    # TODO: Replace name column with slug #464
    slug = tables.Column(linkify=True, accessor="name")
    content_types = ContentTypesColumn(truncate_words=15)
    required = BooleanColumn()

    class Meta(BaseTable.Meta):
        model = CustomField
        fields = (
            "pk",
            "slug",
            "content_types",
            "type",
            "label",
            "description",
            "required",
            "default",
            "weight",
        )
        default_columns = (
            "pk",
            "slug",
            "content_types",
            "type",
            "label",
            "required",
            "weight",
        )

    def render_description(self, record):
        if record.description:
            return mark_safe(render_markdown(record.description))
        return self.default
Exemplo n.º 6
0
class ConsoleConnectionTable(BaseTable):
    console_server = tables.Column(
        accessor=Accessor("_path__destination__device"),
        orderable=False,
        linkify=True,
        verbose_name="Console Server",
    )
    console_server_port = tables.Column(
        accessor=Accessor("_path__destination"),
        orderable=False,
        linkify=True,
        verbose_name="Port",
    )
    device = tables.Column(linkify=True)
    name = tables.Column(linkify=True, verbose_name="Console Port")
    reachable = BooleanColumn(accessor=Accessor("_path__is_active"),
                              verbose_name="Reachable")

    class Meta(BaseTable.Meta):
        model = ConsolePort
        fields = (
            "device",
            "name",
            "console_server",
            "console_server_port",
            "reachable",
        )
Exemplo n.º 7
0
class InterfaceConnectionTable(BaseTable):
    device_a = tables.Column(accessor=Accessor("device"),
                             linkify=True,
                             verbose_name="Device A")
    interface_a = tables.Column(accessor=Accessor("name"),
                                linkify=True,
                                verbose_name="Interface A")
    device_b = tables.Column(
        accessor=Accessor("_path__destination__device"),
        orderable=False,
        linkify=True,
        verbose_name="Device B",
    )
    interface_b = tables.Column(
        accessor=Accessor("_path__destination"),
        orderable=False,
        linkify=True,
        verbose_name="Interface B",
    )
    reachable = BooleanColumn(accessor=Accessor("_path__is_active"),
                              verbose_name="Reachable")

    class Meta(BaseTable.Meta):
        model = Interface
        fields = ("device_a", "interface_a", "device_b", "interface_b",
                  "reachable")
Exemplo n.º 8
0
class InterfaceVLANTable(StatusTableMixin, BaseTable):
    """
    List VLANs assigned to a specific Interface.
    """

    vid = tables.LinkColumn(viewname="ipam:vlan",
                            args=[Accessor("pk")],
                            verbose_name="ID")
    tagged = BooleanColumn()
    site = tables.Column(linkify=True)
    group = tables.Column(accessor=Accessor("group__name"),
                          verbose_name="Group")
    tenant = tables.TemplateColumn(template_code=COL_TENANT)
    role = tables.TemplateColumn(template_code=VLAN_ROLE_LINK)

    class Meta(BaseTable.Meta):
        model = VLAN
        fields = (
            "vid",
            "tagged",
            "site",
            "group",
            "name",
            "tenant",
            "status",
            "role",
            "description",
        )

    def __init__(self, interface, *args, **kwargs):
        self.interface = interface
        super().__init__(*args, **kwargs)
Exemplo n.º 9
0
class IPAddressDetailTable(IPAddressTable):
    nat_inside = tables.Column(linkify=True,
                               orderable=False,
                               verbose_name="NAT (Inside)")
    tenant = tables.TemplateColumn(template_code=COL_TENANT)
    assigned = BooleanColumn(accessor="assigned_object_id",
                             verbose_name="Assigned")
    tags = TagColumn(url_name="ipam:ipaddress_list")

    class Meta(IPAddressTable.Meta):
        fields = (
            "pk",
            "address",
            "vrf",
            "status",
            "role",
            "tenant",
            "nat_inside",
            "assigned",
            "dns_name",
            "description",
            "tags",
        )
        default_columns = (
            "pk",
            "address",
            "vrf",
            "status",
            "role",
            "tenant",
            "assigned",
            "dns_name",
            "description",
        )
Exemplo n.º 10
0
class VRFTable(BaseTable):
    pk = ToggleColumn()
    name = tables.LinkColumn()
    rd = tables.Column(verbose_name="RD")
    tenant = tables.TemplateColumn(template_code=COL_TENANT)
    enforce_unique = BooleanColumn(verbose_name="Unique")
    import_targets = tables.TemplateColumn(template_code=VRF_TARGETS,
                                           orderable=False)
    export_targets = tables.TemplateColumn(template_code=VRF_TARGETS,
                                           orderable=False)
    tags = TagColumn(url_name="ipam:vrf_list")

    class Meta(BaseTable.Meta):
        model = VRF
        fields = (
            "pk",
            "name",
            "rd",
            "tenant",
            "enforce_unique",
            "description",
            "import_targets",
            "export_targets",
            "tags",
        )
        default_columns = ("pk", "name", "rd", "tenant", "description")
Exemplo n.º 11
0
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",
        )
Exemplo n.º 12
0
class DeviceTypeTable(BaseTable):
    pk = ToggleColumn()
    model = tables.Column(linkify=True, verbose_name="Device Type")
    is_full_depth = BooleanColumn(verbose_name="Full Depth")
    instance_count = LinkedCountColumn(
        viewname="dcim:device_list",
        url_params={"device_type_id": "pk"},
        verbose_name="Instances",
    )
    tags = TagColumn(url_name="dcim:devicetype_list")

    class Meta(BaseTable.Meta):
        model = DeviceType
        fields = (
            "pk",
            "model",
            "manufacturer",
            "slug",
            "part_number",
            "u_height",
            "is_full_depth",
            "subdevice_role",
            "instance_count",
            "tags",
        )
        default_columns = (
            "pk",
            "model",
            "manufacturer",
            "part_number",
            "u_height",
            "is_full_depth",
            "instance_count",
        )
Exemplo n.º 13
0
class InventoryItemTable(DeviceComponentTable):
    manufacturer = tables.Column(linkify=True)
    discovered = BooleanColumn()
    tags = TagColumn(url_name="dcim:inventoryitem_list")
    cable = None  # Override DeviceComponentTable

    class Meta(DeviceComponentTable.Meta):
        model = InventoryItem
        fields = (
            "pk",
            "device",
            "name",
            "label",
            "manufacturer",
            "part_id",
            "serial",
            "asset_tag",
            "description",
            "discovered",
            "tags",
        )
        default_columns = (
            "pk",
            "device",
            "name",
            "label",
            "manufacturer",
            "part_id",
            "serial",
            "asset_tag",
        )
Exemplo n.º 14
0
class BaseInterfaceTable(BaseTable):
    enabled = BooleanColumn()
    ip_addresses = tables.TemplateColumn(
        template_code=INTERFACE_IPADDRESSES,
        orderable=False,
        verbose_name="IP Addresses",
    )
    untagged_vlan = tables.Column(linkify=True)
    tagged_vlans = tables.TemplateColumn(
        template_code=INTERFACE_TAGGED_VLANS,
        orderable=False,
        verbose_name="Tagged VLANs",
    )
Exemplo n.º 15
0
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"
Exemplo n.º 16
0
class PrefixTable(StatusTableMixin, BaseTable):
    pk = ToggleColumn()
    prefix = tables.TemplateColumn(template_code=PREFIX_LINK,
                                   attrs={"td": {
                                       "class": "text-nowrap"
                                   }},
                                   order_by=("network", "prefix_length"))
    vrf = tables.TemplateColumn(template_code=VRF_LINK, verbose_name="VRF")
    tenant = TenantColumn()
    site = tables.Column(linkify=True)
    vlan = tables.Column(linkify=True, verbose_name="VLAN")
    role = tables.TemplateColumn(template_code=PREFIX_ROLE_LINK)
    is_pool = BooleanColumn(verbose_name="Pool")

    class Meta(BaseTable.Meta):
        model = Prefix
        fields = (
            "pk",
            "prefix",
            "status",
            "children",
            "vrf",
            "tenant",
            "site",
            "vlan",
            "role",
            "is_pool",
            "description",
        )
        default_columns = (
            "pk",
            "prefix",
            "status",
            "vrf",
            "tenant",
            "site",
            "vlan",
            "role",
            "description",
        )
        row_attrs = {
            "class":
            lambda record: "success" if not record.present_in_database else "",
        }
Exemplo n.º 17
0
class PowerConnectionTable(BaseTable):
    pdu = tables.Column(
        accessor=Accessor("_path__destination__device"),
        orderable=False,
        linkify=True,
        verbose_name="PDU",
    )
    outlet = tables.Column(
        accessor=Accessor("_path__destination"),
        orderable=False,
        linkify=True,
        verbose_name="Outlet",
    )
    device = tables.Column(linkify=True)
    name = tables.Column(linkify=True, verbose_name="Power Port")
    reachable = BooleanColumn(accessor=Accessor("_path__is_active"),
                              verbose_name="Reachable")

    class Meta(BaseTable.Meta):
        model = PowerPort
        fields = ("device", "name", "pdu", "outlet", "reachable")
Exemplo n.º 18
0
class DeviceRoleTable(BaseTable):
    pk = ToggleColumn()
    name = tables.LinkColumn()
    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",
        )
Exemplo n.º 19
0
class JobTable(BaseTable):
    # TODO pk = ToggleColumn()
    source = tables.Column()
    # grouping is used to, well, group the Jobs, so it isn't a column of its own.
    name = tables.Column(linkify=True)
    installed = BooleanColumn()
    enabled = BooleanColumn()
    description = tables.Column(accessor="description_first_line")
    commit_default = BooleanColumn()
    hidden = BooleanColumn()
    read_only = BooleanColumn()
    approval_required = BooleanColumn()
    soft_time_limit = tables.Column()
    time_limit = tables.Column()
    actions = ButtonsColumn(JobModel,
                            pk_field="slug",
                            prepend_template=JOB_BUTTONS)
    last_run = tables.TemplateColumn(
        accessor="latest_result",
        template_code="""
            {% if value %}
                {{ value.created }} by {{ value.user }}
            {% else %}
                <span class="text-muted">Never</span>
            {% endif %}
        """,
        linkify=lambda value: value.get_absolute_url() if value else None,
    )
    last_status = tables.TemplateColumn(
        template_code=
        "{% include 'extras/inc/job_label.html' with result=record.latest_result %}",
    )
    tags = TagColumn(url_name="extras:job_list")

    def render_description(self, value):
        return render_markdown(value)

    class Meta(BaseTable.Meta):
        model = JobModel
        orderable = False
        fields = (
            "source",
            "name",
            "installed",
            "enabled",
            "description",
            "commit_default",
            "hidden",
            "read_only",
            "approval_required",
            "soft_time_limit",
            "time_limit",
            "last_run",
            "last_status",
            "tags",
            "actions",
        )
        default_columns = (
            "name",
            "enabled",
            "description",
            "last_run",
            "last_status",
            "actions",
        )