diff --git a/devstack/cfg.py b/devstack/cfg.py index f7f4e1be..49d6d8ac 100644 --- a/devstack/cfg.py +++ b/devstack/cfg.py @@ -48,10 +48,12 @@ class IgnoreMissingConfigParser(ConfigParser.RawConfigParser): DEF_BOOLEAN = False DEF_BASE = None - def __init__(self): + def __init__(self, cs=True): ConfigParser.RawConfigParser.__init__(self) - #make option names case sensitive - self.optionxform = str + if cs: + # Make option names case sensitive + # See: http://docs.python.org/library/configparser.html#ConfigParser.RawConfigParser.optionxform + self.optionxform = str def get(self, section, option): value = IgnoreMissingConfigParser.DEF_BASE @@ -80,21 +82,21 @@ class IgnoreMissingConfigParser(ConfigParser.RawConfigParser): class StackConfigParser(IgnoreMissingConfigParser): - def __init__(self): - IgnoreMissingConfigParser.__init__(self) + def __init__(self, cs=True): + IgnoreMissingConfigParser.__init__(self, cs) self.configs_fetched = dict() def _resolve_value(self, section, option, value_gotten): if section == 'host' and option == 'ip': LOG.debug("Host ip from configuration/environment was empty, programatically attempting to determine it.") value_gotten = utils.get_host_ip() - LOG.debug("Determined your host ip to be: [%s]" % (value_gotten)) + LOG.debug("Determined your host ip to be: %r" % (value_gotten)) return value_gotten def getdefaulted(self, section, option, default_val): val = self.get(section, option) if not val or not val.strip(): - LOG.debug("Value [%s] found was not good enough, returning provided default [%s]" % (val, default_val)) + LOG.debug("Value %r found was not good enough, returning provided default '%s'" % (val, default_val)) return default_val return val @@ -102,23 +104,23 @@ class StackConfigParser(IgnoreMissingConfigParser): key = cfg_helpers.make_id(section, option) if key in self.configs_fetched: value = self.configs_fetched.get(key) - LOG.debug("Fetched cached value [%s] for param [%s]" % (value, key)) + LOG.debug("Fetched cached value '%s' for param %r" % (value, key)) else: - LOG.debug("Fetching value for param [%s]" % (key)) + LOG.debug("Fetching value for param %r" % (key)) gotten_value = self._get_bashed(section, option) value = self._resolve_value(section, option, gotten_value) - LOG.debug("Fetched [%s] for [%s] %s" % (value, key, CACHE_MSG)) + LOG.debug("Fetched %r for %r %s" % (value, key, CACHE_MSG)) self.configs_fetched[key] = value return value def set(self, section, option, value): key = cfg_helpers.make_id(section, option) - LOG.audit("Setting config value [%s] for param [%s]" % (value, key)) + LOG.audit("Setting config value '%s' for param %r" % (value, key)) self.configs_fetched[key] = value IgnoreMissingConfigParser.set(self, section, option, value) def _resolve_replacements(self, value): - LOG.debug("Performing simple replacement on [%s]", value) + LOG.debug("Performing simple replacement on %r", value) #allow for our simple replacement to occur def replacer(match): @@ -138,19 +140,19 @@ class StackConfigParser(IgnoreMissingConfigParser): env_key = mtch.group(1).strip() def_val = mtch.group(2).strip() if not def_val and not env_key: - msg = "Invalid bash-like value [%s]" % (value) + msg = "Invalid bash-like value %r" % (value) raise excp.BadParamException(msg) env_value = env.get_key(env_key) if env_value is None: - LOG.debug("Extracting value from config provided default value [%s]" % (def_val)) + LOG.debug("Extracting value from config provided default value %r" % (def_val)) extracted_val = self._resolve_replacements(def_val) - LOG.debug("Using config provided default value [%s] (no environment key)" % (extracted_val)) + LOG.debug("Using config provided default value %r (no environment key)" % (extracted_val)) else: extracted_val = env_value - LOG.debug("Using enviroment provided value [%s]" % (extracted_val)) + LOG.debug("Using enviroment provided value %r" % (extracted_val)) else: extracted_val = value - LOG.debug("Using raw config provided value [%s]" % (extracted_val)) + LOG.debug("Using raw config provided value %r" % (extracted_val)) return extracted_val diff --git a/devstack/components/glance.py b/devstack/components/glance.py index c9da3024..aaa31f33 100644 --- a/devstack/components/glance.py +++ b/devstack/components/glance.py @@ -129,7 +129,7 @@ class GlanceInstaller(GlanceMixin, comp.PythonInstallComponent): # then extract known configs that # will need locations/directories/files made (or touched)... with io.BytesIO(contents) as stream: - config = cfg.IgnoreMissingConfigParser() + config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) if config.getboolean('default', 'image_cache_enabled'): cache_dir = config.get('default', "image_cache_datadir") diff --git a/devstack/components/keystone.py b/devstack/components/keystone.py index 000769c7..7313457b 100644 --- a/devstack/components/keystone.py +++ b/devstack/components/keystone.py @@ -112,7 +112,7 @@ class KeystoneInstaller(comp.PythonInstallComponent): return set(['swift', 'quantum']) def _sync_db(self): - LOG.info("Syncing keystone to database named %s.", DB_NAME) + LOG.info("Syncing keystone to database named %r", DB_NAME) mp = self._get_param_map(None) cmds = [{'cmd': SYNC_DB_CMD}] utils.execute_template(*cmds, cwd=self.bin_dir, params=mp) @@ -142,7 +142,7 @@ class KeystoneInstaller(comp.PythonInstallComponent): # then extract known configs that # ill need locations/directories/files made (or touched)... with io.BytesIO(contents) as stream: - config = cfg.IgnoreMissingConfigParser() + config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) log_filename = config.get('default', 'log_file') if log_filename: diff --git a/devstack/components/melange.py b/devstack/components/melange.py index a11ba46f..181aab76 100644 --- a/devstack/components/melange.py +++ b/devstack/components/melange.py @@ -85,11 +85,14 @@ class MelangeInstaller(comp.PythonInstallComponent): self._sync_db() def _sync_db(self): - LOG.info("Syncing the database with melange.") - mp = dict() - mp['BIN_DIR'] = self.bin_dir + LOG.info("Syncing melange to database named %r", DB_NAME) + utils.execute_template(*DB_SYNC_CMD, params=self._get_param_map(None)) + + def _get_param_map(self, config_fn): + mp = comp.PythonInstallComponent._get_param_map(self, config_fn) mp['CFG_FILE'] = sh.joinpths(self.cfg_dir, ROOT_CONF_REAL_NAME) - utils.execute_template(*DB_SYNC_CMD, params=mp) + mp['BIN_DIR'] = self.bin_dir + return mp def _get_config_files(self): return list(CONFIGS) @@ -98,12 +101,12 @@ class MelangeInstaller(comp.PythonInstallComponent): if config_fn == ROOT_CONF: newcontents = contents with io.BytesIO(contents) as stream: - config = cfg.IgnoreMissingConfigParser() + config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) db_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME) - old_dbsn = config.get('DEFAULT', 'sql_connection') + old_dbsn = config.get('default', 'sql_connection') if db_dsn != old_dbsn: - config.set('DEFAULT', 'sql_connection', db_dsn) + config.set('default', 'sql_connection', db_dsn) with io.BytesIO() as outputstream: config.write(outputstream) outputstream.flush() diff --git a/devstack/components/nova.py b/devstack/components/nova.py index 7f680fe9..3d8e5923 100644 --- a/devstack/components/nova.py +++ b/devstack/components/nova.py @@ -288,7 +288,7 @@ class NovaInstaller(NovaMixin, comp.PythonInstallComponent): self.tracewriter.file_touched(tgt_fn) def _sync_db(self): - LOG.info("Syncing the database with nova.") + LOG.info("Syncing nova to database named %r", DB_NAME) mp = self._get_param_map(None) utils.execute_template(*DB_SYNC_CMD, params=mp) diff --git a/devstack/components/quantum.py b/devstack/components/quantum.py index 2efa3084..756fc3e0 100644 --- a/devstack/components/quantum.py +++ b/devstack/components/quantum.py @@ -97,11 +97,11 @@ class QuantumInstaller(QuantumMixin, comp.PkgInstallComponent): # Need to fix the "Quantum plugin provider module" newcontents = contents with io.BytesIO(contents) as stream: - config = cfg.IgnoreMissingConfigParser() + config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) - provider = config.get("PLUGIN", "provider") + provider = config.get("plugin", "provider") if provider != V_PROVIDER: - config.set("PLUGIN", "provider", V_PROVIDER) + config.set("plugin", "provider", V_PROVIDER) with io.BytesIO() as outputstream: config.write(outputstream) outputstream.flush() @@ -111,13 +111,13 @@ class QuantumInstaller(QuantumMixin, comp.PkgInstallComponent): # Need to adjust the sql connection newcontents = contents with io.BytesIO(contents) as stream: - config = cfg.IgnoreMissingConfigParser() + config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) - db_dsn = config.get("DATABASE", "sql_connection") + db_dsn = config.get("database", "sql_connection") if db_dsn: generated_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME) if generated_dsn != db_dsn: - config.set("DATABASE", "sql_connection", generated_dsn) + config.set("database", "sql_connection", generated_dsn) with io.BytesIO() as outputstream: config.write(outputstream) outputstream.flush()