Fixed getting custom_user when calling create_vm for hosting
This commit is contained in:
		
					parent
					
						
							
								589a4fcaa9
							
						
					
				
			
			
				commit
				
					
						2731ea8635
					
				
			
		
					 1 changed files with 18 additions and 14 deletions
				
			
		|  | @ -7,7 +7,7 @@ from django.core.mail import EmailMessage | ||||||
| 
 | 
 | ||||||
| from dynamicweb.celery import app | from dynamicweb.celery import app | ||||||
| from hosting.models import HostingOrder, HostingBill | from hosting.models import HostingOrder, HostingBill | ||||||
| from membership.models import StripeCustomer | from membership.models import StripeCustomer, CustomUser | ||||||
| from opennebula_api.models import OpenNebulaManager | from opennebula_api.models import OpenNebulaManager | ||||||
| from opennebula_api.serializers import VirtualMachineSerializer | from opennebula_api.serializers import VirtualMachineSerializer | ||||||
| from utils.hosting_utils import get_all_public_keys | from utils.hosting_utils import get_all_public_keys | ||||||
|  | @ -140,9 +140,13 @@ def create_vm_task(self, vm_template_id, user, specs, template, | ||||||
|             # try to see if we have the IP and that if the ssh keys can |             # try to see if we have the IP and that if the ssh keys can | ||||||
|             # be configured |             # be configured | ||||||
|             new_host = manager.get_primary_ipv4(vm_id) |             new_host = manager.get_primary_ipv4(vm_id) | ||||||
|  |             logger.debug("New VM ID is {vm_id}".format(vm_id=vm_id)) | ||||||
|             if new_host is not None: |             if new_host is not None: | ||||||
|                 public_keys = get_all_public_keys(owner) |                 custom_user = CustomUser.objects.get(email=user.get('email')) | ||||||
|                 keys = [{'value': key, 'state': True} for key in public_keys] |                 if custom_user is not None: | ||||||
|  |                     public_keys = get_all_public_keys(custom_user) | ||||||
|  |                     keys = [{'value': key, 'state': True} for key in | ||||||
|  |                             public_keys] | ||||||
|                     if len(keys) > 0: |                     if len(keys) > 0: | ||||||
|                         logger.debug( |                         logger.debug( | ||||||
|                             "Calling configure on {host} for {num_keys} keys".format( |                             "Calling configure on {host} for {num_keys} keys".format( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue