mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-22 05:12:22 -06:00
Merge branch 'develop' into feature
This commit is contained in:
@@ -4,7 +4,7 @@ from django_tables2.utils import Accessor
|
||||
|
||||
from ipam.models import *
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from tenancy.tables import TenancyColumnsMixin, TenantColumn
|
||||
|
||||
__all__ = (
|
||||
'AggregateTable',
|
||||
@@ -99,7 +99,7 @@ class RIRTable(NetBoxTable):
|
||||
# ASNs
|
||||
#
|
||||
|
||||
class ASNTable(NetBoxTable):
|
||||
class ASNTable(TenancyColumnsMixin, NetBoxTable):
|
||||
asn = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -122,7 +122,6 @@ class ASNTable(NetBoxTable):
|
||||
linkify_item=True,
|
||||
verbose_name='Sites'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:asn_list'
|
||||
)
|
||||
@@ -130,7 +129,7 @@ class ASNTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = ASN
|
||||
fields = (
|
||||
'pk', 'asn', 'asn_asdot', 'rir', 'site_count', 'provider_count', 'tenant', 'description', 'sites', 'tags',
|
||||
'pk', 'asn', 'asn_asdot', 'rir', 'site_count', 'provider_count', 'tenant', 'tenant_group', 'description', 'sites', 'tags',
|
||||
'created', 'last_updated', 'actions',
|
||||
)
|
||||
default_columns = ('pk', 'asn', 'rir', 'site_count', 'provider_count', 'sites', 'description', 'tenant')
|
||||
@@ -140,12 +139,11 @@ class ASNTable(NetBoxTable):
|
||||
# Aggregates
|
||||
#
|
||||
|
||||
class AggregateTable(NetBoxTable):
|
||||
class AggregateTable(TenancyColumnsMixin, NetBoxTable):
|
||||
prefix = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='Aggregate'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
date_added = tables.DateColumn(
|
||||
format="Y-m-d",
|
||||
verbose_name='Added'
|
||||
@@ -164,7 +162,7 @@ class AggregateTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = Aggregate
|
||||
fields = (
|
||||
'pk', 'id', 'prefix', 'rir', 'tenant', 'child_count', 'utilization', 'date_added', 'description', 'tags',
|
||||
'pk', 'id', 'prefix', 'rir', 'tenant', 'tenant_group', 'child_count', 'utilization', 'date_added', 'description', 'tags',
|
||||
'created', 'last_updated',
|
||||
)
|
||||
default_columns = ('pk', 'prefix', 'rir', 'tenant', 'child_count', 'utilization', 'date_added', 'description')
|
||||
@@ -225,7 +223,7 @@ class PrefixUtilizationColumn(columns.UtilizationColumn):
|
||||
"""
|
||||
|
||||
|
||||
class PrefixTable(NetBoxTable):
|
||||
class PrefixTable(TenancyColumnsMixin, NetBoxTable):
|
||||
prefix = columns.TemplateColumn(
|
||||
template_code=PREFIX_LINK,
|
||||
export_raw=True,
|
||||
@@ -256,7 +254,6 @@ class PrefixTable(NetBoxTable):
|
||||
template_code=VRF_LINK,
|
||||
verbose_name='VRF'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -289,7 +286,7 @@ class PrefixTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = Prefix
|
||||
fields = (
|
||||
'pk', 'id', 'prefix', 'prefix_flat', 'status', 'children', 'vrf', 'utilization', 'tenant', 'site',
|
||||
'pk', 'id', 'prefix', 'prefix_flat', 'status', 'children', 'vrf', 'utilization', 'tenant', 'tenant_group', 'site',
|
||||
'vlan_group', 'vlan', 'role', 'is_pool', 'mark_utilized', 'description', 'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = (
|
||||
@@ -303,7 +300,7 @@ class PrefixTable(NetBoxTable):
|
||||
#
|
||||
# IP ranges
|
||||
#
|
||||
class IPRangeTable(NetBoxTable):
|
||||
class IPRangeTable(TenancyColumnsMixin, NetBoxTable):
|
||||
start_address = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
@@ -317,7 +314,6 @@ class IPRangeTable(NetBoxTable):
|
||||
role = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
utilization = columns.UtilizationColumn(
|
||||
accessor='utilization',
|
||||
orderable=False
|
||||
@@ -329,7 +325,7 @@ class IPRangeTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = IPRange
|
||||
fields = (
|
||||
'pk', 'id', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'description',
|
||||
'pk', 'id', 'start_address', 'end_address', 'size', 'vrf', 'status', 'role', 'tenant', 'tenant_group', 'description',
|
||||
'utilization', 'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = (
|
||||
@@ -344,7 +340,7 @@ class IPRangeTable(NetBoxTable):
|
||||
# IPAddresses
|
||||
#
|
||||
|
||||
class IPAddressTable(NetBoxTable):
|
||||
class IPAddressTable(TenancyColumnsMixin, NetBoxTable):
|
||||
address = tables.TemplateColumn(
|
||||
template_code=IPADDRESS_LINK,
|
||||
verbose_name='IP Address'
|
||||
@@ -357,7 +353,6 @@ class IPAddressTable(NetBoxTable):
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
role = columns.ChoiceFieldColumn()
|
||||
tenant = TenantColumn()
|
||||
assigned_object = tables.Column(
|
||||
linkify=True,
|
||||
orderable=False,
|
||||
@@ -386,7 +381,7 @@ class IPAddressTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = IPAddress
|
||||
fields = (
|
||||
'pk', 'id', 'address', 'vrf', 'status', 'role', 'tenant', 'nat_inside', 'assigned', 'dns_name', 'description',
|
||||
'pk', 'id', 'address', 'vrf', 'status', 'role', 'tenant', 'tenant_group', 'nat_inside', 'assigned', 'dns_name', 'description',
|
||||
'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = (
|
||||
|
||||
@@ -5,7 +5,7 @@ from django_tables2.utils import Accessor
|
||||
from dcim.models import Interface
|
||||
from ipam.models import *
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from tenancy.tables import TenancyColumnsMixin, TenantColumn
|
||||
from virtualization.models import VMInterface
|
||||
|
||||
__all__ = (
|
||||
@@ -90,7 +90,7 @@ class VLANGroupTable(NetBoxTable):
|
||||
# VLANs
|
||||
#
|
||||
|
||||
class VLANTable(NetBoxTable):
|
||||
class VLANTable(TenancyColumnsMixin, NetBoxTable):
|
||||
vid = tables.TemplateColumn(
|
||||
template_code=VLAN_LINK,
|
||||
verbose_name='VID'
|
||||
@@ -104,7 +104,6 @@ class VLANTable(NetBoxTable):
|
||||
group = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
status = columns.ChoiceFieldColumn(
|
||||
default=AVAILABLE_LABEL
|
||||
)
|
||||
@@ -123,7 +122,7 @@ class VLANTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = VLAN
|
||||
fields = (
|
||||
'pk', 'id', 'vid', 'name', 'site', 'group', 'prefixes', 'tenant', 'status', 'role', 'description', 'tags',
|
||||
'pk', 'id', 'vid', 'name', 'site', 'group', 'prefixes', 'tenant', 'tenant_group', 'status', 'role', 'description', 'tags',
|
||||
'created', 'last_updated',
|
||||
)
|
||||
default_columns = ('pk', 'vid', 'name', 'site', 'group', 'prefixes', 'tenant', 'status', 'role', 'description')
|
||||
|
||||
@@ -2,7 +2,7 @@ import django_tables2 as tables
|
||||
|
||||
from ipam.models import *
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
from tenancy.tables import TenantColumn
|
||||
from tenancy.tables import TenancyColumnsMixin
|
||||
|
||||
__all__ = (
|
||||
'RouteTargetTable',
|
||||
@@ -20,14 +20,13 @@ VRF_TARGETS = """
|
||||
# VRFs
|
||||
#
|
||||
|
||||
class VRFTable(NetBoxTable):
|
||||
class VRFTable(TenancyColumnsMixin, NetBoxTable):
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
rd = tables.Column(
|
||||
verbose_name='RD'
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
enforce_unique = columns.BooleanColumn(
|
||||
verbose_name='Unique'
|
||||
)
|
||||
@@ -46,7 +45,7 @@ class VRFTable(NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = VRF
|
||||
fields = (
|
||||
'pk', 'id', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets', 'export_targets',
|
||||
'pk', 'id', 'name', 'rd', 'tenant', 'tenant_group', 'enforce_unique', 'description', 'import_targets', 'export_targets',
|
||||
'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = ('pk', 'name', 'rd', 'tenant', 'description')
|
||||
@@ -56,16 +55,15 @@ class VRFTable(NetBoxTable):
|
||||
# Route targets
|
||||
#
|
||||
|
||||
class RouteTargetTable(NetBoxTable):
|
||||
class RouteTargetTable(TenancyColumnsMixin, NetBoxTable):
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tenant = TenantColumn()
|
||||
tags = columns.TagColumn(
|
||||
url_name='ipam:vrf_list'
|
||||
)
|
||||
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = RouteTarget
|
||||
fields = ('pk', 'id', 'name', 'tenant', 'description', 'tags', 'created', 'last_updated',)
|
||||
fields = ('pk', 'id', 'name', 'tenant', 'tenant_group', 'description', 'tags', 'created', 'last_updated',)
|
||||
default_columns = ('pk', 'name', 'tenant', 'description')
|
||||
|
||||
@@ -299,7 +299,7 @@ class AggregatePrefixesView(generic.ObjectChildrenView):
|
||||
def get_children(self, request, parent):
|
||||
return Prefix.objects.restrict(request.user, 'view').filter(
|
||||
prefix__net_contained_or_equal=str(parent.prefix)
|
||||
).prefetch_related('site', 'role', 'tenant', 'vlan')
|
||||
).prefetch_related('site', 'role', 'tenant', 'tenant__group', 'vlan')
|
||||
|
||||
def prep_table_data(self, request, queryset, parent):
|
||||
# Determine whether to show assigned prefixes, available prefixes, or both
|
||||
@@ -471,7 +471,7 @@ class PrefixPrefixesView(generic.ObjectChildrenView):
|
||||
|
||||
def get_children(self, request, parent):
|
||||
return parent.get_child_prefixes().restrict(request.user, 'view').prefetch_related(
|
||||
'site', 'vrf', 'vlan', 'role', 'tenant',
|
||||
'site', 'vrf', 'vlan', 'role', 'tenant', 'tenant__group'
|
||||
)
|
||||
|
||||
def prep_table_data(self, request, queryset, parent):
|
||||
@@ -500,7 +500,7 @@ class PrefixIPRangesView(generic.ObjectChildrenView):
|
||||
|
||||
def get_children(self, request, parent):
|
||||
return parent.get_child_ranges().restrict(request.user, 'view').prefetch_related(
|
||||
'vrf', 'role', 'tenant',
|
||||
'vrf', 'role', 'tenant', 'tenant__group',
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
@@ -587,9 +587,7 @@ class IPRangeIPAddressesView(generic.ObjectChildrenView):
|
||||
template_name = 'ipam/iprange/ip_addresses.html'
|
||||
|
||||
def get_children(self, request, parent):
|
||||
return parent.get_child_ips().restrict(request.user, 'view').prefetch_related(
|
||||
'vrf', 'tenant',
|
||||
)
|
||||
return parent.get_child_ips().restrict(request.user, 'view')
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user