node_check fails to evaluate down hypervisors
Change-Id: Id5c4406cb953c999fcc9cd96e8083a1c418b239b
This commit is contained in:

committed by
Sawan Choudhary

parent
ace2c424f1
commit
e63302c863
@@ -373,48 +373,44 @@ class operator_scenario(base.Scenario):
|
|||||||
|
|
||||||
@base.scenario(admin_only=False, operator=True)
|
@base.scenario(admin_only=False, operator=True)
|
||||||
def node_check(self):
|
def node_check(self):
|
||||||
failed_hosts = None
|
failed_hosts = []
|
||||||
self.load()
|
self.load()
|
||||||
nodes_from_ansible_config = [node.name.lower()
|
nodes_from_ansible_config = [node.name for node in
|
||||||
for node in
|
|
||||||
self.os_node_info_obj.get_host_list()
|
self.os_node_info_obj.get_host_list()
|
||||||
if "compute" in node.role.split()]
|
if "compute" in node.role.split()]
|
||||||
nova_hypervisor_list = self._get_nova_hypervior_list()
|
nova_hypervisor_list = self._get_nova_hypervior_list()
|
||||||
if nova_hypervisor_list[0] != 200:
|
if nova_hypervisor_list[0] != 200:
|
||||||
return (404, ("Cannot get hypervisor list from "
|
return (404, ("Cannot get hypervisor list from "
|
||||||
"Nova reason-%sa") % nova_hypervisor_list[1])
|
"Nova reason-%sa") % nova_hypervisor_list[1])
|
||||||
nodes_from_nova = [node.lower() for node in nova_hypervisor_list[2]]
|
nodes_from_nova = [node for node in nova_hypervisor_list[2]]
|
||||||
extra_nodes_nova = set(
|
|
||||||
nodes_from_nova) - set(nodes_from_ansible_config)
|
|
||||||
extra_nodes_ansible = set(
|
|
||||||
nodes_from_ansible_config) - set(nodes_from_nova)
|
|
||||||
if extra_nodes_nova:
|
|
||||||
return (404, ("Hypervisors in nova hypervisor list are more"
|
|
||||||
" than configured.nova hypervisor list = %s") %
|
|
||||||
nodes_from_nova)
|
|
||||||
if extra_nodes_ansible:
|
|
||||||
return (404, ("Hypervisors in nova hypervisor list are less"
|
|
||||||
" than configured.nova hypervisor list = %s") %
|
|
||||||
nodes_from_nova)
|
|
||||||
|
|
||||||
anscmd = ("ansible -o all -i '%s' -m ping -u root" %
|
anscmd = ("ansible -o all -i '%s' -m ping -u root" %
|
||||||
','.join(nova_hypervisor_list[2]))
|
','.join(nodes_from_ansible_config))
|
||||||
res = execute(anscmd)
|
res = execute(anscmd)
|
||||||
res['output'] = res['output'].split('\n')
|
res['output'] = res['output'].split('\n')
|
||||||
output = filter(lambda x: not re.match(r'^\s*$', x), res['output'])
|
output = filter(lambda x: not re.match(r'^\s*$', x), res['output'])
|
||||||
for line in output:
|
for line in output:
|
||||||
if "SUCCESS" not in line:
|
if "SUCCESS" not in line:
|
||||||
failed_hosts = failed_hosts + line.split('|')[0]
|
failed_hosts.append(line.split('|')[0].strip())
|
||||||
|
|
||||||
if not res['status']:
|
# Check if ansible ping cmd failed with reason other than unreachable
|
||||||
return (200, "All nodes are up.nova hypervisor list = %s" %
|
# nodes
|
||||||
nodes_from_nova)
|
if res['status'] and not failed_hosts:
|
||||||
|
return (404, "Unable to perform ping test on nodes, ansible cmd: "
|
||||||
|
"'%s' failed" % anscmd)
|
||||||
|
|
||||||
|
# Check if nova also recognizes that passed nodes were up
|
||||||
|
nova_failed_hosts = [node for node in nodes_from_ansible_config if
|
||||||
|
node not in nodes_from_nova]
|
||||||
|
failed_hosts = list(set(nova_failed_hosts + failed_hosts))
|
||||||
|
|
||||||
|
if not failed_hosts:
|
||||||
|
return (200, "All nodes are up. nova hypervisor list = %s" %
|
||||||
|
', '.join(nodes_from_nova))
|
||||||
else:
|
else:
|
||||||
msg = "Some nodes are not up"
|
msg = ("The following nodes are down: %s. nova hypervisor list = "
|
||||||
if failed_hosts:
|
"%s" % (', '.join(failed_hosts),
|
||||||
msg = ("The following nodes are not up: %s."
|
', '.join(nodes_from_nova)))
|
||||||
"nova hypervisor list = %s" %
|
|
||||||
(str(failed_hosts[0]), nodes_from_nova))
|
|
||||||
return (404, msg)
|
return (404, msg)
|
||||||
|
|
||||||
@base.scenario(admin_only=False, operator=True)
|
@base.scenario(admin_only=False, operator=True)
|
||||||
|
Reference in New Issue
Block a user