Fixes #10559: Permit the pinning of a VM to a particular device within a cluster which has no site assignment

This commit is contained in:
jeremystretch 2022-10-04 15:46:55 -04:00
parent fec8d1bc2f
commit 03946f2ca8
3 changed files with 5 additions and 8 deletions

View File

@ -23,6 +23,7 @@
* [#10491](https://github.com/netbox-community/netbox/issues/10491) - Clarify representation of blocking contact assignments during contact deletion
* [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device
* [#10517](https://github.com/netbox-community/netbox/issues/10517) - Automatically inherit site assignment from cluster when creating a virtual machine
* [#10559](https://github.com/netbox-community/netbox/issues/10559) - Permit the pinning of a VM to a particular device within a cluster which has no site assignment
---

View File

@ -21,7 +21,7 @@
</tr>
<tr>
<th scope="row">Group</th>
<td>{{ object.group|linkify }}</td>
<td>{{ object.group|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Tenant</th>
@ -34,7 +34,7 @@
</tr>
<tr>
<th scope="row">Site</th>
<td>{{ object.site|linkify }}</td>
<td>{{ object.site|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Virtual Machines</th>

View File

@ -349,14 +349,10 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
# Validate site for cluster & device
if self.cluster and self.site and self.cluster.site != self.site:
raise ValidationError({
'cluster': f'The selected cluster ({self.cluster} is not assigned to this site ({self.site}).'
'cluster': f'The selected cluster ({self.cluster}) is not assigned to this site ({self.site}).'
})
elif self.cluster:
self.site = self.cluster.site
if self.device and self.device.site != self.site:
raise ValidationError({
'device': f'The selected device ({self.device} is not assigned to this site ({self.site}).'
})
# Validate assigned cluster device
if self.device and not self.cluster:
@ -365,7 +361,7 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
})
if self.device and self.device not in self.cluster.devices.all():
raise ValidationError({
'device': f'The selected device ({self.device} is not assigned to this cluster ({self.cluster}).'
'device': f'The selected device ({self.device}) is not assigned to this cluster ({self.cluster}).'
})
# Validate primary IP addresses