summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingxian Kong <anlin.kong@gmail.com>2021-07-07 09:34:17 +1200
committerLingxian Kong <anlin.kong@gmail.com>2021-07-14 20:52:28 +1200
commit69f08ab470a0d1d1d4676b41ad29a9c19ce28648 (patch)
tree099a2045be8d03190f36bccde042dc77579aa8cb
parent437d594e86b3efd9a797ab4462681404b31b41e8 (diff)
downloadtrove-69f08ab470a0d1d1d4676b41ad29a9c19ce28648.tar.gz
Fix getting config option value for database
Change-Id: If2d3022a59ba535e1361a3ba9bc9dd983ca25256 Story: 2009051 Task: 42821
-rw-r--r--trove/guestagent/common/configuration.py6
-rw-r--r--trove/guestagent/datastore/mysql_common/manager.py9
-rw-r--r--trove/guestagent/datastore/mysql_common/service.py2
3 files changed, 12 insertions, 5 deletions
diff --git a/trove/guestagent/common/configuration.py b/trove/guestagent/common/configuration.py
index b3165080..2edfa0da 100644
--- a/trove/guestagent/common/configuration.py
+++ b/trove/guestagent/common/configuration.py
@@ -104,12 +104,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):
@@ -417,6 +420,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 538c29e1..cd6546a1 100644
--- a/trove/guestagent/datastore/mysql_common/manager.py
+++ b/trove/guestagent/datastore/mysql_common/manager.py
@@ -173,11 +173,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 4efa091c..a110d222 100644
--- a/trove/guestagent/datastore/mysql_common/service.py
+++ b/trove/guestagent/datastore/mysql_common/service.py
@@ -463,7 +463,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):