mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
* Add fhrpgroup to IPAddressImportForm * Change fhrpgroup accessor to name * rename fhrpgroup to fhrp_group * Add fhrp_group to IPAddressTestCase csv_data
This commit is contained in:
parent
e186113cb3
commit
447e108d97
@ -327,6 +327,13 @@ class IPAddressImportForm(NetBoxModelImportForm):
|
|||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text=_('Assigned interface')
|
help_text=_('Assigned interface')
|
||||||
)
|
)
|
||||||
|
fhrp_group = CSVModelChoiceField(
|
||||||
|
label=_('FHRP Group'),
|
||||||
|
queryset=FHRPGroup.objects.all(),
|
||||||
|
required=False,
|
||||||
|
to_field_name='name',
|
||||||
|
help_text=_('Assigned FHRP Group name')
|
||||||
|
)
|
||||||
is_primary = forms.BooleanField(
|
is_primary = forms.BooleanField(
|
||||||
label=_('Is primary'),
|
label=_('Is primary'),
|
||||||
help_text=_('Make this the primary IP for the assigned device'),
|
help_text=_('Make this the primary IP for the assigned device'),
|
||||||
@ -341,8 +348,8 @@ class IPAddressImportForm(NetBoxModelImportForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = IPAddress
|
model = IPAddress
|
||||||
fields = [
|
fields = [
|
||||||
'address', 'vrf', 'tenant', 'status', 'role', 'device', 'virtual_machine', 'interface', 'is_primary',
|
'address', 'vrf', 'tenant', 'status', 'role', 'device', 'virtual_machine', 'interface', 'fhrp_group',
|
||||||
'is_oob', 'dns_name', 'description', 'comments', 'tags',
|
'is_primary', 'is_oob', 'dns_name', 'description', 'comments', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, data=None, *args, **kwargs):
|
def __init__(self, data=None, *args, **kwargs):
|
||||||
@ -398,6 +405,8 @@ class IPAddressImportForm(NetBoxModelImportForm):
|
|||||||
# Set interface assignment
|
# Set interface assignment
|
||||||
if self.cleaned_data.get('interface'):
|
if self.cleaned_data.get('interface'):
|
||||||
self.instance.assigned_object = self.cleaned_data['interface']
|
self.instance.assigned_object = self.cleaned_data['interface']
|
||||||
|
if self.cleaned_data.get('fhrp_group'):
|
||||||
|
self.instance.assigned_object = self.cleaned_data['fhrp_group']
|
||||||
|
|
||||||
ipaddress = super().save(*args, **kwargs)
|
ipaddress = super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -666,6 +666,24 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
|
|
||||||
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
|
fhrp_groups = (
|
||||||
|
FHRPGroup(
|
||||||
|
name='FHRP Group 1',
|
||||||
|
protocol=FHRPGroupProtocolChoices.PROTOCOL_HSRP,
|
||||||
|
group_id=10
|
||||||
|
),
|
||||||
|
FHRPGroup(
|
||||||
|
name='FHRP Group 2',
|
||||||
|
protocol=FHRPGroupProtocolChoices.PROTOCOL_HSRP,
|
||||||
|
group_id=20
|
||||||
|
),
|
||||||
|
FHRPGroup(
|
||||||
|
name='FHRP Group 3',
|
||||||
|
protocol=FHRPGroupProtocolChoices.PROTOCOL_HSRP,
|
||||||
|
group_id=30
|
||||||
|
),
|
||||||
|
)
|
||||||
|
FHRPGroup.objects.bulk_create(fhrp_groups)
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'vrf': vrfs[1].pk,
|
'vrf': vrfs[1].pk,
|
||||||
'address': IPNetwork('192.0.2.99/24'),
|
'address': IPNetwork('192.0.2.99/24'),
|
||||||
@ -679,10 +697,10 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
"vrf,address,status",
|
"vrf,address,status,fhrp_group",
|
||||||
"VRF 1,192.0.2.4/24,active",
|
"VRF 1,192.0.2.4/24,active,FHRP Group 1",
|
||||||
"VRF 1,192.0.2.5/24,active",
|
"VRF 1,192.0.2.5/24,active,FHRP Group 2",
|
||||||
"VRF 1,192.0.2.6/24,active",
|
"VRF 1,192.0.2.6/24,active,FHRP Group 3",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.csv_update_data = (
|
cls.csv_update_data = (
|
||||||
|
Loading…
Reference in New Issue
Block a user