From b103772c0d6148eb4c0614e787299b76d16b9383 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 16 Apr 2018 03:37:19 +0200 Subject: [PATCH] Pass vm_pricing if available when creating HostingOrder --- datacenterlight/tasks.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index df91387e..c97c6c54 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -97,13 +97,26 @@ def create_vm_task(self, vm_template_id, user, specs, template, if vm_id is None: raise Exception("Could not create VM") - # Create a Hosting Order - order = HostingOrder.create( - price=final_price, - vm_id=vm_id, - customer=customer, - billing_address=billing_address - ) + if 'pricing_name' in specs: + vm_pricing = VMPricing.get_vm_pricing_by_name( + name=specs['pricing_name'] + ) + # Create a Hosting Order + order = HostingOrder.create( + price=final_price, + vm_id=vm_id, + customer=customer, + billing_address=billing_address, + vm_pricing=vm_pricing + ) + else: + # Create a Hosting Order + order = HostingOrder.create( + price=final_price, + vm_id=vm_id, + customer=customer, + billing_address=billing_address + ) # Create a Hosting Bill HostingBill.create(