X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=mclu_status.py;h=add55ab46a608aee3bdd5a8db61252290a52f3ab;hb=3a20c16f4a7581382be469f1ced6692bd973a77f;hp=3d8fa746fdd4c8b2facc51ba70954c1778c50231;hpb=8f509fea52826d18df504f18ad0e702f54320f48;p=mclu.git diff --git a/mclu_status.py b/mclu_status.py index 3d8fa74..add55ab 100644 --- a/mclu_status.py +++ b/mclu_status.py @@ -18,6 +18,8 @@ import argparse +import ansible.runner + import lib def cmdline (subparsers): @@ -27,19 +29,14 @@ def cmdline (subparsers): ) p.set_defaults (run=run) -def run (c, args, nodes): - for node_name in sorted (nodes.keys ()): - node = nodes[node_name] - print "%s (%s)" % (node_name, node.host), - if node.ping(): - print "\tup", - if node.ssh_ping(): - print "\tssh: OK", - if node.libvirt_ping(): - print "\tlibvirt: OK" - else: - print "libvirt: dead" - else: - print "ssh: dead" - else: - print "down" +def run (c, args): + runner = ansible.runner.Runner ( + remote_user = 'root', + module_name = 'ping', + pattern = c['nodes_group'], + ) + data = runner.run () + for name in sorted (data['contacted']): + print "%s\tup" % name + for name in sorted (data['dark']): + print "%s\tdown" % name