Fixes #21578: Enable assignment of scope object by name when bulk importing prefixes/VLAN groups (#21671)

This commit is contained in:
Jeremy Stretch
2026-03-13 19:27:26 -04:00
committed by GitHub
parent 9b57512b12
commit e28ed7446c
7 changed files with 153 additions and 43 deletions

View File

@@ -74,8 +74,8 @@ class ClusterImportForm(ScopedImportForm, PrimaryModelImportForm):
class Meta:
model = Cluster
fields = (
'name', 'type', 'group', 'status', 'scope_type', 'scope_id', 'tenant', 'description', 'owner', 'comments',
'tags',
'name', 'type', 'group', 'status', 'scope_type', 'scope_name', 'scope_id', 'tenant', 'description', 'owner',
'comments', 'tags',
)
labels = {
'scope_id': _('Scope ID'),

View File

@@ -157,12 +157,20 @@ class ClusterTestCase(ViewTestCases.PrimaryObjectViewTestCase):
'tags': [t.pk for t in tags],
}
cls.csv_data = (
"name,type,status",
"Cluster 4,Cluster Type 1,active",
"Cluster 5,Cluster Type 1,active",
"Cluster 6,Cluster Type 1,active",
)
cls.csv_data = {
'default': (
"name,type,status,scope_type,scope_id",
f"Cluster 4,Cluster Type 1,active,dcim.site,{sites[0].pk}",
f"Cluster 5,Cluster Type 1,active,dcim.site,{sites[0].pk}",
f"Cluster 6,Cluster Type 1,active,dcim.site,{sites[0].pk}",
),
'scope_name': (
"name,type,status,scope_type,scope_name",
f"Cluster 4,Cluster Type 1,active,dcim.site,{sites[0].name}",
f"Cluster 5,Cluster Type 1,active,dcim.site,{sites[0].name}",
f"Cluster 6,Cluster Type 1,active,dcim.site,{sites[0].name}",
),
}
cls.csv_update_data = (
"id,name,comments",