diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 69ba08ad..9f0249a2 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -58,6 +58,7 @@ def retry_task(task, exception=None): def create_vm_task(self, vm_template_id, user, specs, template, stripe_customer_id, billing_address_data, billing_address_id, charge): + vm_id = None try: final_price = specs.get('price') billing_address = BillingAddress.objects.filter(id=billing_address_id).first() @@ -76,6 +77,9 @@ def create_vm_task(self, vm_template_id, user, specs, template, stripe_customer_ date=int(datetime.now().strftime("%s"))) ) + if vm_id is None: + raise Exception("Could not create VM") + # Create a Hosting Order order = HostingOrder.create( price=final_price, @@ -132,6 +136,8 @@ def create_vm_task(self, vm_template_id, user, specs, template, stripe_customer_ logger.error(str(e)) retry_task(self) + return vm_id + class DictDotLookup(object): """