qvm-shutdown: Allow multiple VMs to be shut down with one invocation

Prior to this commit, qvm-shutdown had a limitation where only one
VM name could be passed in via the command line for shutting down.

This commit removes the aforementioned limitation by adapting the
code for multiple command line arguments.

Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
This commit is contained in:
M. Vefa Bicakci 2017-03-14 16:36:51 +03:00 committed by Marek Marczykowski-Górecki
parent 1d9d59a335
commit e499e6e88c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -47,7 +47,7 @@ def main():
"repeated)") "repeated)")
(options, args) = parser.parse_args () (options, args) = parser.parse_args ()
if not options.shutdown_all and (len (args) != 1): if not options.shutdown_all and not args:
parser.error ("You must specify VM name!") parser.error ("You must specify VM name!")
qvm_collection = QubesVmCollection() qvm_collection = QubesVmCollection()
@ -66,12 +66,12 @@ def main():
if vm.is_running(): if vm.is_running():
vms_list.append (vm) vms_list.append (vm)
else: else:
vmname = args[0] for vmname in args:
vm = qvm_collection.get_vm_by_name(vmname) vm = qvm_collection.get_vm_by_name(vmname)
if vm is None: if vm is None:
print >> sys.stderr, "A VM with the name '{0}' does not exist in the system!".format(vmname) print >> sys.stderr, "A VM with the name '{0}' does not exist in the system!".format(vmname)
exit(1) exit(1)
vms_list.append(vm) vms_list.append(vm)
# Check VMs network dependencies # Check VMs network dependencies
if not options.force: if not options.force: