forked from uncloud/uncloud
Adapt recurring price of VM and Matrix to new scheme
This commit is contained in:
parent
14f59430bb
commit
f5897ed4b1
2 changed files with 6 additions and 15 deletions
|
@ -15,11 +15,9 @@ class MatrixServiceProduct(Product):
|
|||
)
|
||||
domain = models.CharField(max_length=255, default='domain.tld')
|
||||
|
||||
def recurring_price(self, recurring_period=RecurringPeriod.PER_MONTH):
|
||||
if recurring_period == RecurringPeriod.PER_MONTH:
|
||||
return self.monthly_managment_fee
|
||||
else:
|
||||
raise Exception('Invalid recurring period for VM Product pricing.')
|
||||
# Default recurring price is PER_MONT, see Product class.
|
||||
def recurring_price(self):
|
||||
return self.monthly_managment_fee
|
||||
|
||||
@staticmethod
|
||||
def base_image():
|
||||
|
|
|
@ -71,16 +71,9 @@ class VMProduct(Product):
|
|||
|
||||
primary_disk = models.ForeignKey('VMDiskProduct', on_delete=models.CASCADE, null=True)
|
||||
|
||||
def recurring_price(self, recurring_period=RecurringPeriod.PER_MONTH):
|
||||
# TODO: move magic numbers in variables
|
||||
if recurring_period == RecurringPeriod.PER_MONTH:
|
||||
return self.cores * 3 + self.ram_in_gb * 4
|
||||
elif recurring_period == RecurringPeriod.PER_HOUR:
|
||||
return self.cores * 4.0/(30 * 24) + self.ram_in_gb * 4.5/(30* 24)
|
||||
elif recurring_period == RecurringPeriod.PER_YEAR:
|
||||
return (self.cores * 2.5 + self.ram_in_gb * 3.5) * 12
|
||||
else:
|
||||
raise Exception('Invalid recurring period for VM Product pricing.')
|
||||
# Default recurring price is PER_MONTH, see uncloud_pay.models.Product.
|
||||
def recurring_price(self):
|
||||
return self.cores * 3 + self.ram_in_gb * 4
|
||||
|
||||
def __str__(self):
|
||||
return "VM {} ({}): {} cores {} gb ram".format(self.uuid,
|
||||
|
|
Loading…
Reference in a new issue