Don't crash if VM has invalid disks

Useful if storage=False and removing a VM.
This commit is contained in:
Joshua Boniface 2019-07-31 23:05:00 -04:00
parent 7380f45b1b
commit 6a712ffe7a
1 changed files with 7 additions and 4 deletions

View File

@ -261,10 +261,13 @@ def remove_vm(zk_conn, domain, is_cli=False):
# Remove disks # Remove disks
for disk in disk_list: for disk in disk_list:
# vmpool/vmname_volume # vmpool/vmname_volume
disk_pool, disk_name = disk.split('/') try:
retcode, message = ceph.remove_volume(zk_conn, disk_pool, disk_name) disk_pool, disk_name = disk.split('/')
if is_cli and message: retcode, message = ceph.remove_volume(zk_conn, disk_pool, disk_name)
click.echo('{}'.format(message)) if is_cli and message:
click.echo('{}'.format(message))
except ValueError:
continue
return True, 'Removed VM "{}" and disks from the cluster.'.format(domain) return True, 'Removed VM "{}" and disks from the cluster.'.format(domain)