예제 #1
0
파일: quota.py 프로젝트: nkrinner/manila
 def _driver(self):
     if self.__driver:
         return self.__driver
     if not self._driver_cls:
         self._driver_cls = CONF.quota_driver
     if isinstance(self._driver_cls, basestring):
         self._driver_cls = importutils.import_object(self._driver_cls)
     self.__driver = self._driver_cls
     return self.__driver
예제 #2
0
 def _driver(self):
     if self.__driver:
         return self.__driver
     if not self._driver_cls:
         self._driver_cls = CONF.quota_driver
     if isinstance(self._driver_cls, six.string_types):
         self._driver_cls = importutils.import_object(self._driver_cls)
     self.__driver = self._driver_cls
     return self.__driver
예제 #3
0
 def __init__(self,
              scheduler_driver=None,
              service_name=None,
              *args,
              **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     super(SchedulerManager, self).__init__(*args, **kwargs)
예제 #4
0
파일: impl_zmq.py 프로젝트: nkrinner/manila
def _get_matchmaker(*args, **kwargs):
    global matchmaker
    if not matchmaker:
        mm = CONF.rpc_zmq_matchmaker
        if mm.endswith('matchmaker.MatchMakerRing'):
            mm.replace('matchmaker', 'matchmaker_ring')
            LOG.warn(_('rpc_zmq_matchmaker = %(orig)s is deprecated; use'
                       ' %(new)s instead') % dict(
                     orig=CONF.rpc_zmq_matchmaker, new=mm))
        matchmaker = importutils.import_object(mm, *args, **kwargs)
    return matchmaker
예제 #5
0
 def __init__(self, share_driver=None, service_name=None, *args, **kwargs):
     """Load the driver from args, or from flags."""
     self.configuration = Configuration(share_manager_opts,
                                        config_group=service_name)
     super(ShareManager, self).__init__(service_name='share',
                                        *args, **kwargs)
     if not share_driver:
         share_driver = self.configuration.share_driver
     self.driver = importutils.import_object(
         share_driver, self.db, configuration=self.configuration)
     self.network_api = network.API()
예제 #6
0
 def setUp(self):
     super(ShareManagerTestCase, self).setUp()
     self.flags(connection_type='fake',
                share_driver='manila.tests.fake_driver.FakeShareDriver')
     # Define class directly, because this test suite dedicated
     # to specific manager.
     self.share_manager = importutils.import_object(
         "manila.share.manager.ShareManager")
     self.stubs.Set(self.share_manager.driver, 'do_setup', mock.Mock())
     self.stubs.Set(self.share_manager.driver, 'check_for_setup_error',
                    mock.Mock())
     self.context = context.get_admin_context()
예제 #7
0
 def setUp(self):
     super(ShareManagerTestCase, self).setUp()
     self.flags(connection_type='fake',
                share_driver='manila.tests.fake_driver.FakeShareDriver')
     # Define class directly, because this test suite dedicated
     # to specific manager.
     self.share_manager = importutils.import_object(
         "manila.share.manager.ShareManager")
     self.stubs.Set(self.share_manager.driver, 'do_setup', mock.Mock())
     self.stubs.Set(self.share_manager.driver, 'check_for_setup_error',
                    mock.Mock())
     self.context = context.get_admin_context()
예제 #8
0
    def __init__(self, share_driver=None, service_name=None, *args, **kwargs):
        """Load the driver from args, or from flags."""
        self.configuration = manila.share.configuration.Configuration(
            share_manager_opts, config_group=service_name)
        super(ShareManager, self).__init__(service_name='share',
                                           *args,
                                           **kwargs)

        if not share_driver:
            share_driver = self.configuration.share_driver
        self.driver = importutils.import_object(
            share_driver, self.db, configuration=self.configuration)
        self.network_api = network.API()
예제 #9
0
def _get_matchmaker(*args, **kwargs):
    global matchmaker
    if not matchmaker:
        matchmaker = importutils.import_object(
            CONF.rpc_zmq_matchmaker, *args, **kwargs)
    return matchmaker
예제 #10
0
파일: driver.py 프로젝트: mbr4v0v/manila
 def __init__(self):
     self.host_manager = importutils.import_object(
         CONF.scheduler_host_manager)
     self.share_rpcapi = share_rpcapi.ShareAPI()
예제 #11
0
 def setUp(self):
     super(ShareTestCase, self).setUp()
     self.flags(connection_type='fake',
                share_driver='manila.tests.test_share.FakeShareDriver')
     self.share_manager = importutils.import_object(CONF.share_manager)
     self.context = context.get_admin_context()
예제 #12
0
 def setUp(self):
     super(ShareTestCase, self).setUp()
     self.flags(connection_type='fake',
                share_driver='manila.tests.test_share.FakeShareDriver')
     self.share_manager = importutils.import_object(CONF.share_manager)
     self.context = context.get_admin_context()
예제 #13
0
 def __init__(self, scheduler_driver=None, service_name=None,
              *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     super(SchedulerManager, self).__init__(*args, **kwargs)
예제 #14
0
파일: driver.py 프로젝트: mbr4v0v/manila
 def __init__(self):
     self.host_manager = importutils.import_object(
         CONF.scheduler_host_manager)
     self.share_rpcapi = share_rpcapi.ShareAPI()
예제 #15
0
파일: log.py 프로젝트: bobcallaway/manila
def _setup_logging_from_conf(project, version):
    log_root = getLogger(None).logger
    for handler in log_root.handlers:
        log_root.removeHandler(handler)

    if CONF.use_syslog:
        facility = _find_facility_from_conf()
        # TODO(bogdando) use the format provided by RFCSysLogHandler
        #   after existing syslog format deprecation in J
        if CONF.use_syslog_rfc_format:
            syslog = RFCSysLogHandler(address='/dev/log',
                                      facility=facility)
        else:
            syslog = logging.handlers.SysLogHandler(address='/dev/log',
                                                    facility=facility)
        log_root.addHandler(syslog)

    logpath = _get_log_file_path()
    if logpath:
        filelog = logging.handlers.WatchedFileHandler(logpath)
        log_root.addHandler(filelog)

    if CONF.use_stderr:
        streamlog = ColorHandler()
        log_root.addHandler(streamlog)

    elif not logpath:
        # pass sys.stdout as a positional argument
        # python2.6 calls the argument strm, in 2.7 it's stream
        streamlog = logging.StreamHandler(sys.stdout)
        log_root.addHandler(streamlog)

    if CONF.publish_errors:
        try:
            handler = importutils.import_object(
                "manila.openstack.common.log_handler.PublishErrorsHandler",
                logging.ERROR)
        except ImportError:
            handler = importutils.import_object(
                "oslo.messaging.notify.log_handler.PublishErrorsHandler",
                logging.ERROR)
        log_root.addHandler(handler)

    datefmt = CONF.log_date_format
    for handler in log_root.handlers:
        # NOTE(alaski): CONF.log_format overrides everything currently.  This
        # should be deprecated in favor of context aware formatting.
        if CONF.log_format:
            handler.setFormatter(logging.Formatter(fmt=CONF.log_format,
                                                   datefmt=datefmt))
            log_root.info('Deprecated: log_format is now deprecated and will '
                          'be removed in the next release')
        else:
            handler.setFormatter(ContextFormatter(project=project,
                                                  version=version,
                                                  datefmt=datefmt))

    if CONF.debug:
        log_root.setLevel(logging.DEBUG)
    elif CONF.verbose:
        log_root.setLevel(logging.INFO)
    else:
        log_root.setLevel(logging.WARNING)

    for pair in CONF.default_log_levels:
        mod, _sep, level_name = pair.partition('=')
        logger = logging.getLogger(mod)
        # NOTE(AAzza) in python2.6 Logger.setLevel doesn't convert string name
        # to integer code.
        if sys.version_info < (2, 7):
            level = logging.getLevelName(level_name)
            logger.setLevel(level)
        else:
            logger.setLevel(level_name)