Merge pull request #558 from pcoder/task/4046/compute_hdd_sdd
Task/4046/Add sdd_size, hdd_size to VirtualMachineSerializer
This commit is contained in:
commit
b1099d20b9
1 changed files with 18 additions and 0 deletions
|
@ -49,6 +49,8 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
memory = serializers.SerializerMethodField()
|
memory = serializers.SerializerMethodField()
|
||||||
|
|
||||||
disk_size = serializers.SerializerMethodField()
|
disk_size = serializers.SerializerMethodField()
|
||||||
|
hdd_size = serializers.SerializerMethodField()
|
||||||
|
sdd_size = serializers.SerializerMethodField()
|
||||||
ipv4 = serializers.SerializerMethodField()
|
ipv4 = serializers.SerializerMethodField()
|
||||||
ipv6 = serializers.SerializerMethodField()
|
ipv6 = serializers.SerializerMethodField()
|
||||||
vm_id = serializers.IntegerField(read_only=True, source='id')
|
vm_id = serializers.IntegerField(read_only=True, source='id')
|
||||||
|
@ -102,6 +104,22 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
disk_size += int(disk.size)
|
disk_size += int(disk.size)
|
||||||
return disk_size / 1024
|
return disk_size / 1024
|
||||||
|
|
||||||
|
def get_sdd_size(self, obj):
|
||||||
|
template = obj.template
|
||||||
|
disk_size = 0
|
||||||
|
for disk in template.disks:
|
||||||
|
if disk.datastore == 'cephds':
|
||||||
|
disk_size += int(disk.size)
|
||||||
|
return disk_size / 1024
|
||||||
|
|
||||||
|
def get_hdd_size(self, obj):
|
||||||
|
template = obj.template
|
||||||
|
disk_size = 0
|
||||||
|
for disk in template.disks:
|
||||||
|
if disk.datastore == 'ceph_hdd_ds':
|
||||||
|
disk_size += int(disk.size)
|
||||||
|
return disk_size / 1024
|
||||||
|
|
||||||
def get_price(self, obj):
|
def get_price(self, obj):
|
||||||
template = obj.template
|
template = obj.template
|
||||||
price = float(template.vcpu) * 5.0
|
price = float(template.vcpu) * 5.0
|
||||||
|
|
Loading…
Reference in a new issue