+++ /dev/null
-#!/usr/bin/python
-# mclu (mini cluster)
-# Copyright (C) 2014 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-import argparse
-import fnmatch
-import re
-import subprocess
-import sys
-import libvirt
-
-import config
-import lib
-
-def cmdline (subparsers):
- p = subparsers.add_parser (
- 'start',
- 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):
- _, inactive = lib.get_all_guests (c)
-
- # User supplied a list of node:VMs.
- for a in args.vms:
- m = re.match (r'^(.*):(.*)$', a)
- if m:
- node_name = m.group (1)
- wc = m.group (2)
- else:
- wc = a
- 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", 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:
- sys.exit ("error: no VMs matched pattern %s" % a)
-
- # Make sure we don't start the same VMs again the next
- # time around the loop:
- for vm_name in started:
- del inactive[vm_name]