Added email and password as attributes of the class OpenNebulaManager
This commit is contained in:
		
					parent
					
						
							
								79ecdadeb2
							
						
					
				
			
			
				commit
				
					
						fae96ec5ac
					
				
			
		
					 1 changed files with 11 additions and 11 deletions
				
			
		| 
						 | 
					@ -1,16 +1,15 @@
 | 
				
			||||||
import oca
 | 
					 | 
				
			||||||
import socket
 | 
					 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					import socket
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from oca.pool import WrongNameError, WrongIdError
 | 
					import oca
 | 
				
			||||||
from oca.exceptions import OpenNebulaException
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from django.conf import settings
 | 
					from django.conf import settings
 | 
				
			||||||
 | 
					from oca.exceptions import OpenNebulaException
 | 
				
			||||||
 | 
					from oca.pool import WrongNameError, WrongIdError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from utils.models import CustomUser
 | 
					 | 
				
			||||||
from .exceptions import KeyExistsError, UserExistsError, UserCredentialError
 | 
					 | 
				
			||||||
from hosting.models import HostingOrder
 | 
					from hosting.models import HostingOrder
 | 
				
			||||||
 | 
					from utils.models import CustomUser
 | 
				
			||||||
from utils.tasks import save_ssh_key
 | 
					from utils.tasks import save_ssh_key
 | 
				
			||||||
 | 
					from .exceptions import KeyExistsError, UserExistsError, UserCredentialError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +18,8 @@ class OpenNebulaManager():
 | 
				
			||||||
    """This class represents an opennebula manager."""
 | 
					    """This class represents an opennebula manager."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, email=None, password=None):
 | 
					    def __init__(self, email=None, password=None):
 | 
				
			||||||
 | 
					        self.email = email
 | 
				
			||||||
 | 
					        self.password = password
 | 
				
			||||||
        # Get oneadmin client
 | 
					        # Get oneadmin client
 | 
				
			||||||
        self.oneadmin_client = self._get_opennebula_client(
 | 
					        self.oneadmin_client = self._get_opennebula_client(
 | 
				
			||||||
            settings.OPENNEBULA_USERNAME,
 | 
					            settings.OPENNEBULA_USERNAME,
 | 
				
			||||||
| 
						 | 
					@ -517,11 +517,11 @@ class OpenNebulaManager():
 | 
				
			||||||
        :return:
 | 
					        :return:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        owner = CustomUser.objects.filter(
 | 
					        owner = CustomUser.objects.filter(
 | 
				
			||||||
            email=self.opennebula_user.name).first()
 | 
					            email=self.email).first()
 | 
				
			||||||
        all_orders = HostingOrder.objects.filter(customer__user=owner)
 | 
					        all_orders = HostingOrder.objects.filter(customer__user=owner)
 | 
				
			||||||
        if len(all_orders) > 0:
 | 
					        if len(all_orders) > 0:
 | 
				
			||||||
            logger.debug("The user {} has 1 or more VMs. We need to configure "
 | 
					            logger.debug("The user {} has 1 or more VMs. We need to configure "
 | 
				
			||||||
                         "the ssh keys.".format(self.opennebula_user.name))
 | 
					                         "the ssh keys.".format(self.email))
 | 
				
			||||||
            hosts = []
 | 
					            hosts = []
 | 
				
			||||||
            for order in all_orders:
 | 
					            for order in all_orders:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
| 
						 | 
					@ -536,4 +536,4 @@ class OpenNebulaManager():
 | 
				
			||||||
                save_ssh_key.delay(hosts, keys)
 | 
					                save_ssh_key.delay(hosts, keys)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            logger.debug("The user {} has no VMs. We don't need to configure "
 | 
					            logger.debug("The user {} has no VMs. We don't need to configure "
 | 
				
			||||||
                         "the ssh keys.".format(self.opennebula_user.name))
 | 
					                         "the ssh keys.".format(self.email))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue