Example #1
0
    def __init__(self, message=None, **kwargs):
        self.kwargs = kwargs
        self.logger = get_default_logger(self.__module__)

        if 'code' not in self.kwargs:
            try:
                self.kwargs['code'] = self.code
            except AttributeError:
                pass

        if not message:
            try:
                message = self.msg_fmt % kwargs

            except Exception:
                exc_info = sys.exc_info()
                # kwargs doesn't match a variable in the message
                # log the issue and the kwargs
                self.logger.warn('Exception in string format operation')
                for name, value in six.iteritems(kwargs):
                    self.logger.error("%s: %s" % (name, value))  # noqa

                global fatal_exception_format_errors
                if fatal_exception_format_errors:
                    six.reraise(*exc_info)
                else:
                    # at least get the core message out if something happened
                    message = self.msg_fmt

        self.message = message
        super(PollTaskException, self).__init__(message)
Example #2
0
 def __init__(self):
   signal(SIGINT, SIG_IGN)
   self.proxy = wdc_proxy()
   self.proxy.register_observer(self)
   self.logger = get_default_logger()
   self.logger.info('wdc_manager loaded')
   self.current_diagnostics = {}
   self.last_completions = {}
   self.state = {}
Example #3
0
 def __init__(self, manager):
   self.manager = manager
   self.logger = get_default_logger()
Example #4
0
import re
import copy

from exception import NetmaskErrorException, TimeoutException
from logger import get_default_logger

from setting import (DEFAULT_SSH_KEY_DIR, 
                        DEFAULT_SSH_KEY_NAME,
                        DEFAULT_SSH_KEY_TYPE,
                        DEFAULT_SSH_KEY_CONFIG_NAME,
                        DEFAULT_DOMAIN_NAME,
                        DEFAULT_DISK_LABEL,
                        ZFS_CONFIG)

TASK_DIR = os.path.join(os.path.dirname(__file__), 'tasks')
Logger = get_default_logger(__name__)

def import_utils(module_name, module_path=TASK_DIR):
    for dir_path, dir_names, files in os.walk(module_path):
        if '.'.join([module_name, 'py']) in files:
            if dir_path not in sys.path:
                sys.path.append(dir_path)
            return __import__(module_name)
    
    return None

def get_subclass(module, clazz):
    for subclazz_name, subclazz in inspect.getmembers(module):
        if hasattr(subclazz, '__bases__') and clazz in subclazz.__bases__:
            yield (subclazz_name, subclazz)