def _load_config(): # Don't load in global context, since we can't assume # these modules are accessible when distutils uses # this module import ConfigParser from oslo_config import cfg import logging global loaded, PATRON_VENDOR, PATRON_PRODUCT, PATRON_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("Patron", "vendor"): PATRON_VENDOR = cfg.get("Patron", "vendor") if cfg.has_option("Patron", "product"): PATRON_PRODUCT = cfg.get("Patron", "product") if cfg.has_option("Patron", "package"): PATRON_PACKAGE = cfg.get("Patron", "package") except Exception as ex: LOG = logging.getLogger(__name__) LOG.error(_LE("Failed to load %(cfgfile)s: %(ex)s"), {"cfgfile": cfgfile, "ex": ex})
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()
def _provide_config_file(self, bin_path, nfvi_cfg, kwargs): with open(os.path.join(bin_path, nfvi_cfg), 'r') as cfg: template = cfg.read() cfg, cfg_content = tempfile.mkstemp() with os.fdopen(cfg, "w+") as cfg: cfg.write(template.format(**kwargs)) cfg_file = os.path.join(bin_path, nfvi_cfg) self.connection.put(cfg_content, cfg_file)
def _load_config(): from six.moves import configparser from oslo_config import cfg from oslo_log import log as logging global loaded, SIMILAR_VENDOR, SIMILAR_PRODUCT, SIMILAR_PACKAGE if loaded: return loaded = True cfgfile = cfg.CONF.find_file("release") if cfgfile is None: return try: cfg = configparser.RawConfigParser() cfg.read(cfgfile) except Exception as ex: LOG = logging.getLogger(__name__) LOG.error(_LE("Failed to load %(cfgfile)s: %(ex)s"), {'cfgfile': cfgfile, 'ex': ex})
def _load_config(): # Don't load in global context, since we can't assume # these modules are accessible when distutils uses # this module import ConfigParser from oslo_config import cfg from oslo_log import log as 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) NOVA_VENDOR = cfg.get("Prototype", "vendor") if cfg.has_option("Prototype", "vendor"): NOVA_VENDOR = cfg.get("Prototype", "vendor") NOVA_PRODUCT = cfg.get("Prototype", "product") if cfg.has_option("Prototype", "product"): NOVA_PRODUCT = cfg.get("Prototype", "product") NOVA_PACKAGE = cfg.get("Prototype", "package") if cfg.has_option("Prototype", "package"): NOVA_PACKAGE = cfg.get("Prototype", "package") except Exception as ex: LOG = logging.getLogger(__name__) LOG.error(_LE("Failed to load %(cfgfile)s: %(ex)s"), { 'cfgfile': cfgfile, 'ex': ex })
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})