33 actions.append(list_clusters)
35 actions.append(list_admin_vms)
36 actions.append(list_nodes)
39 actions.append({
'type':
'pyscript',
40 'description':
'Compare number of dnsmasq processes with virtual machines on node',
47 # walk over all nodes (from previous actions - list_nodes)
48 for node in stored_results['nodes']:
49 # Check only unlocked nodes (state == ok)
50 if node['state'] == 1:
51 # Count all dnsmasq processes
52 p = subprocess.Popen('ssh cc1@%s "pgrep -c dnsmasq"' % node['address'], shell=True, stdout=subprocess.PIPE)
55 log = log + 'Node %s is not responding (ssh)\\n' % node['address']
58 dnsmasq = int(p.stdout.read())
61 # Collect all vms on this node
62 for vm in stored_results['admin_vms']:
63 if vm['node'] == node['address']:
64 vms_on_node.append(vm)
66 # Compare dnsmasq processes with vms on node
67 if len(vms_on_node) != dnsmasq:
69 log = log + "Node %s has inconsistent networking\\n" % node["address"]
71 log = log + 'Exception: %s' % str(e)
73 traceback.print_exc(limit=sys.getrecursionlimit())
77 actions.append({
'type':
'pyscript',
78 'description':
'Compare bridges with libvirt networks',
85 for node in stored_results['nodes']:
86 if node['state'] == 1:
87 # List all bridges on node without vm interfaces (which also are called bridgeNNNN-nic
88 p = subprocess.Popen('ssh cc1@%s "ls -1 /sys/class/net/ | grep br | grep -v nic"' % node['address'], shell=True, stdout=subprocess.PIPE)
91 log = log + 'Node %s is not responding (ssh)\\n' % node['address']
94 # Prepare output to easy compare with virsh output
95 bridges = p.stdout.read().splitlines()
96 bridges = [b.replace('br', 'net') for b in bridges]
98 # Ask libvirt to list networks on node
99 p = subprocess.Popen('ssh cc1@%s "virsh -q -c qemu:///system net-list | tr -s \\' \\' | cut -d \\' \\' -f 1"' % node['address'], shell=True, stdout=subprocess.PIPE)
102 log = log + 'Node %s is not responding (virsh)\\n' % node['address']
104 networks = p.stdout.read().splitlines()
109 # Compare two outputs
110 if networks != bridges:
112 log = log + "Node %s has inconsistent networking\\n" % node["address"]
114 log = log + 'Exception: %s' % str(e)
116 traceback.print_exc(limit=sys.getrecursionlimit())