Refactor code
This commit is contained in:
		
					parent
					
						
							
								c13af95017
							
						
					
				
			
			
				commit
				
					
						ae0d4c0841
					
				
			
		
					 1 changed files with 8 additions and 17 deletions
				
			
		| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
import ipaddress
 | 
					 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,27 +53,18 @@ class OpenNebulaManager():
 | 
				
			||||||
            ConnectionError: If the connection to the opennebula server can't be
 | 
					            ConnectionError: If the connection to the opennebula server can't be
 | 
				
			||||||
                established
 | 
					                established
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        return oca.Client("{0}:{1}".format(
 | 
					        return self._get_opennebula_client(user.email, user.password)
 | 
				
			||||||
            user.email,
 | 
					 | 
				
			||||||
            user.password),
 | 
					 | 
				
			||||||
            "{protocol}://{domain}:{port}{endpoint}".format(
 | 
					 | 
				
			||||||
                protocol=settings.OPENNEBULA_PROTOCOL,
 | 
					 | 
				
			||||||
                domain=settings.OPENNEBULA_DOMAIN,
 | 
					 | 
				
			||||||
                port=settings.OPENNEBULA_PORT,
 | 
					 | 
				
			||||||
                endpoint=settings.OPENNEBULA_ENDPOINT
 | 
					 | 
				
			||||||
        ))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_opennebula_client(self, username, password):
 | 
					    def _get_opennebula_client(self, username, password):
 | 
				
			||||||
        return oca.Client("{0}:{1}".format(
 | 
					        return oca.Client(
 | 
				
			||||||
            username,
 | 
					            "{0}:{1}".format(username, password),
 | 
				
			||||||
 | 
					 | 
				
			||||||
            password),
 | 
					 | 
				
			||||||
            "{protocol}://{domain}:{port}{endpoint}".format(
 | 
					            "{protocol}://{domain}:{port}{endpoint}".format(
 | 
				
			||||||
                protocol=settings.OPENNEBULA_PROTOCOL,
 | 
					                protocol=settings.OPENNEBULA_PROTOCOL,
 | 
				
			||||||
                domain=settings.OPENNEBULA_DOMAIN,
 | 
					                domain=settings.OPENNEBULA_DOMAIN,
 | 
				
			||||||
                port=settings.OPENNEBULA_PORT,
 | 
					                port=settings.OPENNEBULA_PORT,
 | 
				
			||||||
                endpoint=settings.OPENNEBULA_ENDPOINT
 | 
					                endpoint=settings.OPENNEBULA_ENDPOINT
 | 
				
			||||||
        ))
 | 
					            )
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_user(self, user):
 | 
					    def _get_user(self, user):
 | 
				
			||||||
        """Get the corresponding opennebula user for a CustomUser object
 | 
					        """Get the corresponding opennebula user for a CustomUser object
 | 
				
			||||||
| 
						 | 
					@ -438,8 +428,9 @@ class OpenNebulaManager():
 | 
				
			||||||
        return template_id
 | 
					        return template_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def delete_template(self, template_id):
 | 
					    def delete_template(self, template_id):
 | 
				
			||||||
        self.oneadmin_client.call(oca.VmTemplate.METHODS[
 | 
					        self.oneadmin_client.call(
 | 
				
			||||||
            'delete'], template_id, False)
 | 
					            oca.VmTemplate.METHODS['delete'], template_id, False
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def change_user_password(self, passwd_hash):
 | 
					    def change_user_password(self, passwd_hash):
 | 
				
			||||||
        self.oneadmin_client.call(
 | 
					        self.oneadmin_client.call(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue