From 98272c29f7b54983258ff9474545fc6ddc9a6a92 Mon Sep 17 00:00:00 2001 From: Renato Almeida de Oliveira Zaroubin Date: Wed, 19 Mar 2025 02:00:36 +0000 Subject: [PATCH] Add fhrpgroup to IPAddressImportForm --- netbox/ipam/forms/bulk_import.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/netbox/ipam/forms/bulk_import.py b/netbox/ipam/forms/bulk_import.py index a672fd641..ae4178627 100644 --- a/netbox/ipam/forms/bulk_import.py +++ b/netbox/ipam/forms/bulk_import.py @@ -327,6 +327,13 @@ class IPAddressImportForm(NetBoxModelImportForm): to_field_name='name', help_text=_('Assigned interface') ) + fhrpgroup = CSVModelChoiceField( + label=_('FHRP Group (ID)'), + queryset=FHRPGroup.objects.all(), + required=False, + to_field_name='group_id', + help_text=_('Assigned FHRP Group ID') + ) is_primary = forms.BooleanField( label=_('Is primary'), help_text=_('Make this the primary IP for the assigned device'), @@ -341,8 +348,8 @@ class IPAddressImportForm(NetBoxModelImportForm): class Meta: model = IPAddress fields = [ - 'address', 'vrf', 'tenant', 'status', 'role', 'device', 'virtual_machine', 'interface', 'is_primary', - 'is_oob', 'dns_name', 'description', 'comments', 'tags', + 'address', 'vrf', 'tenant', 'status', 'role', 'device', 'virtual_machine', 'interface', 'fhrpgroup', + 'is_primary', 'is_oob', 'dns_name', 'description', 'comments', 'tags', ] def __init__(self, data=None, *args, **kwargs): @@ -398,6 +405,8 @@ class IPAddressImportForm(NetBoxModelImportForm): # Set interface assignment if self.cleaned_data.get('interface'): self.instance.assigned_object = self.cleaned_data['interface'] + if self.cleaned_data.get('fhrpgroup'): + self.instance.assigned_object = self.cleaned_data['fhrpgroup'] ipaddress = super().save(*args, **kwargs)