import argparse
import fnmatch
import re
+import subprocess
import sys
import libvirt
+import config
import lib
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'
)
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:
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):
- lib.start_guest (c, node, vm_name)
+ if args.viewer:
+ subprocess.Popen ([config.VIRT_VIEWER,
+ "-c", lib.uri_of_node (node_name),
+ vm_name],
+ close_fds=True)
+ lib.start_guest (c, node_name, vm_name)
started.append (vm_name)
if not started: