1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #14402: Avoid nullifying disk value when editing a VM with disk(s) attached

This commit is contained in:
Jeremy Stretch
2023-12-04 10:03:47 -05:00
parent c0512e2c36
commit 625825d482

View File

@ -200,7 +200,9 @@ class VirtualMachine(ContactsMixin, RenderConfigMixin, ConfigContextModel, Prima
# Validate aggregate disk size # Validate aggregate disk size
if self.pk: if self.pk:
total_disk = self.virtualdisks.aggregate(Sum('size', default=0))['size__sum'] total_disk = self.virtualdisks.aggregate(Sum('size', default=0))['size__sum']
if total_disk and self.disk != total_disk: if total_disk and self.disk is None:
self.disk = total_disk
elif total_disk and self.disk != total_disk:
raise ValidationError({ raise ValidationError({
'disk': _( 'disk': _(
"The specified disk size ({size}) must match the aggregate size of assigned virtual disks " "The specified disk size ({size}) must match the aggregate size of assigned virtual disks "