X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=mclu_status.py;h=add55ab46a608aee3bdd5a8db61252290a52f3ab;hb=3a20c16f4a7581382be469f1ced6692bd973a77f;hp=81b9fb0df487a9b5a894fccbde61001680308e6b;hpb=4040ab9e21c2b78d4361798351dde57cd7ca67ef;p=mclu.git diff --git a/mclu_status.py b/mclu_status.py index 81b9fb0..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 "\tlibvirt: dead" - else: - print "\tssh: dead" - else: - print "\tdown" +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