From 0edf9b17f65636aa36275c8b35f68553226f3989 Mon Sep 17 00:00:00 2001 From: Will Irvine Date: Sat, 13 Nov 2021 13:27:49 +1300 Subject: [PATCH 01/62] Closes #7665 add new boolen for filtering assigned prefixes, adjust current filter for avaliabile prefixes to only return avaliable --- netbox/ipam/utils.py | 7 +------ netbox/ipam/views.py | 19 +++++++++++++++---- .../templates/ipam/inc/toggle_available.html | 11 +++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/netbox/ipam/utils.py b/netbox/ipam/utils.py index 0e79e7f78e6..888a2ad1799 100644 --- a/netbox/ipam/utils.py +++ b/netbox/ipam/utils.py @@ -13,12 +13,7 @@ def add_available_prefixes(parent, prefix_list): available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list]) available_prefixes = [Prefix(prefix=p, status=None) for p in available_prefixes.iter_cidrs()] - # Concatenate and sort complete list of children - prefix_list = list(prefix_list) + available_prefixes - prefix_list.sort(key=lambda p: p.prefix) - - return prefix_list - + return available_prefixes def add_available_ipaddresses(prefix, ipaddress_list, is_pool=False): """ diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index c24a80124bd..300f2f6d7d5 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -393,14 +393,24 @@ class PrefixPrefixesView(generic.ObjectView): template_name = 'ipam/prefix/prefixes.html' def get_extra_context(self, request, instance): - # Child prefixes table - child_prefixes = instance.get_child_prefixes().restrict(request.user, 'view').prefetch_related( + # Initial pull of currently assigned child prefixes + child_prefixes_assigned = instance.get_child_prefixes().restrict(request.user, 'view').prefetch_related( 'site', 'vlan', 'role', ) + # List to append filtered prefixes to + child_prefixes = [] + # Add available prefixes to the table if requested - if child_prefixes and request.GET.get('show_available', 'true') == 'true': - child_prefixes = add_available_prefixes(instance.prefix, child_prefixes) + if child_prefixes_assigned and request.GET.get('show_available', 'true') == 'true': + child_prefixes = child_prefixes + add_available_prefixes(instance.prefix, child_prefixes_assigned) + + # Add assigned prefixes to the table if requested + if child_prefixes_assigned and request.GET.get('show_assigned', 'true') == 'true': + child_prefixes = child_prefixes + list(child_prefixes_assigned) + + # Sort child prefixes after additions + child_prefixes.sort(key=lambda p: p.prefix) table = tables.PrefixTable(child_prefixes, user=request.user, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): @@ -422,6 +432,7 @@ def get_extra_context(self, request, instance): 'active_tab': 'prefixes', 'first_available_prefix': instance.get_first_available_prefix(), 'show_available': request.GET.get('show_available', 'true') == 'true', + 'show_assigned': request.GET.get('show_assigned', 'true') == 'true', } diff --git a/netbox/templates/ipam/inc/toggle_available.html b/netbox/templates/ipam/inc/toggle_available.html index 234218a0194..f0d286128e4 100644 --- a/netbox/templates/ipam/inc/toggle_available.html +++ b/netbox/templates/ipam/inc/toggle_available.html @@ -1,5 +1,16 @@ {% load helpers %} +{% if show_assigned is not None %} +
+ + Show Assigned + + + Hide Assigned + +
+{% endif %} + {% if show_available is not None %}
From 641a9bc6c56a214737b673add3f3de9efb9b9671 Mon Sep 17 00:00:00 2001 From: Will Irvine Date: Sat, 13 Nov 2021 15:26:07 +1300 Subject: [PATCH 02/62] pep8 compliance --- netbox/ipam/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/netbox/ipam/utils.py b/netbox/ipam/utils.py index 888a2ad1799..c457dc0686f 100644 --- a/netbox/ipam/utils.py +++ b/netbox/ipam/utils.py @@ -15,6 +15,7 @@ def add_available_prefixes(parent, prefix_list): return available_prefixes + def add_available_ipaddresses(prefix, ipaddress_list, is_pool=False): """ Annotate ranges of available IP addresses within a given prefix. If is_pool is True, the first and last IP will be From 80048bfa2b259b1f3dad5bf7ddefc7c1254ccd6a Mon Sep 17 00:00:00 2001 From: Will Irvine Date: Sat, 13 Nov 2021 16:42:38 +1300 Subject: [PATCH 03/62] Make the same changes for aggregate views as these use the same adjusted functions --- netbox/ipam/views.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 300f2f6d7d5..fc64eb73b08 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -213,7 +213,7 @@ class AggregateView(generic.ObjectView): def get_extra_context(self, request, instance): # Find all child prefixes contained by this aggregate - child_prefixes = Prefix.objects.restrict(request.user, 'view').filter( + child_prefixes_assigned = Prefix.objects.restrict(request.user, 'view').filter( prefix__net_contained_or_equal=str(instance.prefix) ).prefetch_related( 'site', 'role' @@ -221,9 +221,19 @@ def get_extra_context(self, request, instance): 'prefix' ) + # List to append filtered prefixes to + child_prefixes = [] + # Add available prefixes to the table if requested - if request.GET.get('show_available', 'true') == 'true': - child_prefixes = add_available_prefixes(instance.prefix, child_prefixes) + if child_prefixes_assigned and request.GET.get('show_available', 'true') == 'true': + child_prefixes = child_prefixes + add_available_prefixes(instance.prefix, child_prefixes_assigned) + + # Add assigned prefixes to the table if requested + if child_prefixes_assigned and request.GET.get('show_assigned', 'true') == 'true': + child_prefixes = child_prefixes + list(child_prefixes_assigned) + + # Sort child prefixes after additions + child_prefixes.sort(key=lambda p: p.prefix) prefix_table = tables.PrefixTable(child_prefixes, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): @@ -242,6 +252,7 @@ def get_extra_context(self, request, instance): 'permissions': permissions, 'bulk_querystring': f'within={instance.prefix}', 'show_available': request.GET.get('show_available', 'true') == 'true', + 'show_assigned': request.GET.get('show_assigned', 'true') == 'true', } From dcfd332cbfb2817b91ec744933291a718b3ebbdd Mon Sep 17 00:00:00 2001 From: Will Irvine Date: Wed, 1 Dec 2021 19:24:44 +1300 Subject: [PATCH 04/62] Moved filtering logic to utils, adjusted show buttons --- netbox/ipam/utils.py | 26 +++++++++--- netbox/ipam/views.py | 40 +++++-------------- .../templates/ipam/inc/toggle_available.html | 24 ++++------- 3 files changed, 37 insertions(+), 53 deletions(-) diff --git a/netbox/ipam/utils.py b/netbox/ipam/utils.py index c457dc0686f..3ec910edef5 100644 --- a/netbox/ipam/utils.py +++ b/netbox/ipam/utils.py @@ -4,16 +4,30 @@ from .models import Prefix, VLAN -def add_available_prefixes(parent, prefix_list): +def add_requested_prefixes(parent, prefix_list, request): """ - Create fake Prefix objects for all unallocated space within a prefix. + Return a list of requested prefixes using show_available, show_assigned filters. + If avalible prefixes are requested, create fake Prefix objects for all unallocated space within a prefix """ - # Find all unallocated space - available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list]) - available_prefixes = [Prefix(prefix=p, status=None) for p in available_prefixes.iter_cidrs()] + child_prefixes = [] - return available_prefixes + # Add available prefixes to the table if requested + if prefix_list and request.GET.get('show_available', 'true') == 'true': + + # Find all unallocated space, add fake Prefix objects to child_prefixes. + available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list]) + available_prefixes = [Prefix(prefix=p, status=None) for p in available_prefixes.iter_cidrs()] + child_prefixes = child_prefixes + available_prefixes + + # Add assigned prefixes to the table if requested + if prefix_list and request.GET.get('show_assigned', 'true') == 'true': + child_prefixes = child_prefixes + list(prefix_list) + + # Sort child prefixes after additions + child_prefixes.sort(key=lambda p: p.prefix) + + return child_prefixes def add_available_ipaddresses(prefix, ipaddress_list, is_pool=False): diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index fc64eb73b08..337c5cf8f0d 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -11,7 +11,7 @@ from . import filtersets, forms, tables from .constants import * from .models import * -from .utils import add_available_ipaddresses, add_available_prefixes, add_available_vlans +from .utils import add_available_ipaddresses, add_requested_prefixes, add_available_vlans # @@ -212,8 +212,8 @@ class AggregateView(generic.ObjectView): queryset = Aggregate.objects.all() def get_extra_context(self, request, instance): - # Find all child prefixes contained by this aggregate - child_prefixes_assigned = Prefix.objects.restrict(request.user, 'view').filter( + # Find all child prefixes contained in this aggregate + prefix_list = Prefix.objects.restrict(request.user, 'view').filter( prefix__net_contained_or_equal=str(instance.prefix) ).prefetch_related( 'site', 'role' @@ -221,19 +221,8 @@ def get_extra_context(self, request, instance): 'prefix' ) - # List to append filtered prefixes to - child_prefixes = [] - - # Add available prefixes to the table if requested - if child_prefixes_assigned and request.GET.get('show_available', 'true') == 'true': - child_prefixes = child_prefixes + add_available_prefixes(instance.prefix, child_prefixes_assigned) - - # Add assigned prefixes to the table if requested - if child_prefixes_assigned and request.GET.get('show_assigned', 'true') == 'true': - child_prefixes = child_prefixes + list(child_prefixes_assigned) - - # Sort child prefixes after additions - child_prefixes.sort(key=lambda p: p.prefix) + # Return List of requested Prefixes + child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, request) prefix_table = tables.PrefixTable(child_prefixes, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): @@ -404,24 +393,13 @@ class PrefixPrefixesView(generic.ObjectView): template_name = 'ipam/prefix/prefixes.html' def get_extra_context(self, request, instance): - # Initial pull of currently assigned child prefixes - child_prefixes_assigned = instance.get_child_prefixes().restrict(request.user, 'view').prefetch_related( + # Find all child prefixes contained in this prefix + prefix_list = instance.get_child_prefixes().restrict(request.user, 'view').prefetch_related( 'site', 'vlan', 'role', ) - # List to append filtered prefixes to - child_prefixes = [] - - # Add available prefixes to the table if requested - if child_prefixes_assigned and request.GET.get('show_available', 'true') == 'true': - child_prefixes = child_prefixes + add_available_prefixes(instance.prefix, child_prefixes_assigned) - - # Add assigned prefixes to the table if requested - if child_prefixes_assigned and request.GET.get('show_assigned', 'true') == 'true': - child_prefixes = child_prefixes + list(child_prefixes_assigned) - - # Sort child prefixes after additions - child_prefixes.sort(key=lambda p: p.prefix) + # Return List of requested Prefixes + child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, request) table = tables.PrefixTable(child_prefixes, user=request.user, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): diff --git a/netbox/templates/ipam/inc/toggle_available.html b/netbox/templates/ipam/inc/toggle_available.html index f0d286128e4..15ea19c984b 100644 --- a/netbox/templates/ipam/inc/toggle_available.html +++ b/netbox/templates/ipam/inc/toggle_available.html @@ -1,23 +1,15 @@ {% load helpers %} -{% if show_assigned is not None %} +{% if show_assigned or show_available is not None %} -{% endif %} - -{% if show_available is not None %} - -{% endif %} +{% endif %} \ No newline at end of file From ca07a886747f59f17b1034af3fa14acb14fa3065 Mon Sep 17 00:00:00 2001 From: Will Irvine Date: Thu, 2 Dec 2021 10:47:19 +1300 Subject: [PATCH 05/62] fix spelling... --- netbox/templates/ipam/inc/toggle_available.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/templates/ipam/inc/toggle_available.html b/netbox/templates/ipam/inc/toggle_available.html index 15ea19c984b..6c5b3319e3e 100644 --- a/netbox/templates/ipam/inc/toggle_available.html +++ b/netbox/templates/ipam/inc/toggle_available.html @@ -6,10 +6,10 @@ Show Assigned - Show Avaliable + Show Available Show All
-{% endif %} \ No newline at end of file +{% endif %} From 13414dcd25e2587bcf3c0f4fcc081dca176385d4 Mon Sep 17 00:00:00 2001 From: William Irvine <32685892+WillIrvine@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:13:54 +1300 Subject: [PATCH 06/62] pep8 compliance... --- netbox/ipam/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 46d0131d413..8f0610cc1cc 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -18,7 +18,6 @@ from .utils import add_available_ipaddresses, add_requested_prefixes, add_available_vlans - # # VRFs # From cc50e229283cacdc9dac59d5e96008461f1841a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Jonak-M=C3=B6chel?= Date: Tue, 7 Dec 2021 15:14:17 +0100 Subject: [PATCH 07/62] feat: add 6GHz & 60Ghz channels --- netbox/wireless/choices.py | 278 +++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) diff --git a/netbox/wireless/choices.py b/netbox/wireless/choices.py index c8e7fd09fda..2813eafd629 100644 --- a/netbox/wireless/choices.py +++ b/netbox/wireless/choices.py @@ -83,6 +83,143 @@ class WirelessChannelChoices(ChoiceSet): CHANNEL_5G_173 = '5g-173-5865-20' CHANNEL_5G_175 = '5g-175-5875-40' CHANNEL_5G_177 = '5g-177-5885-20' + + # 6 GHz + CHANNEL_6G_1 = '6g-1-5955-20' + CHANNEL_6G_3 = '6g-3-5955-40' + CHANNEL_6G_5 = '6g-5-5965-20' + CHANNEL_6G_7 = '6g-7-5975-80' + CHANNEL_6G_9 = '6g-9-5985-20' + CHANNEL_6G_11 = '6g-11-5995-40' + CHANNEL_6G_13 = '6g-13-6005-20' + CHANNEL_6G_15 = '6g-15-6015-160' + CHANNEL_6G_17 = '6g-17-6025-20' + CHANNEL_6G_19 = '6g-19-6035-40' + CHANNEL_6G_21 = '6g-21-6045-20' + CHANNEL_6G_23 = '6g-23-6055-80' + CHANNEL_6G_25 = '6g-25-6065-20' + CHANNEL_6G_28 = '6g-28-6080-40' + CHANNEL_6G_29 = '6g-29-6085-20' + CHANNEL_6G_31 = '6g-31-6095-320' + CHANNEL_6G_33 = '6g-33-6105-20' + CHANNEL_6G_36 = '6g-36-6120-40' + CHANNEL_6G_37 = '6g-37-6125-20' + CHANNEL_6G_39 = '6g-39-6135-80' + CHANNEL_6G_41 = '6g-41-6145-20' + CHANNEL_6G_44 = '6g-44-6160-40' + CHANNEL_6G_45 = '6g-45-6165-20' + CHANNEL_6G_47 = '6g-47-6175-160' + CHANNEL_6G_49 = '6g-49-6185-20' + CHANNEL_6G_52 = '6g-52-6200-40' + CHANNEL_6G_53 = '6g-53-6205-20' + CHANNEL_6G_55 = '6g-55-6215-80' + CHANNEL_6G_57 = '6g-57-6225-20' + CHANNEL_6G_60 = '6g-60-6240-40' + CHANNEL_6G_61 = '6g-61-6245-20' + CHANNEL_6G_65 = '6g-65-6265-20' + CHANNEL_6G_68 = '6g-68-6280-40' + CHANNEL_6G_69 = '6g-69-6285-20' + CHANNEL_6G_71 = '6g-71-6295-80' + CHANNEL_6G_73 = '6g-73-6305-20' + CHANNEL_6G_76 = '6g-76-6320-40' + CHANNEL_6G_77 = '6g-77-6325-20' + CHANNEL_6G_79 = '6g-79-6335-160' + CHANNEL_6G_81 = '6g-81-6345-20' + CHANNEL_6G_84 = '6g-84-6360-40' + CHANNEL_6G_85 = '6g-85-6365-20' + CHANNEL_6G_87 = '6g-87-6375-80' + CHANNEL_6G_89 = '6g-89-6385-20' + CHANNEL_6G_92 = '6g-92-6400-40' + CHANNEL_6G_93 = '6g-93-6405-20' + CHANNEL_6G_95 = '6g-95-6415-320' + CHANNEL_6G_97 = '6g-97-6425-20' + CHANNEL_6G_100 = '6g-100-6440-40' + CHANNEL_6G_101 = '6g-101-6445-20' + CHANNEL_6G_103 = '6g-103-6455-80' + CHANNEL_6G_105 = '6g-105-6465-20' + CHANNEL_6G_108 = '6g-108-6480-40' + CHANNEL_6G_109 = '6g-109-6485-20' + CHANNEL_6G_111 = '6g-111-6495-160' + CHANNEL_6G_113 = '6g-113-6505-20' + CHANNEL_6G_116 = '6g-116-6520-40' + CHANNEL_6G_117 = '6g-117-6525-20' + CHANNEL_6G_119 = '6g-119-6535-80' + CHANNEL_6G_121 = '6g-121-6545-20' + CHANNEL_6G_124 = '6g-124-6560-40' + CHANNEL_6G_125 = '6g-125-6565-20' + CHANNEL_6G_129 = '6g-129-6585-20' + CHANNEL_6G_132 = '6g-132-6600-40' + CHANNEL_6G_133 = '6g-133-6605-20' + CHANNEL_6G_135 = '6g-135-6615-80' + CHANNEL_6G_137 = '6g-137-6625-20' + CHANNEL_6G_140 = '6g-140-6640-40' + CHANNEL_6G_141 = '6g-141-6645-20' + CHANNEL_6G_143 = '6g-143-6655-160' + CHANNEL_6G_145 = '6g-145-6665-20' + CHANNEL_6G_148 = '6g-148-6680-40' + CHANNEL_6G_149 = '6g-149-6685-20' + CHANNEL_6G_151 = '6g-151-6695-80' + CHANNEL_6G_153 = '6g-153-6705-20' + CHANNEL_6G_156 = '6g-156-6720-40' + CHANNEL_6G_157 = '6g-157-6725-20' + CHANNEL_6G_159 = '6g-159-6735-320' + CHANNEL_6G_161 = '6g-161-6745-20' + CHANNEL_6G_164 = '6g-164-6760-40' + CHANNEL_6G_165 = '6g-165-6765-20' + CHANNEL_6G_167 = '6g-167-6775-80' + CHANNEL_6G_169 = '6g-169-6785-20' + CHANNEL_6G_172 = '6g-172-6800-40' + CHANNEL_6G_173 = '6g-173-6805-20' + CHANNEL_6G_175 = '6g-175-6815-160' + CHANNEL_6G_177 = '6g-177-6825-20' + CHANNEL_6G_180 = '6g-180-6840-40' + CHANNEL_6G_181 = '6g-181-6845-20' + CHANNEL_6G_183 = '6g-183-6855-80' + CHANNEL_6G_185 = '6g-185-6865-20' + CHANNEL_6G_188 = '6g-188-6880-40' + CHANNEL_6G_189 = '6g-189-6885-20' + CHANNEL_6G_193 = '6g-193-6905-20' + CHANNEL_6G_196 = '6g-196-6920-40' + CHANNEL_6G_197 = '6g-197-6925-20' + CHANNEL_6G_199 = '6g-199-6935-80' + CHANNEL_6G_201 = '6g-201-6945-20' + CHANNEL_6G_204 = '6g-204-6960-40' + CHANNEL_6G_205 = '6g-205-6965-20' + CHANNEL_6G_207 = '6g-207-6975-160' + CHANNEL_6G_209 = '6g-209-6985-20' + CHANNEL_6G_212 = '6g-212-7000-40' + CHANNEL_6G_213 = '6g-213-7005-20' + CHANNEL_6G_215 = '6g-215-7015-80' + CHANNEL_6G_217 = '6g-217-7025-20' + CHANNEL_6G_220 = '6g-220-7040-40' + CHANNEL_6G_221 = '6g-221-7045-20' + CHANNEL_6G_225 = '6g-225-7065-20' + CHANNEL_6G_228 = '6g-228-7080-40' + CHANNEL_6G_229 = '6g-229-7085-20' + CHANNEL_6G_233 = '6g-233-7105-20' + + + # 60 GHz + CHANNEL_60G_1 = '60g-1-58320-2160' + CHANNEL_60G_2 = '60g-2-60480-2160' + CHANNEL_60G_3 = '60g-3-62640-2160' + CHANNEL_60G_4 = '60g-4-64800-2160' + CHANNEL_60G_5 = '60g-5-66960-2160' + CHANNEL_60G_6 = '60g-6-69120-2160' + CHANNEL_60G_9 = '60g-9-59400-4320' + CHANNEL_60G_10 = '60g-10-61560-4320' + CHANNEL_60G_11 = '60g-11-63720-4320' + CHANNEL_60G_12 = '60g-12-65880-4320' + CHANNEL_60G_13 = '60g-13-68040-4320' + CHANNEL_60G_17 = '60g-17-60480-6480' + CHANNEL_60G_18 = '60g-18-62640-6480' + CHANNEL_60G_19 = '60g-19-64800-6480' + CHANNEL_60G_20 = '60g-20-66960-6480' + CHANNEL_60G_25 = '60g-25-61560-6480' + CHANNEL_60G_26 = '60g-26-63720-6480' + CHANNEL_60G_27 = '60g-27-65880-6480' + + CHOICES = ( ( @@ -162,6 +299,147 @@ class WirelessChannelChoices(ChoiceSet): (CHANNEL_5G_177, '177 (5885/20 MHz)'), ) ), + ( + '6 GHz (802.11ax)', + ( + (CHANNEL_6G_1, '1 (5945/20 MHz)'), + (CHANNEL_6G_3, '3 (5955/40 MHz)'), + (CHANNEL_6G_5, '5 (5965/20 MHz)'), + (CHANNEL_6G_7, '7 (5975/80 MHz)'), + (CHANNEL_6G_9, '9 (5985/20 MHz)'), + (CHANNEL_6G_11, '11 (5995/40 MHz)'), + (CHANNEL_6G_13, '13 (6005/20 MHz)'), + (CHANNEL_6G_15, '15 (6015/160 MHz)'), + (CHANNEL_6G_17, '17 (6025/20 MHz)'), + (CHANNEL_6G_19, '19 (6035/40 MHz)'), + (CHANNEL_6G_21, '21 (6045/20 MHz)'), + (CHANNEL_6G_23, '23 (6055/80 MHz)'), + (CHANNEL_6G_25, '25 (6065/20 MHz)'), + (CHANNEL_6G_28, '28 (6080/40 MHz)'), + (CHANNEL_6G_29, '29 (6085/20 MHz)'), + (CHANNEL_6G_31, '31 (6095/320 MHz)'), + (CHANNEL_6G_33, '33 (6105/20 MHz)'), + (CHANNEL_6G_36, '36 (6120/40 MHz)'), + (CHANNEL_6G_37, '37 (6125/20 MHz)'), + (CHANNEL_6G_39, '39 (6135/80 MHz)'), + (CHANNEL_6G_41, '41 (6145/20 MHz)'), + (CHANNEL_6G_44, '44 (6160/40 MHz)'), + (CHANNEL_6G_45, '45 (6165/20 MHz)'), + (CHANNEL_6G_47, '47 (6175/160 MHz)'), + (CHANNEL_6G_49, '49 (6185/20 MHz)'), + (CHANNEL_6G_52, '52 (6200/40 MHz)'), + (CHANNEL_6G_53, '53 (6205/20 MHz)'), + (CHANNEL_6G_55, '55 (6215/80 MHz)'), + (CHANNEL_6G_57, '57 (6225/20 MHz)'), + (CHANNEL_6G_60, '60 (6240/40 MHz)'), + (CHANNEL_6G_61, '61 (6245/20 MHz)'), + (CHANNEL_6G_65, '65 (6265/20 MHz)'), + (CHANNEL_6G_68, '68 (6280/40 MHz)'), + (CHANNEL_6G_69, '69 (6285/20 MHz)'), + (CHANNEL_6G_71, '71 (6295/80 MHz)'), + (CHANNEL_6G_73, '73 (6305/20 MHz)'), + (CHANNEL_6G_76, '76 (6320/40 MHz)'), + (CHANNEL_6G_77, '77 (6325/20 MHz)'), + (CHANNEL_6G_79, '79 (6335/160 MHz)'), + (CHANNEL_6G_81, '81 (6345/20 MHz)'), + (CHANNEL_6G_84, '84 (6360/40 MHz)'), + (CHANNEL_6G_85, '85 (6365/20 MHz)'), + (CHANNEL_6G_87, '87 (6375/80 MHz)'), + (CHANNEL_6G_89, '89 (6385/20 MHz)'), + (CHANNEL_6G_92, '92 (6400/40 MHz)'), + (CHANNEL_6G_93, '93 (6405/20 MHz)'), + (CHANNEL_6G_95, '95 (6415/320 MHz)'), + (CHANNEL_6G_97, '97 (6425/20 MHz)'), + (CHANNEL_6G_100, '100 (6440/40 MHz)'), + (CHANNEL_6G_101, '101 (6445/20 MHz)'), + (CHANNEL_6G_103, '103 (6455/80 MHz)'), + (CHANNEL_6G_105, '105 (6465/20 MHz)'), + (CHANNEL_6G_108, '108 (6480/40 MHz)'), + (CHANNEL_6G_109, '109 (6485/20 MHz)'), + (CHANNEL_6G_111, '111 (6495/160 MHz)'), + (CHANNEL_6G_113, '113 (6505/20 MHz)'), + (CHANNEL_6G_116, '116 (6520/40 MHz)'), + (CHANNEL_6G_117, '117 (6525/20 MHz)'), + (CHANNEL_6G_119, '119 (6535/80 MHz)'), + (CHANNEL_6G_121, '121 (6545/20 MHz)'), + (CHANNEL_6G_124, '124 (6560/40 MHz)'), + (CHANNEL_6G_125, '125 (6565/20 MHz)'), + (CHANNEL_6G_129, '129 (6585/20 MHz)'), + (CHANNEL_6G_132, '132 (6600/40 MHz)'), + (CHANNEL_6G_133, '133 (6605/20 MHz)'), + (CHANNEL_6G_135, '135 (6615/80 MHz)'), + (CHANNEL_6G_137, '137 (6625/20 MHz)'), + (CHANNEL_6G_140, '140 (6640/40 MHz)'), + (CHANNEL_6G_141, '141 (6645/20 MHz)'), + (CHANNEL_6G_143, '143 (6655/160 MHz)'), + (CHANNEL_6G_145, '145 (6665/20 MHz)'), + (CHANNEL_6G_148, '148 (6680/40 MHz)'), + (CHANNEL_6G_149, '149 (6685/20 MHz)'), + (CHANNEL_6G_151, '151 (6695/80 MHz)'), + (CHANNEL_6G_153, '153 (6705/20 MHz)'), + (CHANNEL_6G_156, '156 (6720/40 MHz)'), + (CHANNEL_6G_157, '157 (6725/20 MHz)'), + (CHANNEL_6G_159, '159 (6735/320 MHz)'), + (CHANNEL_6G_161, '161 (6745/20 MHz)'), + (CHANNEL_6G_164, '164 (6760/40 MHz)'), + (CHANNEL_6G_165, '165 (6765/20 MHz)'), + (CHANNEL_6G_167, '167 (6775/80 MHz)'), + (CHANNEL_6G_169, '169 (6785/20 MHz)'), + (CHANNEL_6G_172, '172 (6800/40 MHz)'), + (CHANNEL_6G_173, '173 (6805/20 MHz)'), + (CHANNEL_6G_175, '175 (6815/160 MHz)'), + (CHANNEL_6G_177, '177 (6825/20 MHz)'), + (CHANNEL_6G_180, '180 (6840/40 MHz)'), + (CHANNEL_6G_181, '181 (6845/20 MHz)'), + (CHANNEL_6G_183, '183 (6855/80 MHz)'), + (CHANNEL_6G_185, '185 (6865/20 MHz)'), + (CHANNEL_6G_188, '188 (6880/40 MHz)'), + (CHANNEL_6G_189, '189 (6885/20 MHz)'), + (CHANNEL_6G_193, '193 (6905/20 MHz)'), + (CHANNEL_6G_196, '196 (6920/40 MHz)'), + (CHANNEL_6G_197, '197 (6925/20 MHz)'), + (CHANNEL_6G_199, '199 (6935/80 MHz)'), + (CHANNEL_6G_201, '201 (6945/20 MHz)'), + (CHANNEL_6G_204, '204 (6960/40 MHz)'), + (CHANNEL_6G_205, '205 (6965/20 MHz)'), + (CHANNEL_6G_207, '207 (6975/160 MHz)'), + (CHANNEL_6G_209, '209 (6985/20 MHz)'), + (CHANNEL_6G_212, '212 (7000/40 MHz)'), + (CHANNEL_6G_213, '213 (7005/20 MHz)'), + (CHANNEL_6G_215, '215 (7015/80 MHz)'), + (CHANNEL_6G_217, '217 (7025/20 MHz)'), + (CHANNEL_6G_220, '220 (7040/40 MHz)'), + (CHANNEL_6G_221, '221 (7045/20 MHz)'), + (CHANNEL_6G_225, '225 (7065/20 MHz)'), + (CHANNEL_6G_228, '228 (7080/40 MHz)'), + (CHANNEL_6G_229, '229 (7085/20 MHz)'), + (CHANNEL_6G_233, '233 (7105/20 MHz)'), + + ) + ), + ( + '60 GHz (802.11ad/ay)', + ( + (CHANNEL_60G_1, '1 (58.32/2.16 GHz)'), + (CHANNEL_60G_2, '2 (60.48/2.16 GHz)'), + (CHANNEL_60G_3, '3 (62.64/2.16 GHz)'), + (CHANNEL_60G_4, '4 (64.80/2.16 GHz)'), + (CHANNEL_60G_5, '5 (66.96/2.16 GHz)'), + (CHANNEL_60G_6, '6 (69.12/2.16 GHz)'), + (CHANNEL_60G_9, '9 (59.40/4.32 GHz)'), + (CHANNEL_60G_10, '10 (61.56/4.32 GHz)'), + (CHANNEL_60G_11, '11 (63.72/4.32 GHz)'), + (CHANNEL_60G_12, '12 (65.88/4.32 GHz)'), + (CHANNEL_60G_13, '13 (68.04/4.32 GHz)'), + (CHANNEL_60G_17, '17 (60.48/6.48 GHz)'), + (CHANNEL_60G_18, '18 (62.64/6.48 GHz)'), + (CHANNEL_60G_19, '19 (64.80/6.48 GHz)'), + (CHANNEL_60G_20, '20 (66.96/6.48 GHz)'), + (CHANNEL_60G_25, '25 (61.56/8.64 GHz)'), + (CHANNEL_60G_26, '26 (63.72/8.64 GHz)'), + (CHANNEL_60G_27, '27 (65.88/8.64 GHz)'), + ) + ), ) From e9549ab0bd9f8a2447ccfc644749dccebb2284d3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Dec 2021 09:16:55 -0500 Subject: [PATCH 08/62] PRVB --- netbox/netbox/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 1f0745c2b75..10a30b282a6 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -19,7 +19,7 @@ # Environment setup # -VERSION = '3.1.1' +VERSION = '3.1.2-dev' # Hostname HOSTNAME = platform.node() From b6d93b7c5b39d4f778eda6b221c6ec3d5ac21362 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Dec 2021 12:10:03 -0500 Subject: [PATCH 09/62] Changelog for #7665 --- docs/release-notes/version-3.1.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 0224b9c1589..b65a2a77697 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -1,5 +1,13 @@ # NetBox v3.1 +## v3.1.2 (FUTURE) + +### Enhancements + +* [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes + +--- + ## v3.1.1 (2021-12-13) ### Enhancements From afc866eee4d5fca5ff29e5c95f25b7384174da6c Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Dec 2021 12:15:43 -0500 Subject: [PATCH 10/62] #7665: Refactored add_requested_prefixes(); removed button icons --- netbox/ipam/utils.py | 16 ++++++++++------ netbox/ipam/views.py | 16 ++++++++++------ netbox/templates/ipam/inc/toggle_available.html | 12 ++++++------ 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/netbox/ipam/utils.py b/netbox/ipam/utils.py index 3ec910edef5..97da9e4fed6 100644 --- a/netbox/ipam/utils.py +++ b/netbox/ipam/utils.py @@ -4,16 +4,20 @@ from .models import Prefix, VLAN -def add_requested_prefixes(parent, prefix_list, request): - """ - Return a list of requested prefixes using show_available, show_assigned filters. - If avalible prefixes are requested, create fake Prefix objects for all unallocated space within a prefix +def add_requested_prefixes(parent, prefix_list, show_available=True, show_assigned=True): """ + Return a list of requested prefixes using show_available, show_assigned filters. If available prefixes are + requested, create fake Prefix objects for all unallocated space within a prefix. + :param parent: Parent Prefix instance + :param prefix_list: Child prefixes list + :param show_available: Include available prefixes. + :param show_assigned: Show assigned prefixes. + """ child_prefixes = [] # Add available prefixes to the table if requested - if prefix_list and request.GET.get('show_available', 'true') == 'true': + if prefix_list and show_available: # Find all unallocated space, add fake Prefix objects to child_prefixes. available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list]) @@ -21,7 +25,7 @@ def add_requested_prefixes(parent, prefix_list, request): child_prefixes = child_prefixes + available_prefixes # Add assigned prefixes to the table if requested - if prefix_list and request.GET.get('show_assigned', 'true') == 'true': + if prefix_list and show_assigned: child_prefixes = child_prefixes + list(prefix_list) # Sort child prefixes after additions diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 8f0610cc1cc..e2a6be7feac 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -285,7 +285,9 @@ def get_extra_context(self, request, instance): ) # Return List of requested Prefixes - child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, request) + show_available = bool(request.GET.get('show_available', 'true') == 'true') + show_assigned = bool(request.GET.get('show_assigned', 'true') == 'true') + child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, show_available, show_assigned) prefix_table = tables.PrefixTable(child_prefixes, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): @@ -303,8 +305,8 @@ def get_extra_context(self, request, instance): 'prefix_table': prefix_table, 'permissions': permissions, 'bulk_querystring': f'within={instance.prefix}', - 'show_available': request.GET.get('show_available', 'true') == 'true', - 'show_assigned': request.GET.get('show_assigned', 'true') == 'true', + 'show_available': show_available, + 'show_assigned': show_assigned, } @@ -462,7 +464,9 @@ def get_extra_context(self, request, instance): ) # Return List of requested Prefixes - child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, request) + show_available = bool(request.GET.get('show_available', 'true') == 'true') + show_assigned = bool(request.GET.get('show_assigned', 'true') == 'true') + child_prefixes = add_requested_prefixes(instance.prefix, prefix_list, show_available, show_assigned) table = tables.PrefixTable(child_prefixes, user=request.user, exclude=('utilization',)) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): @@ -483,8 +487,8 @@ def get_extra_context(self, request, instance): 'bulk_querystring': bulk_querystring, 'active_tab': 'prefixes', 'first_available_prefix': instance.get_first_available_prefix(), - 'show_available': request.GET.get('show_available', 'true') == 'true', - 'show_assigned': request.GET.get('show_assigned', 'true') == 'true', + 'show_available': show_available, + 'show_assigned': show_assigned, } diff --git a/netbox/templates/ipam/inc/toggle_available.html b/netbox/templates/ipam/inc/toggle_available.html index 6c5b3319e3e..ccdc4566823 100644 --- a/netbox/templates/ipam/inc/toggle_available.html +++ b/netbox/templates/ipam/inc/toggle_available.html @@ -2,14 +2,14 @@ {% if show_assigned or show_available is not None %} {% endif %} From dc1331e736c0317ebc52af64416906b176f4e2c7 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Dec 2021 13:42:59 -0500 Subject: [PATCH 11/62] Fixes #7674: Fix inadvertent application of device type context to virtual machines --- docs/release-notes/version-3.1.md | 4 ++++ netbox/extras/querysets.py | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index b65a2a77697..83dffd12118 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -6,6 +6,10 @@ * [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes +### Bug Fixes + +* [#7674](https://github.com/netbox-community/netbox/issues/7674) - Fix inadvertent application of device type context to virtual machines + --- ## v3.1.1 (2021-12-13) diff --git a/netbox/extras/querysets.py b/netbox/extras/querysets.py index be5ae64167c..59d16fff850 100644 --- a/netbox/extras/querysets.py +++ b/netbox/extras/querysets.py @@ -22,7 +22,7 @@ def get_for_object(self, obj, aggregate_data=False): # Device type assignment is relevant only for Devices device_type = getattr(obj, 'device_type', None) - # Cluster assignment is relevant only for VirtualMachines + # Get assigned Cluster and ClusterGroup, if any cluster = getattr(obj, 'cluster', None) cluster_group = getattr(cluster, 'group', None) @@ -67,11 +67,8 @@ class ConfigContextModelQuerySet(RestrictedQuerySet): Includes a method which appends an annotation of aggregated config context JSON data objects. This is implemented as a subquery which performs all the joins necessary to filter relevant config context objects. This offers a substantial performance gain over ConfigContextQuerySet.get_for_object() when dealing with - multiple objects. - - This allows the annotation to be entirely optional. + multiple objects. This allows the annotation to be entirely optional. """ - def annotate_config_context_data(self): """ Attach the subquery annotation to the base queryset @@ -123,6 +120,7 @@ def _get_config_context_filters(self): elif self.model._meta.model_name == 'virtualmachine': base_query.add((Q(roles=OuterRef('role')) | Q(roles=None)), Q.AND) base_query.add((Q(sites=OuterRef('cluster__site')) | Q(sites=None)), Q.AND) + base_query.add(Q(device_types=None), Q.AND) region_field = 'cluster__site__region' sitegroup_field = 'cluster__site__group' From c50dc1eb353cd79da88a4379b96a39529835656e Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Dec 2021 15:36:51 -0500 Subject: [PATCH 12/62] Standardize usage of table template --- netbox/templates/circuits/circuittype.html | 5 +- netbox/templates/circuits/provider.html | 5 +- .../templates/circuits/providernetwork.html | 5 +- .../templates/dcim/device/consoleports.html | 4 +- .../dcim/device/consoleserverports.html | 4 +- netbox/templates/dcim/device/devicebays.html | 4 +- netbox/templates/dcim/device/frontports.html | 4 +- netbox/templates/dcim/device/interfaces.html | 4 +- netbox/templates/dcim/device/inventory.html | 4 +- .../templates/dcim/device/poweroutlets.html | 4 +- netbox/templates/dcim/device/powerports.html | 4 +- netbox/templates/dcim/device/rearports.html | 4 +- netbox/templates/dcim/devicerole.html | 5 +- netbox/templates/dcim/interface.html | 2 +- netbox/templates/dcim/location.html | 5 +- netbox/templates/dcim/manufacturer.html | 5 +- netbox/templates/dcim/platform.html | 5 +- netbox/templates/dcim/powerpanel.html | 2 +- netbox/templates/dcim/rackrole.html | 5 +- netbox/templates/dcim/region.html | 9 ++- netbox/templates/dcim/sitegroup.html | 9 ++- netbox/templates/extras/object_changelog.html | 4 +- netbox/templates/extras/object_journal.html | 4 +- .../generic/object_bulk_add_component.html | 5 +- .../templates/generic/object_bulk_delete.html | 5 +- .../templates/generic/object_bulk_edit.html | 5 +- .../templates/generic/object_bulk_remove.html | 5 +- netbox/templates/inc/panel_table.html | 8 +- netbox/templates/inc/table.html | 76 +++++++++---------- netbox/templates/ipam/asn.html | 5 +- netbox/templates/ipam/fhrpgroup.html | 4 +- netbox/templates/ipam/ipaddress.html | 4 +- netbox/templates/ipam/rir.html | 5 +- netbox/templates/ipam/role.html | 5 +- netbox/templates/ipam/vlangroup.html | 2 +- netbox/templates/tenancy/contact.html | 2 +- netbox/templates/tenancy/contactgroup.html | 9 ++- netbox/templates/tenancy/contactrole.html | 5 +- netbox/templates/tenancy/tenantgroup.html | 5 +- .../virtualization/clustergroup.html | 5 +- .../templates/virtualization/clustertype.html | 5 +- .../virtualmachine/interfaces.html | 4 +- .../templates/virtualization/vminterface.html | 2 +- netbox/templates/wireless/wirelesslan.html | 5 +- .../templates/wireless/wirelesslangroup.html | 5 +- 45 files changed, 167 insertions(+), 115 deletions(-) diff --git a/netbox/templates/circuits/circuittype.html b/netbox/templates/circuits/circuittype.html index 57737a6d153..67b6d2d86b9 100644 --- a/netbox/templates/circuits/circuittype.html +++ b/netbox/templates/circuits/circuittype.html @@ -1,6 +1,7 @@ {% extends 'generic/object.html' %} {% load helpers %} {% load plugins %} +{% load render_table from django_tables2 %} {% block content %}
@@ -42,8 +43,8 @@
Circuits
-
- {% include 'inc/table.html' with table=circuits_table %} +
+ {% render_table circuits_table 'inc/table.html' %}
{% if perms.circuits.add_circuit %}