|
@@ -435,13 +435,21 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|
|
'tags': [t.pk for t in tags],
|
|
'tags': [t.pk for t in tags],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- site = sites[0].pk
|
|
|
|
|
- cls.csv_data = (
|
|
|
|
|
- "vrf,prefix,status,scope_type,scope_id",
|
|
|
|
|
- f"VRF 1,10.4.0.0/16,active,dcim.site,{site}",
|
|
|
|
|
- f"VRF 1,10.5.0.0/16,active,dcim.site,{site}",
|
|
|
|
|
- f"VRF 1,10.6.0.0/16,active,dcim.site,{site}",
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ site = sites[0]
|
|
|
|
|
+ cls.csv_data = {
|
|
|
|
|
+ 'default': (
|
|
|
|
|
+ "vrf,prefix,status,scope_type,scope_id",
|
|
|
|
|
+ f"VRF 1,10.4.0.0/16,active,dcim.site,{site.pk}",
|
|
|
|
|
+ f"VRF 1,10.5.0.0/16,active,dcim.site,{site.pk}",
|
|
|
|
|
+ f"VRF 1,10.6.0.0/16,active,dcim.site,{site.pk}",
|
|
|
|
|
+ ),
|
|
|
|
|
+ 'scope_name': (
|
|
|
|
|
+ "vrf,prefix,status,scope_type,scope_name",
|
|
|
|
|
+ f"VRF 1,10.4.0.0/16,active,dcim.site,{site.name}",
|
|
|
|
|
+ f"VRF 1,10.5.0.0/16,active,dcim.site,{site.name}",
|
|
|
|
|
+ f"VRF 1,10.6.0.0/16,active,dcim.site,{site.name}",
|
|
|
|
|
+ ),
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
cls.csv_update_data = (
|
|
cls.csv_update_data = (
|
|
|
"id,description,status",
|
|
"id,description,status",
|
|
@@ -532,6 +540,32 @@ scope_id: {site.pk}
|
|
|
self.assertEqual(prefix.vlan.vid, 101)
|
|
self.assertEqual(prefix.vlan.vid, 101)
|
|
|
self.assertEqual(prefix.scope, site)
|
|
self.assertEqual(prefix.scope, site)
|
|
|
|
|
|
|
|
|
|
+ @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
|
|
|
|
+ def test_prefix_import_with_scope_name(self):
|
|
|
|
|
+ """
|
|
|
|
|
+ Test YAML-based import using scope_name instead of scope_id.
|
|
|
|
|
+ """
|
|
|
|
|
+ site = Site.objects.get(name='Site 1')
|
|
|
|
|
+ IMPORT_DATA = """
|
|
|
|
|
+prefix: 10.1.3.0/24
|
|
|
|
|
+status: active
|
|
|
|
|
+scope_type: dcim.site
|
|
|
|
|
+scope_name: Site 1
|
|
|
|
|
+"""
|
|
|
|
|
+ # Add all required permissions to the test user
|
|
|
|
|
+ self.add_permissions('ipam.view_prefix', 'ipam.add_prefix')
|
|
|
|
|
+
|
|
|
|
|
+ form_data = {
|
|
|
|
|
+ 'data': IMPORT_DATA,
|
|
|
|
|
+ 'format': 'yaml'
|
|
|
|
|
+ }
|
|
|
|
|
+ response = self.client.post(reverse('ipam:prefix_bulk_import'), data=form_data, follow=True)
|
|
|
|
|
+ self.assertHttpStatus(response, 200)
|
|
|
|
|
+
|
|
|
|
|
+ prefix = Prefix.objects.get(prefix='10.1.3.0/24')
|
|
|
|
|
+ self.assertEqual(prefix.status, PrefixStatusChoices.STATUS_ACTIVE)
|
|
|
|
|
+ self.assertEqual(prefix.scope, site)
|
|
|
|
|
+
|
|
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
|
|
def test_prefix_import_with_vlan_group(self):
|
|
def test_prefix_import_with_vlan_group(self):
|
|
|
"""
|
|
"""
|
|
@@ -884,12 +918,20 @@ class VLANGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
|
|
'tags': [t.pk for t in tags],
|
|
'tags': [t.pk for t in tags],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- cls.csv_data = (
|
|
|
|
|
- "name,slug,scope_type,scope_id,description",
|
|
|
|
|
- "VLAN Group 4,vlan-group-4,,,Fourth VLAN group",
|
|
|
|
|
- f"VLAN Group 5,vlan-group-5,dcim.site,{sites[0].pk},Fifth VLAN group",
|
|
|
|
|
- f"VLAN Group 6,vlan-group-6,dcim.site,{sites[1].pk},Sixth VLAN group",
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ cls.csv_data = {
|
|
|
|
|
+ 'default': (
|
|
|
|
|
+ "name,slug,scope_type,scope_id,description",
|
|
|
|
|
+ "VLAN Group 4,vlan-group-4,,,Fourth VLAN group",
|
|
|
|
|
+ f"VLAN Group 5,vlan-group-5,dcim.site,{sites[0].pk},Fifth VLAN group",
|
|
|
|
|
+ f"VLAN Group 6,vlan-group-6,dcim.site,{sites[1].pk},Sixth VLAN group",
|
|
|
|
|
+ ),
|
|
|
|
|
+ 'scope_name': (
|
|
|
|
|
+ "name,slug,scope_type,scope_name,description",
|
|
|
|
|
+ "VLAN Group 4,vlan-group-4,,,Fourth VLAN group",
|
|
|
|
|
+ f"VLAN Group 5,vlan-group-5,dcim.site,{sites[0].name},Fifth VLAN group",
|
|
|
|
|
+ f"VLAN Group 6,vlan-group-6,dcim.site,{sites[1].name},Sixth VLAN group",
|
|
|
|
|
+ ),
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
cls.csv_update_data = (
|
|
cls.csv_update_data = (
|
|
|
"id,name,description",
|
|
"id,name,description",
|