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.
24 def cmdline (subparsers):
25 p = subparsers.add_parser (
27 help='list virtual machines',
30 '--running', action='store_const', const=True,
31 help='list only running VMs'
34 '--inactive', action='store_const', const=True,
35 help='list only inactive VMs'
37 p.set_defaults (run=run)
42 if not args.running or not args.inactive:
50 running, inactive = lib.get_all_guests (c)
53 for guest in sorted (running.values()):
54 node_name = guest['node']
55 dom_name = guest['vm']
56 full_name = "%s:%s" % (node_name, dom_name)
57 print "%-40s running" % full_name
60 for name in sorted (inactive.values()):
61 print "%-40s inactive" % name