Add try and except for template disks

It turns out that some templates don't need a disk size if they use a
image.
This commit is contained in:
Modulos 2017-05-14 01:02:22 +02:00
parent aa8e886745
commit b8df86342a

View file

@ -50,9 +50,12 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
def get_disk_size(self, obj): def get_disk_size(self, obj):
template = obj.template template = obj.template
disk_size = 0 disk_size = 0
for disk in template.disks: try:
disk_size += int(disk.size) for disk in template.disks:
return disk_size / 1024 disk_size += int(disk.size)
return disk_size / 1024
except:
return 0
def get_price(self, obj): def get_price(self, obj):
template = obj.template template = obj.template