Quick fix remove cpu_cost etc.
This commit is contained in:
parent
b8df86342a
commit
f80496a103
1 changed files with 11 additions and 13 deletions
|
@ -17,9 +17,6 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
|
||||||
disk_size = serializers.SerializerMethodField()
|
disk_size = serializers.SerializerMethodField()
|
||||||
set_memory = serializers.IntegerField(write_only=True, label='Memory')
|
set_memory = serializers.IntegerField(write_only=True, label='Memory')
|
||||||
memory = serializers.SerializerMethodField()
|
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()
|
price = serializers.SerializerMethodField()
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
|
@ -30,9 +27,6 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
|
||||||
name = data.pop('name')
|
name = data.pop('name')
|
||||||
disk_size = data.pop('disk')
|
disk_size = data.pop('disk')
|
||||||
memory = template.pop('memory')
|
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()
|
manager = OpenNebulaManager()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -57,12 +51,16 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def get_price(self, obj):
|
def get_price(self, obj):
|
||||||
template = obj.template
|
template = obj.template
|
||||||
price = float(template.cpu) * float(template.cpu_cost)
|
price = float(template.cpu) * 5.0
|
||||||
price += (int(template.memory)/1024 * float(template.memory_cost))
|
price += (int(template.memory)/1024 * 2.0)
|
||||||
|
try:
|
||||||
for disk in template.disks:
|
for disk in template.disks:
|
||||||
price += int(disk.size)/1024 * float(template.disk_cost)
|
price += int(disk.size)/1024 * 0.6
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return price
|
return price
|
||||||
|
|
||||||
def get_memory(self, obj):
|
def get_memory(self, obj):
|
||||||
|
@ -137,8 +135,8 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
|
|
||||||
def get_price(self, obj):
|
def get_price(self, obj):
|
||||||
template = obj.template
|
template = obj.template
|
||||||
price = float(template.cpu) * float(template.cpu_cost)
|
price = float(template.cpu) * 5.0
|
||||||
price += (int(template.memory)/1024 * float(template.memory_cost))
|
price += (int(template.memory)/1024 * 2.0)
|
||||||
for disk in template.disks:
|
for disk in template.disks:
|
||||||
price += int(disk.size)/1024 * float(template.disk_cost)
|
price += int(disk.size)/1024 * 0.6
|
||||||
return price
|
return price
|
||||||
|
|
Loading…
Reference in a new issue