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:
Bahtiar `kalkin-` Gadimov 2016-06-29 17:25:07 +02:00
parent 1ff1ca37a1
commit a66df9c82e
No known key found for this signature in database
GPG Key ID: 96ED3C3BA19C3DEE

View File

@ -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()