Ejemplo n.º 1
0
class DeviceTable(BaseTable):
    pk = ToggleColumn()
    name = tables.TemplateColumn(order_by=('_name', ),
                                 template_code=DEVICE_LINK)
    status = ChoiceFieldColumn()
    tenant = TenantColumn()
    site = tables.Column(linkify=True)
    location = tables.Column(linkify=True)
    rack = tables.Column(linkify=True)
    device_role = ColoredLabelColumn(verbose_name='Role')
    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(linkify=True,
                                   order_by=('primary_ip4', 'primary_ip6'),
                                   verbose_name='IP Address')
    else:
        primary_ip = tables.Column(linkify=True,
                                   order_by=('primary_ip6', 'primary_ip4'),
                                   verbose_name='IP Address')
    primary_ip4 = tables.Column(linkify=True, verbose_name='IPv4 Address')
    primary_ip6 = tables.Column(linkify=True, verbose_name='IPv6 Address')
    cluster = tables.Column(linkify=True)
    virtual_chassis = tables.Column(linkify=True)
    vc_position = tables.Column(verbose_name='VC Position')
    vc_priority = tables.Column(verbose_name='VC Priority')
    comments = MarkdownColumn()
    tags = TagColumn(url_name='dcim:device_list')

    class Meta(BaseTable.Meta):
        model = Device
        fields = (
            'pk',
            'id',
            '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',
            'comments',
            'tags',
        )
        default_columns = (
            'pk',
            'name',
            'status',
            'tenant',
            'site',
            'location',
            'rack',
            'device_role',
            'manufacturer',
            'device_type',
            'primary_ip',
        )
Ejemplo n.º 2
0
class PrefixTable(BaseTable):
    pk = ToggleColumn()
    prefix = tables.TemplateColumn(template_code=PREFIX_LINK,
                                   attrs={'td': {
                                       'class': 'text-nowrap'
                                   }})
    prefix_flat = tables.TemplateColumn(
        template_code=PREFIXFLAT_LINK,
        attrs={'td': {
            'class': 'text-nowrap'
        }},
        verbose_name='Prefix (Flat)',
    )
    depth = tables.Column(accessor=Accessor('_depth'), verbose_name='Depth')
    children = LinkedCountColumn(accessor=Accessor('_children'),
                                 viewname='ipam:prefix_list',
                                 url_params={
                                     'vrf_id': 'vrf_id',
                                     'within': 'prefix',
                                 },
                                 verbose_name='Children')
    status = ChoiceFieldColumn(default=AVAILABLE_LABEL)
    vrf = tables.TemplateColumn(template_code=VRF_LINK, verbose_name='VRF')
    tenant = TenantColumn()
    site = tables.Column(linkify=True)
    vlan_group = tables.Column(accessor='vlan__group',
                               linkify=True,
                               verbose_name='VLAN Group')
    vlan = tables.Column(linkify=True, verbose_name='VLAN')
    role = tables.Column(linkify=True)
    is_pool = BooleanColumn(verbose_name='Pool')
    mark_utilized = BooleanColumn(verbose_name='Marked Utilized')
    utilization = PrefixUtilizationColumn(accessor='get_utilization',
                                          orderable=False)
    tags = TagColumn(url_name='ipam:prefix_list')

    class Meta(BaseTable.Meta):
        model = Prefix
        fields = (
            'pk',
            'id',
            'prefix',
            'prefix_flat',
            'status',
            'children',
            'vrf',
            'utilization',
            'tenant',
            'site',
            'vlan_group',
            'vlan',
            'role',
            'is_pool',
            'mark_utilized',
            'description',
            'tags',
            'created',
            'last_updated',
        )
        default_columns = (
            'pk',
            'prefix',
            'status',
            'children',
            'vrf',
            'utilization',
            'tenant',
            'site',
            'vlan',
            'role',
            'description',
        )
        row_attrs = {
            'class': lambda record: 'success' if not record.pk else '',
        }
Ejemplo n.º 3
0
class ComponentTemplateTable(BaseTable):
    pk = ToggleColumn()
    name = tables.Column(order_by=('_name', ))
Ejemplo n.º 4
0
class DeviceTable(BaseTable):
    pk = ToggleColumn()
    name = tables.TemplateColumn(order_by=('_name', ),
                                 template_code=DEVICE_LINK)
    status = tables.TemplateColumn(template_code=STATUS_LABEL)
    tenant = tables.TemplateColumn(template_code=COL_TENANT)
    site = tables.Column(linkify=True)
    rack = tables.Column(linkify=True)
    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)
    primary_ip = tables.TemplateColumn(template_code=DEVICE_PRIMARY_IP,
                                       orderable=False,
                                       verbose_name='IP Address')
    primary_ip4 = tables.Column(linkify=True, verbose_name='IPv4 Address')
    primary_ip6 = tables.Column(linkify=True, verbose_name='IPv6 Address')
    cluster = tables.LinkColumn(viewname='virtualization:cluster',
                                args=[Accessor('cluster__pk')])
    virtual_chassis = tables.LinkColumn(viewname='dcim:virtualchassis',
                                        args=[Accessor('virtual_chassis__pk')])
    vc_position = tables.Column(verbose_name='VC Position')
    vc_priority = tables.Column(verbose_name='VC Priority')
    tags = TagColumn(url_name='dcim:device_list')

    class Meta(BaseTable.Meta):
        model = Device
        fields = (
            'pk',
            'name',
            'status',
            'tenant',
            'device_role',
            'device_type',
            'platform',
            'serial',
            'asset_tag',
            'site',
            'rack',
            'position',
            'face',
            'primary_ip',
            'primary_ip4',
            'primary_ip6',
            'cluster',
            'virtual_chassis',
            'vc_position',
            'vc_priority',
            'tags',
        )
        default_columns = (
            'pk',
            'name',
            'status',
            'tenant',
            'site',
            'rack',
            'device_role',
            'device_type',
            'primary_ip',
        )
Ejemplo n.º 5
0
class ServiceDetailTable(BaseTable):
    pk = ToggleColumn()

    class Meta(BaseTable.Meta):
        model = Service
        fields = ("type", "cpe.ip_address")