Merge "Change @property usage to function"

This commit is contained in:
Zuul 2020-04-05 01:38:02 +00:00 committed by Gerrit Code Review
commit 8c3df10aa5
6 changed files with 14 additions and 21 deletions

View File

@ -65,8 +65,7 @@ class Manager(manager.Manager):
def configuration_manager(self): def configuration_manager(self):
return self.app.configuration_manager return self.app.configuration_manager
@property def get_datastore_log_defs(self):
def datastore_log_defs(self):
system_log_file = self.validate_log_file( system_log_file = self.validate_log_file(
self.app.cassandra_system_log_file, self.app.cassandra_owner) self.app.cassandra_system_log_file, self.app.cassandra_owner)
return { return {

View File

@ -68,8 +68,7 @@ class Manager(manager.Manager):
def configuration_manager(self): def configuration_manager(self):
return self.app.configuration_manager return self.app.configuration_manager
@property def get_datastore_log_defs(self):
def datastore_log_defs(self):
owner = self.app.pgsql_owner owner = self.app.pgsql_owner
long_query_time = CONF.get(self.manager).get( long_query_time = CONF.get(self.manager).get(
'guest_log_long_query_time') 'guest_log_long_query_time')

View File

@ -53,8 +53,7 @@ class Manager(manager.Manager):
def configuration_manager(self): def configuration_manager(self):
return self._app.configuration_manager return self._app.configuration_manager
@property def get_datastore_log_defs(self):
def datastore_log_defs(self):
logfile = self._app.get_logfile() logfile = self._app.get_logfile()
if not logfile: if not logfile:
return {} return {}

View File

@ -142,8 +142,7 @@ class Manager(periodic_task.PeriodicTasks):
""" """
return None return None
@property def get_datastore_log_defs(self):
def datastore_log_defs(self):
"""Any datastore-specific log files should be overridden in this dict """Any datastore-specific log files should be overridden in this dict
by the corresponding Manager class. by the corresponding Manager class.
@ -182,11 +181,10 @@ class Manager(periodic_task.PeriodicTasks):
}, },
} }
@property def get_guest_log_defs(self):
def guest_log_defs(self):
"""Return all the guest log defs.""" """Return all the guest log defs."""
if not self._guest_log_defs: if not self._guest_log_defs:
self._guest_log_defs = dict(self.datastore_log_defs) self._guest_log_defs = dict(self.get_datastore_log_defs())
self._guest_log_defs.update(self.guestagent_log_defs) self._guest_log_defs.update(self.guestagent_log_defs)
return self._guest_log_defs return self._guest_log_defs
@ -198,8 +196,7 @@ class Manager(periodic_task.PeriodicTasks):
def guest_log_context(self, context): def guest_log_context(self, context):
self._guest_log_context = context self._guest_log_context = context
@property def get_guest_log_cache(self):
def guest_log_cache(self):
"""Make sure the guest_log_cache is loaded and return it.""" """Make sure the guest_log_cache is loaded and return it."""
self._refresh_guest_log_cache() self._refresh_guest_log_cache()
return self._guest_log_cache return self._guest_log_cache
@ -215,7 +212,7 @@ class Manager(periodic_task.PeriodicTasks):
# Load the initial cache # Load the initial cache
self._guest_log_cache = {} self._guest_log_cache = {}
if self.guest_log_context: if self.guest_log_context:
gl_defs = self.guest_log_defs gl_defs = self.get_guest_log_defs()
try: try:
exposed_logs = CONF.get(self.manager).get( exposed_logs = CONF.get(self.manager).get(
'guest_log_exposed_logs') 'guest_log_exposed_logs')
@ -496,7 +493,7 @@ class Manager(periodic_task.PeriodicTasks):
def guest_log_list(self, context): def guest_log_list(self, context):
LOG.info("Getting list of guest logs.") LOG.info("Getting list of guest logs.")
self.guest_log_context = context self.guest_log_context = context
gl_cache = self.guest_log_cache gl_cache = self.get_guest_log_cache()
result = filter(None, [gl_cache[log_name].show() result = filter(None, [gl_cache[log_name].show()
if gl_cache[log_name].exposed else None if gl_cache[log_name].exposed else None
for log_name in gl_cache.keys()]) for log_name in gl_cache.keys()])
@ -517,7 +514,7 @@ class Manager(periodic_task.PeriodicTasks):
{'log': log_name, 'en': enable, 'dis': disable, {'log': log_name, 'en': enable, 'dis': disable,
'pub': publish, 'disc': discard}) 'pub': publish, 'disc': discard})
self.guest_log_context = context self.guest_log_context = context
gl_cache = self.guest_log_cache gl_cache = self.get_guest_log_cache()
if log_name in gl_cache: if log_name in gl_cache:
if ((gl_cache[log_name].type == guest_log.LogType.SYS) and if ((gl_cache[log_name].type == guest_log.LogType.SYS) and
not publish): not publish):
@ -563,7 +560,7 @@ class Manager(periodic_task.PeriodicTasks):
if self.configuration_manager: if self.configuration_manager:
LOG.debug("%(verb)s log '%(log)s'", {'verb': verb, LOG.debug("%(verb)s log '%(log)s'", {'verb': verb,
'log': log_name}) 'log': log_name})
gl_def = self.guest_log_defs[log_name] gl_def = self.get_guest_log_defs()[log_name]
enable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_ENABLE_LABEL, enable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_ENABLE_LABEL,
log_name) log_name)
disable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_DISABLE_LABEL, disable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_DISABLE_LABEL,
@ -614,7 +611,7 @@ class Manager(periodic_task.PeriodicTasks):
"""Sets the status of log_name to 'status' - if log_name is not """Sets the status of log_name to 'status' - if log_name is not
provided, sets the status on all logs. provided, sets the status on all logs.
""" """
gl_cache = self.guest_log_cache gl_cache = self.get_guest_log_cache()
names = [log_name] names = [log_name]
if not log_name or log_name not in gl_cache: if not log_name or log_name not in gl_cache:
names = gl_cache.keys() names = gl_cache.keys()

View File

@ -70,8 +70,7 @@ class MySqlManager(manager.Manager):
return self.mysql_app( return self.mysql_app(
self.mysql_app_status.get()).configuration_manager self.mysql_app_status.get()).configuration_manager
@property def get_datastore_log_defs(self):
def datastore_log_defs(self):
owner = 'mysql' owner = 'mysql'
datastore_dir = self.mysql_app.get_data_dir() datastore_dir = self.mysql_app.get_data_dir()
server_section = configurations.MySQLConfParser.SERVER_CONF_SECTION server_section = configurations.MySQLConfParser.SERVER_CONF_SECTION

View File

@ -259,7 +259,7 @@ class ManagerTest(trove_testtools.TestCase):
def assert_guest_log_status(self, original_status, new_status, def assert_guest_log_status(self, original_status, new_status,
expected_final_status): expected_final_status):
gl_cache = self.manager.guest_log_cache gl_cache = self.manager.get_guest_log_cache()
gl_cache[self.log_name_sys]._status = original_status gl_cache[self.log_name_sys]._status = original_status
self.manager.set_guest_log_status(new_status, self.log_name_sys) self.manager.set_guest_log_status(new_status, self.log_name_sys)
assert_equal(gl_cache[self.log_name_sys].status, expected_final_status, assert_equal(gl_cache[self.log_name_sys].status, expected_final_status,