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:
parent
aa8e886745
commit
b8df86342a
1 changed files with 6 additions and 3 deletions
|
@ -50,9 +50,12 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
|
|||
def get_disk_size(self, obj):
|
||||
template = obj.template
|
||||
disk_size = 0
|
||||
try:
|
||||
for disk in template.disks:
|
||||
disk_size += int(disk.size)
|
||||
return disk_size / 1024
|
||||
except:
|
||||
return 0
|
||||
|
||||
def get_price(self, obj):
|
||||
template = obj.template
|
||||
|
|
Loading…
Reference in a new issue