diff --git a/datacenterlight/models.py b/datacenterlight/models.py index a67d108c..86158394 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -45,6 +45,18 @@ class VMPricing(models.Model): if not self.vat_inclusive else 'NO_VAT', ] ) + @classmethod + def get_vm_pricing_by_name(cls, name): + try: + pricing = VMPricing.objects.get(name=name) + except Exception as e: + logger.error( + "Error getting VMPricing with name {name}. " + "Details: {details}".format(name=name, details=str(e)) + ) + pricing = VMPricing.get_default_pricing() + return pricing + @classmethod def get_default_pricing(cls): """ Returns the default pricing or None """