Added condition to check if create_vm succeeded

This commit is contained in:
M.Ravi 2017-08-06 18:52:23 +02:00
parent f950c1defb
commit e7864f5d85

View file

@ -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):
"""