Pārlūkot izejas kodu

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

Jeremy Stretch 5 gadi atpakaļ
vecāks
revīzija
aa38dcf490

+ 8 - 0
docs/release-notes/version-2.7.md

@@ -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

+ 4 - 4
netbox/ipam/forms.py

@@ -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.',
         }
         }

+ 9 - 8
netbox/ipam/tests/test_views.py

@@ -180,10 +180,10 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
         }
         }
 
 
         cls.csv_data = (
         cls.csv_data = (
-            "prefix,status",
-            "10.4.0.0/16,Active",
-            "10.5.0.0/16,Active",
-            "10.6.0.0/16,Active",
+            "vrf,prefix,status",
+            "VRF 1,10.4.0.0/16,Active",
+            "VRF 1,10.5.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",
-            "192.0.2.4/24,Active",
-            "192.0.2.5/24,Active",
-            "192.0.2.6/24,Active",
+            "vrf,address,status",
+            "VRF 1,192.0.2.4/24,Active",
+            "VRF 1,192.0.2.5/24,Active",
+            "VRF 1,192.0.2.6/24,Active",
         )
         )
 
 
         cls.bulk_edit_data = {
         cls.bulk_edit_data = {