Expose the Hyper-Threading (HT) processor feature

This commit implements a method to verify if the Hyper-Threading (HT)
feature is enabled on host. This method will be used in Task 45621 to
compute the eng_workers parameter.

TEST PLAN:
PASS: AIO-SX: create and deploy CentOS installation ISO successfully
on host with HT enabled.
PASS: AIO-SX: check if the correct qty of threads (in this case only
one) was configured on base services.

PASS: AIO-SX: create and deploy CentOS installation ISO successfully
on host with HT disabled.
PASS: AIO-SX: check if the correct qty of threads (2) was configured
on base services.

PASS: AIO-SX: change the number of dedicated platform cores using the
CLI and verify the change was effective and reflected in the services.

Story: 2010087
Task: 46179

Signed-off-by: Reynaldo P Gomes <reynaldo.patronegomes@windriver.com>
Change-Id: I95cf3d21316307001f42053ba0105c2bd3416fcc
This commit is contained in:
Reynaldo P Gomes 2022-09-01 17:21:11 -03:00
parent 62dea5bcea
commit 297b4af855
4 changed files with 29 additions and 0 deletions

View File

@ -420,6 +420,14 @@ class Connection(object):
:returns: cpus.
"""
@abc.abstractmethod
def icpu_is_hyper_threading_enabled(self, ihost):
"""Return if Hyper Threading is enabled on host.
:param ihost: The id or uuid of an ihost.
:returns: True if enabled and False if not.
"""
@abc.abstractmethod
def icpu_update(self, cpu_id, values, forihostid=None):
"""Update properties of a cpu.

View File

@ -1626,6 +1626,15 @@ class Connection(api.Connection):
return _paginate_query(models.icpu, limit, marker,
sort_key, sort_dir, query)
def icpu_is_hyper_threading_enabled(self, ihost):
query = model_query(models.icpu.id)
query = add_icpu_filter_by_ihost(query, ihost)
query = query.filter(models.icpu.thread > 0)
result = query.first()
return result is not None
@db_objects.objectify(objects.cpu)
def icpu_update(self, cpu_id, values, forihostid=None):
with _session_for_write() as session:

View File

@ -228,6 +228,12 @@ class BasePuppet(object):
cpus = self._get_host_cpu_list(host, constants.PLATFORM_FUNCTION)
return sorted(cpus, key=lambda c: c.cpu)
def _get_hyperthreading_enabled(self, host):
"""
Check if the Hyper-Threading feature is enabled on host
"""
return self.dbapi.icpu_is_hyper_threading_enabled(host.id)
def _get_service_parameters(self, service=None):
service_parameters = []
if self.dbapi is None:

View File

@ -339,6 +339,12 @@ class PlatformPuppet(base.BasePuppet):
cpu_count,
})
hyperthreading_enabled = self._get_hyperthreading_enabled(host)
config.update({
'platform::params::hyperthreading_enabled':
hyperthreading_enabled,
})
return config
def _get_host_platform_config_upgrade(self, host, config_uuid):