-def pick_any_node_which_is_up (nodes):
- node = None
- for n in nodes.values():
- if n.ping ():
- node = n
- break
- if not node:
- sys.exit ("error: no nodes are up, use mclu on [node|--all]")
- return node
+def pick_any_node_which_is_up (c):
+ inventory = ansible.inventory.Inventory ()
+ runner = ansible.runner.Runner (
+ remote_user = 'root',
+ module_name = 'ping',
+ inventory = inventory,
+ pattern = c['nodes_group'],
+ )
+ data = runner.run ()
+ if len (data['contacted']) == 0:
+ sys.exit ("error: no nodes are up, use mclu on")
+ return data['contacted'].keys()[0]
+
+# XXX Make this configurable.
+def uri_of_node (node_name):
+ return "qemu+ssh://root@%s/system" % node_name