Verify OpenStack version to activate agent service

Since pci-irq-affinity-agent service is being containerized, once
the related changes are merged sysinv will have to check if
the stx-openstack application version already supports the agent
or not, in the latter case the agent service still need to be
activated on the platform.

Depends-on: https://review.opendev.org/c/starlingx/openstack-armada-app/+/813247
Story: 2009299
Task: 43653

Change-Id: Ida99726e0ed780cc72da28d74bdae8e1ff08bfc4
Signed-off-by: Heitor Matsui <HeitorVieira.Matsui@windriver.com>
This commit is contained in:
Heitor Matsui 2021-10-21 17:55:09 -03:00
parent c0003fd203
commit 4ed96fc424
1 changed files with 26 additions and 3 deletions

View File

@ -1,18 +1,37 @@
#
# Copyright (c) 2017-2018 Wind River Systems, Inc.
# Copyright (c) 2017-2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from sysinv.common import constants
from sysinv.common import utils
from sysinv.helm import helm
from sysinv.puppet import openstack
class PciIrqAffinityPuppet(openstack.OpenstackBasePuppet):
"""Class to encapsulate puppet operations for PciIrqAffinity configuration"""
PLATFORM_KEYRING_SERVICE = 'CGCS'
OPENSTACK_VERSION_WITH_CONTAINER_SUPPORT = 125
# This function will be removed when the service is completely removed from the platform
def should_enable_agent_service(self):
"""
Checks whether the OpenStack application version
includes the pci irq affinity agent container
"""
openstack_app_name = constants.HELM_APP_OPENSTACK
try:
openstack_app_version = self.dbapi.kube_app_get(openstack_app_name).app_version
# stx-openstack app version string format: x.y-wz-release-info
openstack_app_version = int(openstack_app_version.split('-', 2)[1])
except Exception:
return False
if openstack_app_version < self.OPENSTACK_VERSION_WITH_CONTAINER_SUPPORT:
return True
return False
def get_secure_static_config(self):
return {}
@ -23,12 +42,16 @@ class PciIrqAffinityPuppet(openstack.OpenstackBasePuppet):
if utils.is_openstack_applied(self.dbapi):
helm_data = helm.HelmOperatorData(self.dbapi)
# if openstack includes the agent container then agent
# service on platform must be disabled
enable_agent_service = self.should_enable_agent_service()
# The openstack services are authenticated with pod based
# keystone.
keystone_auth_data = helm_data.get_keystone_auth_data()
openstack_auth_config = {
'platform::pciirqaffinity::params::openstack_enabled':
True,
enable_agent_service,
'platform::pciirqaffinity::params::openstack_username':
keystone_auth_data['admin_user_name'],
'platform::pciirqaffinity::params::openstack_tenant':