mclu: Add --viewer option to mclu start, to start virt-viewer.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 10 May 2014 14:44:39 +0000 (15:44 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 10 May 2014 14:44:39 +0000 (15:44 +0100)
mclu_start.py

index 1187942..50d58c9 100644 (file)
 import argparse
 import fnmatch
 import re
+import subprocess
 import sys
 import libvirt
 
+import config
 import lib
 
 def cmdline (subparsers):
@@ -30,6 +32,10 @@ def cmdline (subparsers):
         help='start virtual machine(s)',
     )
     p.add_argument (
+        '--viewer', action='store_const', const=True,
+        help='start virt-viewer to show the graphical console'
+    )
+    p.add_argument (
         'vms', nargs='+',
         help='virtual machine(s) to be started'
     )
@@ -53,6 +59,10 @@ def run (c, args, nodes):
         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],
+                                      close_fds=True)
                 lib.start_guest (c, node, vm_name)
                 started.append (vm_name)