Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.5.4 #12946

Merged
merged 30 commits into from
Jun 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4a88d5e
PRVB
jeremystretch Jun 2, 2023
01d9e0a
Round rack power utilization to nearest 0.1%
candlerb Jun 8, 2023
210879d
fix contact assignment table modal
abhi1693 Jun 11, 2023
82cd6c5
Fixes #12862 - Add Button for Wireless Links in Sidebar
sudheesh001 Jun 11, 2023
e785139
Merge pull request #12857 from netbox-community/fix/12850-contacts-table
jeremystretch Jun 12, 2023
43235f1
Merge pull request #12839 from candlerb/candlerb/12838
jeremystretch Jun 12, 2023
22a0ce3
broadcast error fixes for ipv6 and /31/32
ITJamie Jun 12, 2023
74c1f7a
Merge pull request #12874 from ITJamie/broadcast_exceptions
jeremystretch Jun 13, 2023
a81924a
Merge pull request #12863 from sudheesh001/fix/12862-connection-sideb…
jeremystretch Jun 13, 2023
2e95865
Changelog for #12687, #12838, #12850, #12862
jeremystretch Jun 13, 2023
96cf95d
fixes typo in register_model_view docstring #12824
abhi1693 Jun 14, 2023
928a346
change link parsing from quote_plus to quote #12822
abhi1693 Jun 14, 2023
c8cbced
fix permission #12818
abhi1693 Jun 14, 2023
d03bfe8
fix connected device api schema #12682
abhi1693 Jun 14, 2023
85e3511
Merge pull request #12897 from netbox-community/fix/12682-openapi-con…
jeremystretch Jun 14, 2023
55e31ef
Merge pull request #12896 from netbox-community/fix/12818-perm
jeremystretch Jun 14, 2023
28b939c
Merge pull request #12894 from netbox-community/fix/12822-link-encode
jeremystretch Jun 14, 2023
36e0bf0
Merge pull request #12893 from netbox-community/feat/12824-doc
jeremystretch Jun 14, 2023
c5f71c0
Fixes #12847 - Include Missing Add buttons to Views
sudheesh001 Jun 11, 2023
f7b0e48
Merge pull request #12864 from sudheesh001/fix/12847-include-adds
jeremystretch Jun 14, 2023
0e873a0
Closes #12622: Fix assigning VLAN without site to Prefix (#12784)
dhenschen Jun 14, 2023
4d686e8
Changelog for #12622, #12682, #12818, #12822, #12847
jeremystretch Jun 14, 2023
9317588
add color to ChangeActionChoices #12828
abhi1693 Jun 14, 2023
0b21625
12474 update cable terminations when moving location between sites
arthanson May 16, 2023
8aeb317
Fixes #12845: Fix pagination of related IP addresses table
jeremystretch Jun 14, 2023
7fc69f3
Fixes #12914: Clear stored ordering from user config when cleared by …
jeremystretch Jun 15, 2023
6ef333e
Fixes #12885: Permit mounting of devices in U100 (#12901)
jeremystretch Jun 15, 2023
e11991c
Fix #12865 - Include Add Nav Buttons for Report and Script Objects (#…
stuntguy3000 Jun 15, 2023
cdce500
Changelog for #12474, #12828, #12845, #12865, #12885, #12914
jeremystretch Jun 15, 2023
54622b5
Release v3.5.4
jeremystretch Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Closes #12622: Fix assigning VLAN without site to Prefix (#12784)
* Issue #12622: Fix creating Prefix using VLAN without site

* Issue #12622: Fix importing Prefix using VLAN without site

This commit also adds tests to verify the import changes implemented
in this commit.

* Issue #12622: Cleanup code to filter allowed VLANs on a prefix import

* Closes #12622: Switch to VLAN selector dialog when creating Prefix
dhenschen authored Jun 14, 2023
commit 0e873a01b8fa22face378db529cdb20df1702458
34 changes: 25 additions & 9 deletions netbox/ipam/forms/bulk_import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.utils.translation import gettext as _

