Merge "CPU c-states and frequency report in Sysinv agent"
This commit is contained in:
commit
05e592cfaa
|
@ -779,8 +779,8 @@ class AgentManager(service.PeriodicService):
|
|||
return kernel_running
|
||||
|
||||
def _report_cstates_and_frequency_update(self, context, rpcapi=None):
|
||||
"""Evaluate if minimum frequency, maximum frequency or cstates
|
||||
are changed. If yes, report to conductor.
|
||||
"""Report to conductor the minimum frequency, maximum frequency and
|
||||
cstates.
|
||||
"""
|
||||
if not self._ihost_uuid:
|
||||
return
|
||||
|
@ -788,32 +788,23 @@ class AgentManager(service.PeriodicService):
|
|||
freq_dict = {}
|
||||
try:
|
||||
min_freq = self._get_min_cpu_mhz_allowed()
|
||||
self._ihost_min_cpu_mhz_allowed = min_freq
|
||||
|
||||
max_freq = self._get_max_cpu_mhz_allowed()
|
||||
self._ihost_max_cpu_mhz_allowed = max_freq
|
||||
|
||||
if min_freq != self._ihost_min_cpu_mhz_allowed:
|
||||
self._ihost_min_cpu_mhz_allowed = min_freq
|
||||
freq_dict.update({
|
||||
constants.IHOST_MIN_CPU_MHZ_ALLOWED:
|
||||
min_freq
|
||||
})
|
||||
freq_dict.update({
|
||||
constants.IHOST_MIN_CPU_MHZ_ALLOWED: min_freq,
|
||||
constants.IHOST_MAX_CPU_MHZ_ALLOWED: max_freq
|
||||
})
|
||||
|
||||
if max_freq != self._ihost_max_cpu_mhz_allowed:
|
||||
self._ihost_max_cpu_mhz_allowed = max_freq
|
||||
freq_dict.update({
|
||||
constants.IHOST_MAX_CPU_MHZ_ALLOWED:
|
||||
max_freq
|
||||
})
|
||||
|
||||
if os.path.isfile(os.path.join(constants.CSTATE_PATH,
|
||||
"state0/name")):
|
||||
if os.path.isfile(os.path.join(constants.CSTATE_PATH, "state0/name")):
|
||||
cstates_names = self._get_cstates_names()
|
||||
if utils.cstates_need_update(self._ihost_cstates_available,
|
||||
cstates_names):
|
||||
self._ihost_cstates_available = ','.join(cstates_names)
|
||||
freq_dict.update({
|
||||
constants.IHOST_CSTATES_AVAILABLE:
|
||||
','.join(cstates_names)
|
||||
})
|
||||
self._ihost_cstates_available = ','.join(cstates_names)
|
||||
freq_dict.update({
|
||||
constants.IHOST_CSTATES_AVAILABLE: ','.join(cstates_names)
|
||||
})
|
||||
|
||||
except OSError as ex:
|
||||
LOG.warning("Something wrong occurs during the cpu frequency"
|
||||
f" search. {ex}")
|
||||
|
|
|
@ -3890,33 +3890,3 @@ def checkout_ostree(ostree_repo, commit, target_dir, subpath):
|
|||
raise exception.SysinvException(
|
||||
"Error checkout ostree commit: %s" % (error),
|
||||
)
|
||||
|
||||
|
||||
def cstates_need_update(old_cstates, new_cstates):
|
||||
if old_cstates is None:
|
||||
return True
|
||||
if new_cstates is None:
|
||||
return False
|
||||
|
||||
old_cstates_list = []
|
||||
if isinstance(old_cstates, str):
|
||||
if old_cstates.strip() == '':
|
||||
return True
|
||||
old_cstates_list = old_cstates.split(',')
|
||||
else:
|
||||
old_cstates_list = old_cstates
|
||||
|
||||
new_cstates_list = []
|
||||
if isinstance(new_cstates, str):
|
||||
if new_cstates.strip() == '':
|
||||
return False
|
||||
new_cstates_list = new_cstates.split(',')
|
||||
else:
|
||||
new_cstates_list = new_cstates
|
||||
|
||||
if len(old_cstates_list) != len(new_cstates_list):
|
||||
return True
|
||||
diff = [v for v in old_cstates_list if v not in new_cstates_list]
|
||||
if len(diff) > 0:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue