Check [whitebox]/hypervisors before using it
A devstack deployment will not set [whitebox]/hypervisors because the host IPs are not known by the whitebox devstack plugin. Therefore, instead of always using the [whitebox]/hypervisors option blindly, this patch starts checking it for truthiness first. If false, we fallback on using the hostname from the OS-EXT-SRV-ATTR:host field in the show server response, or from the list hypervisors API. In a devstack deployment, both of these should contain hostnames that are resolvable and reachable from the machine running the tests. This patch also reworks get_hypervisor_ip() to be cleaner. Change-Id: I1a4430b6ee668bb34c847a63246a14b704185432
This commit is contained in:
parent
1d1b3dae29
commit
12a84871bf
@ -102,17 +102,27 @@ class BaseWhiteboxComputeTest(base.BaseV2ComputeAdminTest):
|
||||
def get_hypervisor_ip(self, server_id):
|
||||
server = self.servers_client.show_server(server_id)
|
||||
host = server['server']['OS-EXT-SRV-ATTR:host']
|
||||
try:
|
||||
|
||||
if not CONF.whitebox.hypervisors:
|
||||
# NOTE(artom) [whitebox]/hypervisors not being set means we're
|
||||
# running against a devstack deployment and we can just use host
|
||||
# directly.
|
||||
return host
|
||||
|
||||
if host in CONF.whitebox.hypervisors:
|
||||
return CONF.whitebox.hypervisors[host]
|
||||
except KeyError:
|
||||
raise exceptions.MissingHypervisorException(server=server_id,
|
||||
host=host)
|
||||
|
||||
raise exceptions.MissingHypervisorException(server=server_id,
|
||||
host=host)
|
||||
|
||||
def get_all_hypervisors(self):
|
||||
"""Returns a list of all hypervisor IPs in the deployment. Assumes all
|
||||
are up and running.
|
||||
"""
|
||||
return CONF.whitebox.hypervisors.values()
|
||||
if CONF.whitebox.hypervisors:
|
||||
return CONF.whitebox.hypervisors.values()
|
||||
hvs = self.hypervisor_client.list_hypervisors()['hypervisors']
|
||||
return [hv['hypervisor_hostname'] for hv in hvs]
|
||||
|
||||
def get_server_xml(self, server_id):
|
||||
hv_ip = self.get_hypervisor_ip(server_id)
|
||||
|
@ -325,11 +325,15 @@ class CPUThreadPolicyTest(BasePinningTest):
|
||||
"""
|
||||
siblings = {}
|
||||
|
||||
try:
|
||||
host_address = CONF.whitebox.hypervisors[host]
|
||||
except KeyError:
|
||||
raise exceptions.MissingHypervisorException(server="",
|
||||
host=host)
|
||||
if CONF.whitebox.hypervisors:
|
||||
try:
|
||||
host_address = CONF.whitebox.hypervisors[host]
|
||||
except KeyError:
|
||||
raise exceptions.MissingHypervisorException(server="",
|
||||
host=host)
|
||||
else:
|
||||
host_address = host
|
||||
|
||||
virshxml = clients.VirshXMLClient(host_address)
|
||||
capxml = virshxml.capabilities()
|
||||
root = ET.fromstring(capxml)
|
||||
|
Loading…
x
Reference in New Issue
Block a user