Rewrite to use ansible.
[mclu.git] / mclu_start.py
index 50d58c9..01a2f1a 100644 (file)
@@ -41,8 +41,8 @@ def cmdline (subparsers):
     )
     p.set_defaults (run=run)
 
-def run (c, args, nodes):
-    _, inactive = lib.get_all_guests (c, nodes.values ())
+def run (c, args):
+    _, inactive = lib.get_all_guests (c)
 
     # User supplied a list of node:VMs.
     for a in args.vms:
@@ -50,20 +50,18 @@ def run (c, args, nodes):
         if m:
             node_name = m.group (1)
             wc = m.group (2)
-            if node_name not in nodes:
-                sys.exit ("error: node %s does not exist" % node_name)
-            node = nodes[node_name]
         else:
             wc = a
-            node = lib.pick_any_node_which_is_up (nodes)
+            node_name = lib.pick_any_node_which_is_up (c)
         started = []
         for vm_name in inactive:
             if fnmatch.fnmatch (vm_name, wc):
                 if args.viewer:
-                    subprocess.Popen ([config.VIRT_VIEWER, "-c",
-                                       node.uri, vm_name],
+                    subprocess.Popen ([config.VIRT_VIEWER,
+                                       "-c", lib.uri_of_node (node_name),
+                                       vm_name],
                                       close_fds=True)
-                lib.start_guest (c, node, vm_name)
+                lib.start_guest (c, node_name, vm_name)
                 started.append (vm_name)
 
         if not started: