Fix bugs in qvm-shutdown --all
- Exit the program if all domains are halted - Changed log.notice to log.info - Replace map with dictionary comprehensions (pylint)
This commit is contained in:
parent
1ff1ca37a1
commit
a66df9c82e
@ -53,8 +53,7 @@ parser.add_argument('--timeout',
|
|||||||
def main(args=None):
|
def main(args=None):
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
for vm in args.domains:
|
[vm.shutdown(force=args.force) for vm in args.domains if not vm.is_halted()]
|
||||||
vm.shutdown(force=args.force)
|
|
||||||
|
|
||||||
if not args.wait:
|
if not args.wait:
|
||||||
return
|
return
|
||||||
@ -64,13 +63,16 @@ def main(args=None):
|
|||||||
while timeout >= 0:
|
while timeout >= 0:
|
||||||
current_vms = [vm for vm in current_vms
|
current_vms = [vm for vm in current_vms
|
||||||
if vm.get_power_state() != 'Halted']
|
if vm.get_power_state() != 'Halted']
|
||||||
|
if not current_vms:
|
||||||
|
return 0
|
||||||
args.app.log.info('Waiting for shutdown ({}): {}'.format(
|
args.app.log.info('Waiting for shutdown ({}): {}'.format(
|
||||||
timeout, ', '.join(map(str, current_vms))))
|
timeout, ', '.join([str(vm) for vm in current_vms])))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
timeout -= 1
|
timeout -= 1
|
||||||
|
|
||||||
args.app.log.notice(
|
args.app.log.info(
|
||||||
'Killing remaining qubes: {}'.format(', '.join(map(str, current_vms))))
|
'Killing remaining qubes: {}'
|
||||||
|
.format(', '.join([str(vm) for vm in current_vms])))
|
||||||
for vm in current_vms:
|
for vm in current_vms:
|
||||||
vm.force_shutdown()
|
vm.force_shutdown()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user