mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fixes #13293: Limit interface selector for IP address to current device/VM
This commit is contained in:
parent
69545fd82d
commit
0b7804c01c
@ -355,6 +355,15 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
|
||||
):
|
||||
self.initial['primary_for_parent'] = True
|
||||
|
||||
if type(instance.assigned_object) is Interface:
|
||||
self.fields['interface'].widget.add_query_params({
|
||||
'device_id': instance.assigned_object.device.pk,
|
||||
})
|
||||
elif type(instance.assigned_object) is VMInterface:
|
||||
self.fields['vminterface'].widget.add_query_params({
|
||||
'virtual_machine_id': instance.assigned_object.virtual_machine.pk,
|
||||
})
|
||||
|
||||
# Disable object assignment fields if the IP address is designated as primary
|
||||
if self.initial.get('primary_for_parent'):
|
||||
self.fields['interface'].disabled = True
|
||||
|
Loading…
Reference in New Issue
Block a user