qvm-tools: qvm-run: eturn exitcode!=0 if any command failed
This commit is contained in:
parent
b0ec7c7b01
commit
17709dcce9
@ -58,19 +58,19 @@ def vm_run_cmd(vm, cmd, options):
|
|||||||
if str(err).startswith("There are other VMs connected"):
|
if str(err).startswith("There are other VMs connected"):
|
||||||
print >> sys.stderr, "Shutdown them first or use --force switch"
|
print >> sys.stderr, "Shutdown them first or use --force switch"
|
||||||
exit(1)
|
exit(1)
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if options.pause:
|
if options.pause:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print >> sys.stderr, "Pausing VM: '{0}'...".format(vm.name)
|
print >> sys.stderr, "Pausing VM: '{0}'...".format(vm.name)
|
||||||
vm.pause()
|
vm.pause()
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if options.unpause:
|
if options.unpause:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print >> sys.stderr, "UnPausing VM: '{0}'...".format(vm.name)
|
print >> sys.stderr, "UnPausing VM: '{0}'...".format(vm.name)
|
||||||
vm.unpause()
|
vm.unpause()
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print >> sys.stderr, "Running command on VM: '{0}'...".format(vm.name)
|
print >> sys.stderr, "Running command on VM: '{0}'...".format(vm.name)
|
||||||
@ -193,8 +193,10 @@ def main():
|
|||||||
exit(1)
|
exit(1)
|
||||||
vms_list.append(vm)
|
vms_list.append(vm)
|
||||||
|
|
||||||
|
retcode = 0
|
||||||
for vm in vms_list:
|
for vm in vms_list:
|
||||||
vm_run_cmd(vm, cmdstr, options)
|
r = vm_run_cmd(vm, cmdstr, options)
|
||||||
|
retcode = max(r, retcode)
|
||||||
|
|
||||||
if options.wait_for_shutdown:
|
if options.wait_for_shutdown:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
@ -217,5 +219,6 @@ def main():
|
|||||||
shutdown_counter += 1
|
shutdown_counter += 1
|
||||||
time.sleep (1)
|
time.sleep (1)
|
||||||
exit (0) # there is no point in executing the other daemons in the case of --wait
|
exit (0) # there is no point in executing the other daemons in the case of --wait
|
||||||
|
exit(retcode)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user