From 6a712ffe7af9f3536d0031716326d552a24724c9 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 31 Jul 2019 23:05:00 -0400 Subject: [PATCH] Don't crash if VM has invalid disks Useful if storage=False and removing a VM. --- client-common/vm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client-common/vm.py b/client-common/vm.py index 71d6345c..36c81138 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -261,10 +261,13 @@ def remove_vm(zk_conn, domain, is_cli=False): # Remove disks for disk in disk_list: # vmpool/vmname_volume - disk_pool, disk_name = disk.split('/') - retcode, message = ceph.remove_volume(zk_conn, disk_pool, disk_name) - if is_cli and message: - click.echo('{}'.format(message)) + try: + disk_pool, disk_name = disk.split('/') + retcode, message = ceph.remove_volume(zk_conn, disk_pool, disk_name) + if is_cli and message: + click.echo('{}'.format(message)) + except ValueError: + continue return True, 'Removed VM "{}" and disks from the cluster.'.format(domain)