from dcim.models import Device, Interface, Site
@@ -181,16 +182,31 @@ class Meta:
def __init__(self, data=None, *args, **kwargs):
super().__init__(data, *args, **kwargs)

if data:
if not data:
return

site = data.get('site')
vlan_group = data.get('vlan_group')

# Limit VLAN queryset by assigned site and/or group (if specified)
query = Q()

if site:
query |= Q(**{
f"site__{self.fields['site'].to_field_name}": site
})
# Don't Forget to include VLANs without a site in the filter
query |= Q(**{
f"site__{self.fields['site'].to_field_name}__isnull": True
})

if vlan_group:
query &= Q(**{
f"group__{self.fields['vlan_group'].to_field_name}": vlan_group
})

# Limit VLAN queryset by assigned site and/or group (if specified)
params = {}
if data.get('site'):
params[f"site__{self.fields['site'].to_field_name}"] = data.get('site')
if data.get('vlan_group'):
params[f"group__{self.fields['vlan_group'].to_field_name}"] = data.get('vlan_group')
if params:
self.fields['vlan'].queryset = self.fields['vlan'].queryset.filter(**params)
queryset = self.fields['vlan'].queryset.filter(query)
self.fields['vlan'].queryset = queryset


class IPRangeImportForm(NetBoxModelImportForm):
4 changes: 1 addition & 3 deletions netbox/ipam/forms/model_forms.py
Original file line number Diff line number Diff line change
@@ -211,10 +211,8 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
selector=True,
label=_('VLAN'),
query_params={
'site_id': '$site',
}
)
role = DynamicModelChoiceField(
queryset=Role.objects.all(),
59 changes: 59 additions & 0 deletions netbox/ipam/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -495,6 +495,65 @@ def test_prefix_ipaddresses(self):
url = reverse('ipam:prefix_ipaddresses', kwargs={'pk': prefix.pk})
self.assertHttpStatus(self.client.get(url), 200)

@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_prefix_import(self):
"""
Custom import test for YAML-based imports (versus CSV)
"""
IMPORT_DATA = """
prefix: 10.1.1.0/24
status: active
vlan: 101
site: Site 1
"""
# Note, a site is not tied to the VLAN to verify the fix for #12622
VLAN.objects.create(vid=101, name='VLAN101')

# Add all required permissions to the test user
self.add_permissions('ipam.view_prefix', 'ipam.add_prefix')

form_data = {
'data': IMPORT_DATA,
'format': 'yaml'
}
response = self.client.post(reverse('ipam:prefix_import'), data=form_data, follow=True)
self.assertHttpStatus(response, 200)

prefix = Prefix.objects.get(prefix='10.1.1.0/24')
self.assertEqual(prefix.status, PrefixStatusChoices.STATUS_ACTIVE)
self.assertEqual(prefix.vlan.vid, 101)
self.assertEqual(prefix.site.name, "Site 1")

@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_prefix_import_with_vlan_group(self):
"""
This test covers a unique import edge case where VLAN group is specified during the import.
"""
IMPORT_DATA = """
prefix: 10.1.2.0/24
status: active
vlan: 102
site: Site 1
vlan_group: Group 1
"""
vlan_group = VLANGroup.objects.create(name='Group 1', slug='group-1', scope=Site.objects.get(name="Site 1"))
VLAN.objects.create(vid=102, name='VLAN102', group=vlan_group)

# Add all required permissions to the test user
self.add_permissions('ipam.view_prefix', 'ipam.add_prefix')

form_data = {
'data': IMPORT_DATA,
'format': 'yaml'
}
response = self.client.post(reverse('ipam:prefix_import'), data=form_data, follow=True)
self.assertHttpStatus(response, 200)

prefix = Prefix.objects.get(prefix='10.1.2.0/24')
self.assertEqual(prefix.status, PrefixStatusChoices.STATUS_ACTIVE)
self.assertEqual(prefix.vlan.vid, 102)
self.assertEqual(prefix.site.name, "Site 1")


class IPRangeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = IPRange