Change cores to SerializerMethodField and obtain it from cpu
This commit is contained in:
parent
46c3bb1ce4
commit
78738e8175
1 changed files with 4 additions and 1 deletions
|
@ -46,7 +46,7 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
"""Serializer to map the virtual machine instance into JSON format."""
|
"""Serializer to map the virtual machine instance into JSON format."""
|
||||||
|
|
||||||
name = serializers.SerializerMethodField()
|
name = serializers.SerializerMethodField()
|
||||||
cores = serializers.IntegerField(source='template.vcpu')
|
cores = serializers.SerializerMethodField()
|
||||||
disk = serializers.IntegerField(write_only=True)
|
disk = serializers.IntegerField(write_only=True)
|
||||||
set_memory = serializers.IntegerField(write_only=True, label='Memory')
|
set_memory = serializers.IntegerField(write_only=True, label='Memory')
|
||||||
memory = serializers.SerializerMethodField()
|
memory = serializers.SerializerMethodField()
|
||||||
|
@ -99,6 +99,9 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
|
|
||||||
return manager.get_vm(opennebula_id)
|
return manager.get_vm(opennebula_id)
|
||||||
|
|
||||||
|
def get_cores(self, obj):
|
||||||
|
return (obj.template.cpu) * 10
|
||||||
|
|
||||||
def get_memory(self, obj):
|
def get_memory(self, obj):
|
||||||
return int(obj.template.memory) / 1024
|
return int(obj.template.memory) / 1024
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue