diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/base.py b/whitebox_neutron_tempest_plugin/tests/scenario/base.py index 8b79b75..728459a 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/base.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/base.py @@ -19,7 +19,6 @@ from multiprocessing import Process import os import random import re -import socket import time import yaml @@ -210,18 +209,18 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): def get_ocp_main_ip(host): LOG.debug('Searching for OCP node main IP corresponding to %s', host) - ocp_ip = socket.gethostbyname(host) for ocp_node_yaml in ocp_node_yaml_list: - # eval is needed here to convert a string into a list - for cidr in eval(ocp_node_yaml[ - 'metadata']['annotations']['k8s.ovn.org/host-cidrs']): - if ocp_ip == cidr.split('/')[0]: - for address in ocp_node_yaml['status']['addresses']: - if address['type'] == 'InternalIP': - ocp_main_ip = address['address'] - LOG.debug('IP address found for %s: %s', - host, ocp_main_ip) - return ocp_main_ip + ocp_main_ip = None + ocp_hostname = None + for address in ocp_node_yaml['status']['addresses']: + if address['type'] == 'InternalIP': + ocp_main_ip = address['address'] + if address['type'] == 'Hostname': + ocp_hostname = address['address'] + if ocp_main_ip and ocp_hostname == host.split('.')[0]: + LOG.debug('IP address found for %s: %s', host, ocp_main_ip) + return ocp_main_ip + LOG.warning('No IP address found for %s', host) return host