From fae96ec5acc4615df09074366b341172e65d1f46 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 31 Aug 2017 12:54:08 +0530 Subject: [PATCH] Added email and password as attributes of the class OpenNebulaManager --- opennebula_api/models.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/opennebula_api/models.py b/opennebula_api/models.py index 0167e000..89a56774 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -1,16 +1,15 @@ -import oca -import socket import logging +import socket -from oca.pool import WrongNameError, WrongIdError -from oca.exceptions import OpenNebulaException - +import oca 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 utils.models import CustomUser from utils.tasks import save_ssh_key +from .exceptions import KeyExistsError, UserExistsError, UserCredentialError logger = logging.getLogger(__name__) @@ -19,7 +18,8 @@ class OpenNebulaManager(): """This class represents an opennebula manager.""" def __init__(self, email=None, password=None): - + self.email = email + self.password = password # Get oneadmin client self.oneadmin_client = self._get_opennebula_client( settings.OPENNEBULA_USERNAME, @@ -517,11 +517,11 @@ class OpenNebulaManager(): :return: """ owner = CustomUser.objects.filter( - email=self.opennebula_user.name).first() + email=self.email).first() all_orders = HostingOrder.objects.filter(customer__user=owner) if len(all_orders) > 0: 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 = [] for order in all_orders: try: @@ -536,4 +536,4 @@ class OpenNebulaManager(): save_ssh_key.delay(hosts, keys) else: 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))