Check node names using startswith instead of in

Due to recent changes in inventory creation, node names use FQDN and
this may cause issues when deciding whether a node is an OCP node or
not. Example: "compute-0.ocp.openstack.lab" is not an OCP node, but
"ocp" is part of its hostname.
With this patch, the issue with FQDNs is resolved by checking how the
hostname starts.

Change-Id: I75ad4316338effccb67614997909ee7d7ff17c65
This commit is contained in:
Eduardo Olivares 2024-08-08 08:59:58 +02:00
parent a022d38865
commit d32e91b857

View File

@ -225,9 +225,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
def append_node_data(node, is_crc):
# Here we mean ansible controller node used by the ci-framework
# This controller is not a part of OSP and should be skipped
if 'controller' in node:
if node.startswith('controller'):
return
if 'ocp' in node and not is_crc:
if node.startswith('ocp') and not is_crc:
# a specific ssh key is used for accessing ocp nodes
key = 'ansible_ssh_private_key_file' # meaning dict key here
# save path of ocp nodes key (if not yet), we'll need it later
@ -242,7 +242,8 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
node_key = 'id_cifw_key'
node_ip = hosts_data[node]['ansible_host']
# Here we mean a node with running OSP control plane services
is_controller = (('ocp' in node) or ('crc' in node))
is_controller = (node.startswith('ocp') or
node.startswith('crc'))
node_data = {
'ip': node_ip,
'user': hosts_data[node]['ansible_user'],
@ -256,7 +257,8 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
'cat ' + WB_CONF.proxy_host_inventory_path))
is_crc = False
ocps = inventory_data['all']['children']['ocps']
if 'hosts' in ocps and 'crc' in ocps['hosts'].keys():
if 'hosts' in ocps and any(ocp_key.startswith('crc')
for ocp_key in ocps['hosts'].keys()):
is_crc = True
else:
# create ocp_node_yaml_list