Find OCP nodes based on hostname instead of list of CIDRs
For some reason, the list of CIDRs from an OCP node sometimes does not include some of its IP addresses. The method `get_ocp_main_ip` will use the hostname in order to identify OCP nodes instead. Change-Id: Ie3e4460d9d338aed21f62b4b17471aef26bebd4a
This commit is contained in:
parent
c1c17025c6
commit
11d863ac35
@ -19,7 +19,6 @@ from multiprocessing import Process
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import socket
|
|
||||||
import time
|
import time
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -210,18 +209,18 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
|
|||||||
def get_ocp_main_ip(host):
|
def get_ocp_main_ip(host):
|
||||||
LOG.debug('Searching for OCP node main IP corresponding to %s',
|
LOG.debug('Searching for OCP node main IP corresponding to %s',
|
||||||
host)
|
host)
|
||||||
ocp_ip = socket.gethostbyname(host)
|
|
||||||
for ocp_node_yaml in ocp_node_yaml_list:
|
for ocp_node_yaml in ocp_node_yaml_list:
|
||||||
# eval is needed here to convert a string into a list
|
ocp_main_ip = None
|
||||||
for cidr in eval(ocp_node_yaml[
|
ocp_hostname = None
|
||||||
'metadata']['annotations']['k8s.ovn.org/host-cidrs']):
|
for address in ocp_node_yaml['status']['addresses']:
|
||||||
if ocp_ip == cidr.split('/')[0]:
|
if address['type'] == 'InternalIP':
|
||||||
for address in ocp_node_yaml['status']['addresses']:
|
ocp_main_ip = address['address']
|
||||||
if address['type'] == 'InternalIP':
|
if address['type'] == 'Hostname':
|
||||||
ocp_main_ip = address['address']
|
ocp_hostname = address['address']
|
||||||
LOG.debug('IP address found for %s: %s',
|
if ocp_main_ip and ocp_hostname == host.split('.')[0]:
|
||||||
host, ocp_main_ip)
|
LOG.debug('IP address found for %s: %s', host, ocp_main_ip)
|
||||||
return ocp_main_ip
|
return ocp_main_ip
|
||||||
|
|
||||||
LOG.warning('No IP address found for %s', host)
|
LOG.warning('No IP address found for %s', host)
|
||||||
return host
|
return host
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user