Python oslo_config.cfg 模块,get() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用oslo_config.cfg.get()

项目:ramdisk-func-test    作者:openstack    | 项目源码 | 文件源码
def _check_rsync(self):

        rsync_config_path = "/etc/rsyncd.conf"
        rsync_ironic_section_name = 'ironic_rsync'

        if not utils._pid_of('rsync'):
            raise exception.RsyncProcessNotFound()

        if os.path.exists(rsync_config_path):
            cfg = utils.read_config(rsync_config_path)
        else:
            raise exception.RsyncConfigNotFound(path=rsync_config_path)

        if rsync_ironic_section_name in cfg.sections():
            self.rsync_dir = cfg.get(rsync_ironic_section_name, 'path')
        else:
            raise exception.RsyncIronicSectionNotFound(
                section=rsync_ironic_section_name
            )
项目:broadview-collector    作者:openstack    | 项目源码 | 文件源码
def readConfig(self):
        LOG.info("broadview_collector: readConfig")
        try:
            cfg = ConfigParser.ConfigParser()
            cfg.read("/etc/broadviewcollector.conf")
            x = cfg.get("plugins", "publishers")
            self._publisherNames = [y.strip() for y in x.split(',')]
            LOG.info("publishers {}".format(self._publisherNames))
            self._searchpath = []
            try:
                x = cfg.get("plugins", "searchpath")
                self._searchpath = [y.strip() for y in x.split(',')]
            except:
                LOG.info("plugin searchpath missing or malformed")

            if not self._searchpath or len(self._searchpath) == 0:
                self._searchpath = ["broadview_collector.plugins"]
            else:
                self._searchpath.append("broadview_collector.plugins")
            LOG.info("plugin searchpath {}".format(self._searchpath))

            x = cfg.get("plugins", "handlers")
            self._handlerNames = [y.strip() for y in x.split(',')]
            LOG.info("plugin handlers {}".format(self._handlerNames))
            self._ip_address = cfg.get("network", "ip_address")
            self._port = int(cfg.get("network", "port"))

        except:
            LOG.error("Unable to open or read /etc/broadviewcollector.conf")
            exit()
项目:masakari-monitors    作者:openstack    | 项目源码 | 文件源码
def _load_config():
    # Don't load in global context, since we can't assume
    # these modules are accessible when distutils uses
    # this module
    from six.moves import configparser

    from oslo_config import cfg

    from oslo_log import log as logging

    global loaded, MONITORS_VENDOR, MONITORS_PRODUCT, MONITORS_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = configparser.RawConfigParser()
        cfg.read(cfgfile)

        if cfg.has_option("Masakarimonitors", "vendor"):
            MONITORS_VENDOR = cfg.get("Masakarimonitors", "vendor")

        if cfg.has_option("Masakarimonitors", "product"):
            MONITORS_PRODUCT = cfg.get("Masakarimonitors", "product")

        if cfg.has_option("Masakarimonitors", "package"):
            MONITORS_PACKAGE = cfg.get("Masakarimonitors", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error("Failed to load %(cfgfile)s: %(ex)s",
                  {'cfgfile': cfgfile, 'ex': ex})
项目:masakari    作者:openstack    | 项目源码 | 文件源码
def _load_config():
    # Don't load in global context, since we can't assume
    # these modules are accessible when distutils uses
    # this module
    from six.moves import configparser

    from oslo_config import cfg

    from oslo_log import log as logging

    global loaded, MASAKARI_VENDOR, MASAKARI_PRODUCT, MASAKARI_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = configparser.RawConfigParser()
        cfg.read(cfgfile)

        if cfg.has_option("Masakari", "vendor"):
            MASAKARI_VENDOR = cfg.get("Masakari", "vendor")

        if cfg.has_option("Masakari", "product"):
            MASAKARI_PRODUCT = cfg.get("Masakari", "product")

        if cfg.has_option("Masakari", "package"):
            MASAKARI_PACKAGE = cfg.get("Masakari", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error("Failed to load %(cfgfile)s: %(ex)s",
                  {'cfgfile': cfgfile, 'ex': ex})
项目:Trusted-Platform-Module-nova    作者:BU-NU-CLOUD-SP16    | 项目源码 | 文件源码
def _load_config():
    # Don't load in global context, since we can't assume
    # these modules are accessible when distutils uses
    # this module
    from six.moves import configparser

    from oslo_config import cfg

    import logging

    global loaded, NOVA_VENDOR, NOVA_PRODUCT, NOVA_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = configparser.RawConfigParser()
        cfg.read(cfgfile)

        if cfg.has_option("Nova", "vendor"):
            NOVA_VENDOR = cfg.get("Nova", "vendor")

        if cfg.has_option("Nova", "product"):
            NOVA_PRODUCT = cfg.get("Nova", "product")

        if cfg.has_option("Nova", "package"):
            NOVA_PACKAGE = cfg.get("Nova", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error(_LE("Failed to load %(cfgfile)s: %(ex)s"),
                  {'cfgfile': cfgfile, 'ex': ex})