diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2021-07-07 09:34:17 +1200 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2021-07-14 23:38:53 +0000 |
commit | be65d641d28fa84dc0629ecc29b6799eb99fa195 (patch) | |
tree | 3b3b6f682ac86bd59f07c311aa0f57d6ad630381 | |
parent | 327231dcc7887639202ba60d152d81bc9221b17a (diff) | |
download | trove-be65d641d28fa84dc0629ecc29b6799eb99fa195.tar.gz |
Fix getting config option value for database
Change-Id: If2d3022a59ba535e1361a3ba9bc9dd983ca25256
Story: 2009051
Task: 42821
(cherry picked from commit 69f08ab470a0d1d1d4676b41ad29a9c19ce28648)
-rw-r--r-- | trove/guestagent/common/configuration.py | 6 | ||||
-rw-r--r-- | trove/guestagent/datastore/mysql_common/manager.py | 9 | ||||
-rw-r--r-- | trove/guestagent/datastore/mysql_common/service.py | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/trove/guestagent/common/configuration.py b/trove/guestagent/common/configuration.py index f26f0ef2..77f76f51 100644 --- a/trove/guestagent/common/configuration.py +++ b/trove/guestagent/common/configuration.py @@ -105,12 +105,15 @@ class ConfigurationManager(object): self._override_strategy.configure( base_config_path, owner, group, codec, requires_root) - def get_value(self, key, default=None): + def get_value(self, key, section=None, default=None): """Return the current value at a given key or 'default'. """ if self._value_cache is None: self.refresh_cache() + if section: + return self._value_cache.get(section, {}).get(key, default) + return self._value_cache.get(key, default) def parse_configuration(self): @@ -419,6 +422,7 @@ class ImportOverrideStrategy(ConfigurationOverrideStrategy): as_root=self._requires_root) guestagent_utils.update_dict(options, parsed_options) + LOG.debug(f"Parsed overrides options: {parsed_options}") return parsed_options @property diff --git a/trove/guestagent/datastore/mysql_common/manager.py b/trove/guestagent/datastore/mysql_common/manager.py index 5c55ebe6..e7fe0e14 100644 --- a/trove/guestagent/datastore/mysql_common/manager.py +++ b/trove/guestagent/datastore/mysql_common/manager.py @@ -174,11 +174,14 @@ class MySqlManager(manager.Manager): def is_log_enabled(self, logname): if logname == self.GUEST_LOG_DEFS_GENERAL_LABEL: - value = self.configuration_manager.get_value('general_log', 'off') + value = self.configuration_manager.get_value( + 'general_log', section='mysqld', default='off') + LOG.debug(f"The config value of general_log is {value}") return value == 'on' elif logname == self.GUEST_LOG_DEFS_SLOW_QUERY_LABEL: - value = self.configuration_manager.get_value('slow_query_log', - 'off') + value = self.configuration_manager.get_value( + 'slow_query_log', section='mysqld', default='off') + LOG.debug(f"The config value of slow_query_log is {value}") return value == 'on' return False diff --git a/trove/guestagent/datastore/mysql_common/service.py b/trove/guestagent/datastore/mysql_common/service.py index 84a514c1..7dfadfce 100644 --- a/trove/guestagent/datastore/mysql_common/service.py +++ b/trove/guestagent/datastore/mysql_common/service.py @@ -460,7 +460,7 @@ class BaseMySqlApp(service.BaseDbApp): @classmethod def get_data_dir(cls): return cls.configuration_manager.get_value( - MySQLConfParser.SERVER_CONF_SECTION).get('datadir') + 'datadir', section=MySQLConfParser.SERVER_CONF_SECTION) @classmethod def set_data_dir(cls, value): |