Closes #3676: Reference VRF by name rather than RD during IP/prefix import

This commit is contained in:
Jeremy Stretch 2020-03-30 15:54:35 -04:00
parent 5cf872d000
commit aa38dcf490
3 changed files with 21 additions and 12 deletions

View File

@ -1,5 +1,13 @@
# NetBox v2.7 Release Notes # NetBox v2.7 Release Notes
## v2.7.12 (FUTURE)
### Enhancements
* [#3676](https://github.com/netbox-community/netbox/issues/3676) - Reference VRF by name rather than RD during IP/prefix import
---
## v2.7.11 (2020-03-27) ## v2.7.11 (2020-03-27)
### Enhancements ### Enhancements

View File

@ -335,9 +335,9 @@ class PrefixForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class PrefixCSVForm(CustomFieldModelCSVForm): class PrefixCSVForm(CustomFieldModelCSVForm):
vrf = FlexibleModelChoiceField( vrf = FlexibleModelChoiceField(
queryset=VRF.objects.all(), queryset=VRF.objects.all(),
to_field_name='rd', to_field_name='name',
required=False, required=False,
help_text='Route distinguisher of parent VRF (or {ID})', help_text='Name of parent VRF (or {ID})',
error_messages={ error_messages={
'invalid_choice': 'VRF not found.', 'invalid_choice': 'VRF not found.',
} }
@ -739,9 +739,9 @@ class IPAddressBulkAddForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
class IPAddressCSVForm(CustomFieldModelCSVForm): class IPAddressCSVForm(CustomFieldModelCSVForm):
vrf = FlexibleModelChoiceField( vrf = FlexibleModelChoiceField(
queryset=VRF.objects.all(), queryset=VRF.objects.all(),
to_field_name='rd', to_field_name='name',
required=False, required=False,
help_text='Route distinguisher of parent VRF (or {ID})', help_text='Name of parent VRF (or {ID})',
error_messages={ error_messages={
'invalid_choice': 'VRF not found.', 'invalid_choice': 'VRF not found.',
} }

View File

@ -180,10 +180,10 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"prefix,status", "vrf,prefix,status",
"10.4.0.0/16,Active", "VRF 1,10.4.0.0/16,Active",
"10.5.0.0/16,Active", "VRF 1,10.5.0.0/16,Active",
"10.6.0.0/16,Active", "VRF 1,10.6.0.0/16,Active",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {
@ -207,6 +207,7 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
VRF(name='VRF 1', rd='65000:1'), VRF(name='VRF 1', rd='65000:1'),
VRF(name='VRF 2', rd='65000:2'), VRF(name='VRF 2', rd='65000:2'),
) )
VRF.objects.bulk_create(vrfs)
IPAddress.objects.bulk_create([ IPAddress.objects.bulk_create([
IPAddress(family=4, address=IPNetwork('192.0.2.1/24'), vrf=vrfs[0]), IPAddress(family=4, address=IPNetwork('192.0.2.1/24'), vrf=vrfs[0]),
@ -228,10 +229,10 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"address,status", "vrf,address,status",
"192.0.2.4/24,Active", "VRF 1,192.0.2.4/24,Active",
"192.0.2.5/24,Active", "VRF 1,192.0.2.5/24,Active",
"192.0.2.6/24,Active", "VRF 1,192.0.2.6/24,Active",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {