3 # Copyright (C) 2014 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 def cmdline (subparsers):
30 p = subparsers.add_parser (
32 help='start virtual machine(s)',
35 '--viewer', action='store_const', const=True,
36 help='start virt-viewer to show the graphical console'
40 help='virtual machine(s) to be started'
42 p.set_defaults (run=run)
45 _, inactive = lib.get_all_guests (c)
47 # User supplied a list of node:VMs.
49 m = re.match (r'^(.*):(.*)$', a)
51 node_name = m.group (1)
55 node_name = lib.pick_any_node_which_is_up (c)
57 for vm_name in inactive:
58 if fnmatch.fnmatch (vm_name, wc):
60 subprocess.Popen ([config.VIRT_VIEWER,
61 "-c", lib.uri_of_node (node_name),
64 lib.start_guest (c, node_name, vm_name)
65 started.append (vm_name)
68 sys.exit ("error: no VMs matched pattern %s" % a)
70 # Make sure we don't start the same VMs again the next
71 # time around the loop:
72 for vm_name in started: