Refactored obtaining vm price to utils.hosting_utils.get_vm_price

This commit is contained in:
PCoder 2017-09-23 03:16:18 +05:30
parent dd3c967500
commit 3bb7f09d41

View file

@ -9,3 +9,16 @@ def get_all_public_keys(customer):
""" """
return UserHostingKey.objects.filter(user_id=customer.id).values_list( return UserHostingKey.objects.filter(user_id=customer.id).values_list(
"public_key", flat=True) "public_key", flat=True)
def get_vm_price(cpu, memory, disk_size):
"""
A helper function that computes price of a VM from given cpu, ram and
ssd parameters
:param cpu: Number of cores of the VM
:param memory: RAM of the VM
:param disk_size: Disk space of the VM
:return: The price of the VM
"""
return (cpu * 5) + (memory * 2) + (disk_size * 0.6)