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.
27 def cmdline (subparsers):
28 p = subparsers.add_parser (
30 help='start virtual machine(s)',
34 help='virtual machine(s) to be started'
36 p.set_defaults (run=run)
38 def run (c, args, nodes):
39 _, inactive = lib.get_all_guests (c, nodes.values ())
41 # User supplied a list of node:VMs.
43 m = re.match (r'^(.*):(.*)$', a)
45 node_name = m.group (1)
47 if node_name not in nodes:
48 sys.exit ("error: node %s does not exist" % node_name)
49 node = nodes[node_name]
52 node = lib.pick_any_node_which_is_up (nodes)
54 for vm_name in inactive:
55 if fnmatch.fnmatch (vm_name, wc):
56 lib.start_guest (c, node, vm_name)
57 started.append (vm_name)
60 sys.exit ("error: no VMs matched pattern %s" % a)
62 # Make sure we don't start the same VMs again the next
63 # time around the loop:
64 for vm_name in started: