コード例 #1
0
ファイル: service.py プロジェクト: openstack/ceilometer
def prepare_service(argv=None, config_files=None, conf=None):
    if argv is None:
        argv = sys.argv

    if conf is None:
        conf = cfg.ConfigOpts()

    oslo_i18n.enable_lazy()
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)
    keystone_client.register_keystoneauth_opts(conf)
    log.register_options(conf)
    log_levels = (conf.default_log_levels +
                  ['futurist=INFO', 'neutronclient=INFO',
                   'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)

    conf(argv[1:], project='ceilometer', validate_default_values=True,
         version=version.version_info.version_string(),
         default_config_files=config_files)

    keystone_client.post_register_keystoneauth_opts(conf)

    log.setup(conf, 'ceilometer')
    utils.setup_root_helper(conf)
    sample.setup(conf)

    gmr.TextGuruMeditation.setup_autorun(version)
    messaging.setup()
    return conf
コード例 #2
0
ファイル: service.py プロジェクト: ityaptin/ceilometer
def prepare_service(argv=None, config_files=None, conf=None):
    if argv is None:
        argv = sys.argv

    # FIXME(sileht): Use ConfigOpts() instead
    if conf is None:
        conf = cfg.CONF

    oslo_i18n.enable_lazy()
    log.register_options(conf)
    log_levels = (conf.default_log_levels +
                  ['futurist=INFO', 'neutronclient=INFO',
                   'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    defaults.set_cors_middleware_defaults()
    policy_opts.set_defaults(conf)

    conf(argv[1:], project='ceilometer', validate_default_values=True,
         version=version.version_info.version_string(),
         default_config_files=config_files)

    ka_loading.load_auth_from_conf_options(conf, "service_credentials")

    log.setup(conf, 'ceilometer')
    # NOTE(liusheng): guru cannot run with service under apache daemon, so when
    # ceilometer-api running with mod_wsgi, the argv is [], we don't start
    # guru.
    if argv:
        gmr.TextGuruMeditation.setup_autorun(version)
    messaging.setup()
    return conf
コード例 #3
0
ファイル: service.py プロジェクト: openstack/panko
def prepare_service(argv=None, config_files=None, share=False):
    conf = cfg.ConfigOpts()
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)
    db_options.set_defaults(conf)
    if profiler_opts:
        profiler_opts.set_defaults(conf)
    if not share:
        defaults.set_cors_middleware_defaults()
        oslo_i18n.enable_lazy()
        log.register_options(conf)

    if argv is None:
        argv = sys.argv
    conf(argv[1:], project='panko', validate_default_values=True,
         version=version.version_info.version_string(),
         default_config_files=config_files)

    if not share:
        log.setup(conf, 'panko')
    profiler.setup(conf)
    # NOTE(liusheng): guru cannot run with service under apache daemon, so when
    # panko-api running with mod_wsgi, the argv is [], we don't start
    # guru.
    if argv:
        gmr.TextGuruMeditation.setup_autorun(version)
    return conf
コード例 #4
0
ファイル: service.py プロジェクト: anirupdutta/searchlight
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log.set_defaults(_DEFAULT_LOG_LEVELS)
    log.register_options(CONF)
    if argv is None:
        argv = sys.argv
    CONF(argv[1:], project='searchlight')
    log.setup(cfg.CONF, 'searchlight')
    oslo_messaging.set_transport_defaults('searchlight')
コード例 #5
0
ファイル: service.py プロジェクト: pkilambi/ceilometer
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log.register_options(cfg.CONF)
    log_levels = cfg.CONF.default_log_levels + ["stevedore=INFO", "keystoneclient=INFO"]
    log.set_defaults(default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project="ceilometer", validate_default_values=True)
    log.setup(cfg.CONF, "ceilometer")
    messaging.setup()
コード例 #6
0
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log_levels = (cfg.CONF.default_log_levels +
                  ['stevedore=INFO', 'keystoneclient=INFO'])
    cfg.set_defaults(log.log_opts,
                     default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='ceilometer', validate_default_values=True)
    log.setup('ceilometer')
    messaging.setup()
コード例 #7
0
ファイル: service.py プロジェクト: chungg/aodh
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log.register_options(cfg.CONF)
    log_levels = (cfg.CONF.default_log_levels +
                  ['stevedore=INFO', 'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='aodh', validate_default_values=True)
    log.setup(cfg.CONF, 'aodh')
    messaging.setup()
コード例 #8
0
ファイル: service.py プロジェクト: cy-lee/kiloeyes
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log.set_defaults(constant.KILOEYES_LOGGING_CONTEXT_FORMAT,
                     constant.KILOEYES_LOG_LEVELS)
    log.register_options(cfg.CONF)

    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='kiloeyes')
    log.setup(cfg.CONF, 'kiloeyes')
    LOG.info('Service has started!')
コード例 #9
0
ファイル: sphinxext.py プロジェクト: openstack/oslo.config
def setup(app):
    # NOTE(dhellmann): Try to turn off lazy translation from oslo_i18n
    # so any translated help text or deprecation messages associated
    # with configuration options are treated as regular strings
    # instead of Message objects. Unfortunately this is a bit
    # order-dependent, and so it's still possible that importing code
    # from another module such as through the autodoc features, or
    # even through the plugin scanner, will turn lazy evaluation back
    # on.
    oslo_i18n.enable_lazy(False)
    app.add_directive('show-options', ShowOptionsDirective)
    app.add_domain(ConfigDomain)
コード例 #10
0
ファイル: service.py プロジェクト: openstack/searchlight
def prepare_service(argv=None):
    oslo_i18n.enable_lazy()
    log.set_defaults(_DEFAULT_LOG_LEVELS)
    log.register_options(CONF)
    gmr.TextGuruMeditation.setup_autorun(version)
    utils.register_plugin_opts()

    if argv is None:
        argv = sys.argv
    CONF(argv[1:], project='searchlight')
    log.setup(cfg.CONF, 'searchlight')
    oslo_messaging.set_transport_defaults('searchlight')
コード例 #11
0
ファイル: test.py プロジェクト: vponomaryov/manila
    def setUp(self):
        """Run before each test method to initialize test environment."""
        super(TestCase, self).setUp()

        oslo_i18n.enable_lazy(enable=False)
        conf_fixture.set_defaults(CONF)
        CONF([], default_config_files=[])

        global _DB_CACHE
        if not _DB_CACHE:
            _DB_CACHE = Database(
                db_api,
                migration,
                sql_connection=CONF.database.connection,
                sqlite_db=CONF.sqlite_db,
                sqlite_clean_db=CONF.sqlite_clean_db,
            )
        self.useFixture(_DB_CACHE)

        self.injected = []
        self._services = []
        self.flags(fatal_exception_format_errors=True)
        # This will be cleaned up by the NestedTempfile fixture
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path, group='oslo_concurrency')
        self.fixture.config(
            disable_process_locking=True, group='oslo_concurrency')

        rpc.add_extra_exmods('manila.tests')
        self.addCleanup(rpc.clear_extra_exmods)
        self.addCleanup(rpc.cleanup)

        self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
        self.messaging_conf.transport_driver = 'fake'
        self.messaging_conf.response_timeout = 15
        self.useFixture(self.messaging_conf)
        rpc.init(CONF)

        mock.patch('keystoneauth1.loading.load_auth_from_conf_options').start()

        fake_notifier.stub_notifier(self)

        # Locks must be cleaned up after tests
        CONF.set_override('backend_url', 'file://' + lock_path,
                          group='coordination')
        coordination.LOCK_COORDINATOR.start()
        self.addCleanup(coordination.LOCK_COORDINATOR.stop)
コード例 #12
0
ファイル: heat_api.py プロジェクト: PradeepSingh1988/heat
def init_application():
    i18n.enable_lazy()

    LOG = logging.getLogger('heat.api')

    logging.register_options(cfg.CONF)
    version = hversion.version_info.version_string()
    cfg.CONF(project='heat', prog='heat-api', version=version)
    logging.setup(cfg.CONF, 'heat-api')
    messaging.setup()

    port = cfg.CONF.heat_api.bind_port
    host = cfg.CONF.heat_api.bind_host
    profiler.setup('heat-api', host)
    LOG.info(_LI('Starting Heat REST API on %(host)s:%(port)s'),
             {'host': host, 'port': port})
    return config.load_paste_app()
コード例 #13
0
ファイル: solum_api.py プロジェクト: openstack/solum
def init_application():
    i18n.enable_lazy()

    LOG = logging.getLogger('solum.api')

    logging.register_options(cfg.CONF)
    cfg.CONF(project='solum')
    logging.setup(cfg.CONF, 'solum')

    config.set_config_defaults()
    objects.load()

    port = cfg.CONF.api.port
    host = cfg.CONF.api.host
    LOG.info(('Starting Solum REST API on %(host)s:%(port)s'),
             {'host': host, 'port': port})
    return api_app.setup_app()
コード例 #14
0
def prepare_service(argv=None, config_files=None):
    oslo_i18n.enable_lazy()
    log.register_options(cfg.CONF)
    log_levels = (cfg.CONF.default_log_levels +
                  ['stevedore=INFO', 'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='ceilometer', validate_default_values=True,
             version=version.version_info.version_string(),
             default_config_files=config_files)
    log.setup(cfg.CONF, 'ceilometer')
    # NOTE(liusheng): guru cannot run with service under apache daemon, so when
    # ceilometer-api running with mod_wsgi, the argv is [], we don't start
    # guru.
    if argv:
        gmr.TextGuruMeditation.setup_autorun(version)
    messaging.setup()
コード例 #15
0
ファイル: service.py プロジェクト: pczerkas/aodh
def prepare_service(argv=None):
    conf = cfg.ConfigOpts()
    oslo_i18n.enable_lazy()
    log.register_options(conf)
    log_levels = (conf.default_log_levels +
                  ['stevedore=INFO', 'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    db_options.set_defaults(conf)
    policy_opts.set_defaults(conf)
    from aodh import opts
    # Register our own Aodh options
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)

    conf(argv, project='aodh', validate_default_values=True)
    log.setup(conf, 'aodh')
    messaging.setup()
    return conf
コード例 #16
0
ファイル: service.py プロジェクト: therve/nabu
def prepare_service(argv=None, config_files=None, conf=None):
    oslo_i18n.enable_lazy()

    if argv is None:
        argv = sys.argv
    if conf is None:
        conf = cfg.ConfigOpts()
    conf.register_opts(OPTS)
    log.register_options(conf)
    db_options.set_defaults(conf)
    loading.register_auth_conf_options(conf, 'keystone_authtoken')
    conf(argv[1:], project='nabu', validate_default_values=True,
         version=nabu.__version__,
         default_config_files=config_files)
    loading.load_auth_from_conf_options(conf, 'keystone_authtoken')

    log.setup(conf, 'nabu')

    return conf
コード例 #17
0
def init_application():
    i18n.enable_lazy()

    LOG = logging.getLogger('heat.api.cloudwatch')

    logging.register_options(cfg.CONF)
    cfg.CONF(project='heat',
             prog='heat-api-cloudwatch',
             version=version.version_info.version_string())
    logging.setup(cfg.CONF, 'heat-api-cloudwatch')
    logging.set_defaults()
    messaging.setup()

    port = cfg.CONF.heat_api_cloudwatch.bind_port
    host = cfg.CONF.heat_api_cloudwatch.bind_host
    LOG.info(_LI('Starting Heat CloudWatch API on %(host)s:%(port)s'),
             {'host': host, 'port': port})
    profiler.setup('heat-api-cloudwatch', host)

    return config.load_paste_app()
コード例 #18
0
ファイル: test.py プロジェクト: jkasarherou/manila
    def setUp(self):
        """Run before each test method to initialize test environment."""
        super(TestCase, self).setUp()

        oslo_i18n.enable_lazy(enable=False)
        conf_fixture.set_defaults(CONF)
        CONF([], default_config_files=[])

        global _DB_CACHE
        if not _DB_CACHE:
            _DB_CACHE = Database(
                db_api,
                migration,
                sql_connection=CONF.database.connection,
                sqlite_db=CONF.sqlite_db,
                sqlite_clean_db=CONF.sqlite_clean_db,
            )
        self.useFixture(_DB_CACHE)

        self.injected = []
        self._services = []
        self.flags(fatal_exception_format_errors=True)
        # This will be cleaned up by the NestedTempfile fixture
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path, group="oslo_concurrency")
        self.fixture.config(disable_process_locking=True, group="oslo_concurrency")

        rpc.add_extra_exmods("manila.tests")
        self.addCleanup(rpc.clear_extra_exmods)
        self.addCleanup(rpc.cleanup)

        self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
        self.messaging_conf.transport_driver = "fake"
        self.messaging_conf.response_timeout = 15
        self.useFixture(self.messaging_conf)
        rpc.init(CONF)

        fake_notifier.stub_notifier(self)
コード例 #19
0
ファイル: service.py プロジェクト: andymcc/ceilometer
def prepare_service(argv=None, config_files=None, conf=None):
    if argv is None:
        argv = sys.argv

    if conf is None:
        conf = cfg.ConfigOpts()

    oslo_i18n.enable_lazy()
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)
    keystone_client.register_keystoneauth_opts(conf)
    log.register_options(conf)
    log_levels = (conf.default_log_levels +
                  ['futurist=INFO', 'neutronclient=INFO',
                   'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    defaults.set_cors_middleware_defaults()
    policy_opts.set_defaults(conf)
    db_options.set_defaults(conf)

    conf(argv[1:], project='ceilometer', validate_default_values=True,
         version=version.version_info.version_string(),
         default_config_files=config_files)

    ka_loading.load_auth_from_conf_options(conf, "service_credentials")

    log.setup(conf, 'ceilometer')
    utils.setup_root_helper(conf)
    sample.setup(conf)

    # NOTE(liusheng): guru cannot run with service under apache daemon, so when
    # ceilometer-api running with mod_wsgi, the argv is [], we don't start
    # guru.
    if argv:
        gmr.TextGuruMeditation.setup_autorun(version)
    messaging.setup()
    return conf
コード例 #20
0
ファイル: service.py プロジェクト: ISCAS-VDI/aodh-base
def prepare_service(argv=None, config_files=None):
    conf = cfg.ConfigOpts()
    oslo_i18n.enable_lazy()
    log.register_options(conf)
    log_levels = (conf.default_log_levels +
                  ['futurist=INFO', 'keystoneclient=INFO'])
    log.set_defaults(default_log_levels=log_levels)
    defaults.set_cors_middleware_defaults()
    db_options.set_defaults(conf)
    policy_opts.set_defaults(conf)
    from aodh import opts
    # Register our own Aodh options
    for group, options in opts.list_opts():
        conf.register_opts(list(options),
                           group=None if group == "DEFAULT" else group)
    keystone_client.register_keystoneauth_opts(conf)

    conf(argv, project='aodh', validate_default_values=True,
         default_config_files=config_files)

    ka_loading.load_auth_from_conf_options(conf, "service_credentials")
    log.setup(conf, 'aodh')
    messaging.setup()
    return conf
コード例 #21
0
ファイル: eventlet.py プロジェクト: dstanek/keystone
import os
import socket

from oslo_concurrency import processutils
from oslo_config import cfg
import oslo_i18n
from oslo_service import service
from oslo_service import systemd
import pbr.version


# NOTE(dstanek): i18n.enable_lazy() must be called before
# keystone.i18n._() is called to ensure it has the desired lazy lookup
# behavior. This includes cases, like keystone.exceptions, where
# keystone.i18n._() is called at import time.
oslo_i18n.enable_lazy()


from keystone.common import environment
from keystone.common import utils
from keystone import config
from keystone.i18n import _
from keystone.server import common
from keystone import service as keystone_service


CONF = cfg.CONF


class ServerWrapper(object):
    """Wraps a Server with some launching info & capabilities."""
コード例 #22
0
ファイル: api_cfn.py プロジェクト: aaratn/heat
import sys

from oslo_config import cfg
import oslo_i18n as i18n
from oslo_log import log as logging
from oslo_reports import guru_meditation_report as gmr
from oslo_service import systemd
import six

from heat.common import config
from heat.common import messaging
from heat.common import profiler
from heat.common import wsgi
from heat import version

i18n.enable_lazy()

LOG = logging.getLogger('heat.api.cfn')


def launch_cfn_api(setup_logging=True):
    if setup_logging:
        logging.register_options(cfg.CONF)
    cfg.CONF(project='heat',
             prog='heat-api-cfn',
             version=version.version_info.version_string())
    if setup_logging:
        logging.setup(cfg.CONF, 'heat-api-cfn')
        logging.set_defaults()
    config.set_config_defaults()
    messaging.setup()
コード例 #23
0
ファイル: i18n.py プロジェクト: Vaidyanath/guts
def enable_lazy(enable=True):
    return i18n.enable_lazy(enable)
コード例 #24
0
ファイル: _i18n.py プロジェクト: openstack/python-heatclient
def enable_lazy():
    return oslo_i18n.enable_lazy()
コード例 #25
0
def enable_lazy(enable=True):
    return i18n.enable_lazy(enable)
コード例 #26
0
ファイル: engine.py プロジェクト: cryptickp/heat
from oslo_config import cfg
import oslo_i18n as i18n
from oslo_log import log as logging
from oslo_reports import guru_meditation_report as gmr
from oslo_service import service

from heat.common import config
from heat.common.i18n import _LC
from heat.common import messaging
from heat.common import profiler
from heat.engine import template
from heat.rpc import api as rpc_api
from heat import version

i18n.enable_lazy()

LOG = logging.getLogger('heat.engine')


def main():
    logging.register_options(cfg.CONF)
    cfg.CONF(project='heat',
             prog='heat-engine',
             version=version.version_info.version_string())
    logging.setup(cfg.CONF, 'heat-engine')
    logging.set_defaults()
    messaging.setup()

    config.startup_sanity_check()
コード例 #27
0
ファイル: _i18n.py プロジェクト: ge0rgi/python-cinderclient
def enable_lazy():
    return oslo_i18n.enable_lazy()
コード例 #28
0
# Copyright (c) 2014 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from sahara_plugins.utils import patches
patches.patch_all()

import oslo_i18n

# NOTE(slukjanov): i18n.enable_lazy() must be called before
#                  sahara.utils.i18n._() is called to ensure it has the desired
#                  lazy lookup behavior.
oslo_i18n.enable_lazy()
コード例 #29
0
ファイル: _i18n.py プロジェクト: K-OpenNet/OPNFV-StateMon
def enable_lazy(enable=True):
    return oslo_i18n.enable_lazy(enable)
コード例 #30
0
ファイル: autohelp.py プロジェクト: SvenDowideit/clearlinux
def import_modules(repo_location, package_name, verbose=0):
    """Import modules.

    Loops through the repository, importing module by module to
    populate the configuration object (cfg.CONF) created from Oslo.
    """

    # If the project uses oslo.i18n, make sure that it is initialized so that
    # the builtins contain the _ function.
    requirements = os.path.join(repo_location, 'requirements.txt')
    with open(requirements) as fd:
        with_i18n = False
        for line in fd:
            if line.startswith('oslo.i18n'):
                i18n.enable_lazy()
                i18n.install(package_name)
                with_i18n = True
                break
        if not with_i18n:
            # NOTE(gpocentek): projects didn't use oslo.i18n on havana, and
            # some imports fail because _ is not yet registered in the
            # builtins. We try to import and setup the translation tools
            # manually.
            try:
                modname = "%s.openstack.common.gettextutils" % package_name
                module = importlib.import_module(modname)
                module.install(package_name)
            except Exception:
                pass

    pkg_location = os.path.join(repo_location, package_name)
    for root, dirs, files in os.walk(pkg_location):
        skipdir = False
        for excludedir in ('tests', 'locale',
                           os.path.join('db', 'migration'), 'transfer'):
            if ((os.path.sep + excludedir + os.path.sep) in root or (
                    root.endswith(os.path.sep + excludedir))):
                skipdir = True
                break
        if skipdir:
            continue
        for pyfile in files:
            if pyfile.endswith('.py'):
                abs_path = os.path.join(root, pyfile)
                modfile = abs_path.split(repo_location, 1)[1]
                modname = os.path.splitext(modfile)[0].split(os.path.sep)
                modname = [m for m in modname if m != '']
                modname = '.'.join(modname)
                if modname.endswith('.__init__'):
                    modname = modname[:modname.rfind(".")]
                if modname in IGNORE:
                    continue
                try:
                    module = importlib.import_module(modname)
                    if verbose >= 1:
                        print("imported %s" % modname)
                except ImportError as e:
                    """
                    work around modules that don't like being imported in
                    this way FIXME This could probably be better, but does
                    not affect the configuration options found at this stage
                    """
                    if verbose >= 2:
                        print("Failed to import: %s (%s)" % (modname, e))
                    continue
                except cfg.DuplicateOptError as e:
                    """
                    oslo.cfg doesn't allow redefinition of a config option, but
                    we don't mind. Don't fail if this happens.
                    """
                    if verbose >= 2:
                        print(e)
                    continue
                except cfg.NoSuchGroupError as e:
                    """
                    If a group doesn't exist, we ignore the import.
                    """
                    if verbose >= 2:
                        print(e)
                    continue
                _register_runtime_opts(module, abs_path, verbose)
                _run_hook(modname)

    # All the components provide keystone token authentication, usually using a
    # pipeline. Since the auth_token options can only be discovered at runtime
    # in this configuration, we force their discovery by importing the module.
    try:
        import keystonemiddleware.auth_token  # noqa
    except cfg.DuplicateOptError:
        pass