Refactored code
This commit is contained in:
		
					parent
					
						
							
								56a8ad2edf
							
						
					
				
			
			
				commit
				
					
						38a8997e29
					
				
			
		
					 1 changed files with 9 additions and 7 deletions
				
			
		|  | @ -53,22 +53,24 @@ def create_vm_task(self, vm_template_id, user, specs, template, | ||||||
|         billing_address = BillingAddress.objects.filter( |         billing_address = BillingAddress.objects.filter( | ||||||
|             id=billing_address_id).first() |             id=billing_address_id).first() | ||||||
|         customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() |         customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() | ||||||
|         # Create OpenNebulaManager | 
 | ||||||
|         if 'pass' in user: |         if 'pass' in user: | ||||||
|             manager = OpenNebulaManager(email=user.get('email'), |             on_user = user.get('email') | ||||||
|                                         password=user.get('pass')) |             on_pass = user.get('pass') | ||||||
|             logger.debug("Using user {user} to create VM".format( |             logger.debug("Using user {user} to create VM".format(user=on_user)) | ||||||
|                 user=user.get('email'))) |  | ||||||
|             vm_name = None |             vm_name = None | ||||||
|         else: |         else: | ||||||
|             manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, |             on_user = settings.OPENNEBULA_USERNAME | ||||||
|                                         password=settings.OPENNEBULA_PASSWORD) |             on_pass = settings.OPENNEBULA_PASSWORD | ||||||
|             logger.debug("Using OpenNebula admin user to create VM") |             logger.debug("Using OpenNebula admin user to create VM") | ||||||
|             vm_name = "{email}-{template_name}-{date}".format( |             vm_name = "{email}-{template_name}-{date}".format( | ||||||
|                 email=user.get('email'), |                 email=user.get('email'), | ||||||
|                 template_name=template.get('name'), |                 template_name=template.get('name'), | ||||||
|                 date=int(datetime.now().strftime("%s"))) |                 date=int(datetime.now().strftime("%s"))) | ||||||
| 
 | 
 | ||||||
|  |         # Create OpenNebulaManager | ||||||
|  |         manager = OpenNebulaManager(email=on_user, password=on_pass) | ||||||
|  | 
 | ||||||
|         vm_id = manager.create_vm( |         vm_id = manager.create_vm( | ||||||
|             template_id=vm_template_id, |             template_id=vm_template_id, | ||||||
|             specs=specs, |             specs=specs, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue