mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-26 10:49:07 +02:00
Fixes #19745: properly check IP assignment to FHRPGroup
- Expands the logic in ServiceImportForm.clean() to handle properly validation of FHRPGroup assignments and maintain the existing [VM]Interface validation checks. - Includes an extension to ServiceTestCase.csv_data to act as a regression test for this behavior.
This commit is contained in:
committed by
Jeremy Stretch
parent
3ecf29d797
commit
0a9887b42f
@@ -633,7 +633,10 @@ class ServiceImportForm(NetBoxModelImportForm):
|
||||
# triggered
|
||||
parent = self.cleaned_data.get('parent')
|
||||
for ip_address in self.cleaned_data.get('ipaddresses', []):
|
||||
if not ip_address.assigned_object or getattr(ip_address.assigned_object, 'parent_object') != parent:
|
||||
if not (assigned := ip_address.assigned_object) or ( # no assigned object
|
||||
(isinstance(parent, FHRPGroup) and assigned != parent) # assigned to FHRPGroup
|
||||
and getattr(assigned, 'parent_object') != parent # assigned to [VM]Interface
|
||||
):
|
||||
raise forms.ValidationError(
|
||||
_("{ip} is not assigned to this parent.").format(ip=ip_address)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user