mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-19 11:52:22 -06:00
* Fixes #15717: Allow VM with Site to Cluster without Site * Fixes #15717: Allow VM with Site to Cluster without Site * Fixes #15717: Allow VM with Site to Cluster without Site * Fixes #15717: Allow VM with Site to Cluster without Site * Fixes #15717: Allow VM with Site to Cluster without Site
This commit is contained in:
@@ -178,8 +178,8 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
required=False,
|
||||
selector=True,
|
||||
query_params={
|
||||
'site_id': '$site',
|
||||
}
|
||||
'site_id': ['$site', 'null']
|
||||
},
|
||||
)
|
||||
device = DynamicModelChoiceField(
|
||||
label=_('Device'),
|
||||
|
||||
@@ -180,7 +180,7 @@ class VirtualMachine(ContactsMixin, ImageAttachmentsMixin, RenderConfigMixin, Co
|
||||
})
|
||||
|
||||
# Validate site for cluster & device
|
||||
if self.cluster and self.site and self.cluster.site != self.site:
|
||||
if self.cluster and self.cluster.site is not None and self.cluster.site != self.site:
|
||||
raise ValidationError({
|
||||
'cluster': _(
|
||||
'The selected cluster ({cluster}) is not assigned to this site ({site}).'
|
||||
|
||||
@@ -63,6 +63,9 @@ class VirtualMachineTestCase(TestCase):
|
||||
# VM with site only should pass
|
||||
VirtualMachine(name='vm1', site=sites[0]).full_clean()
|
||||
|
||||
# VM with site, cluster non-site should pass
|
||||
VirtualMachine(name='vm1', site=sites[0], cluster=clusters[2]).full_clean()
|
||||
|
||||
# VM with non-site cluster only should pass
|
||||
VirtualMachine(name='vm1', cluster=clusters[2]).full_clean()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user