From 3bb7f09d41a4f05550f4652a103aa341ad0e175d Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 23 Sep 2017 03:16:18 +0530 Subject: [PATCH] Refactored obtaining vm price to utils.hosting_utils.get_vm_price --- utils/hosting_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index 7c1a83ad..dae8e412 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -9,3 +9,16 @@ def get_all_public_keys(customer): """ return UserHostingKey.objects.filter(user_id=customer.id).values_list( "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)