Quick fix remove cpu_cost etc.

This commit is contained in:
Modulos 2017-05-14 01:21:10 +02:00
parent b8df86342a
commit f80496a103

View file

@ -17,9 +17,6 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
disk_size = serializers.SerializerMethodField()
set_memory = serializers.IntegerField(write_only=True, label='Memory')
memory = serializers.SerializerMethodField()
core_price = serializers.FloatField(source='template.cpu_cost')
disk_size_price = serializers.FloatField(source='template.disk_cost')
memory_price = serializers.FloatField(source='template.memory_cost')
price = serializers.SerializerMethodField()
def create(self, validated_data):
@ -30,9 +27,6 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
name = data.pop('name')
disk_size = data.pop('disk')
memory = template.pop('memory')
core_price = template.pop('cpu_cost')
memory_price = template.pop('memory_cost')
disk_size_price = template.pop('disk_cost')
manager = OpenNebulaManager()
try:
@ -57,12 +51,16 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
except:
return 0
def get_price(self, obj):
template = obj.template
price = float(template.cpu) * float(template.cpu_cost)
price += (int(template.memory)/1024 * float(template.memory_cost))
for disk in template.disks:
price += int(disk.size)/1024 * float(template.disk_cost)
price = float(template.cpu) * 5.0
price += (int(template.memory)/1024 * 2.0)
try:
for disk in template.disks:
price += int(disk.size)/1024 * 0.6
except:
pass
return price
def get_memory(self, obj):
@ -137,8 +135,8 @@ class VirtualMachineSerializer(serializers.Serializer):
def get_price(self, obj):
template = obj.template
price = float(template.cpu) * float(template.cpu_cost)
price += (int(template.memory)/1024 * float(template.memory_cost))
price = float(template.cpu) * 5.0
price += (int(template.memory)/1024 * 2.0)
for disk in template.disks:
price += int(disk.size)/1024 * float(template.disk_cost)
price += int(disk.size)/1024 * 0.6
return price