[Kimchi-devel] [PATCH] Issue #100: do not delete the VM when storage volume not found
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Jun 5 13:18:10 UTC 2014
On 05/09/2014 07:33 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> The VM may not be in a certain pool for some reasons.
> Or the pool may not be active for some reasons.
>
> We do not allow to delete this VM in this case.
> And report the detail message to user.
And if the sysadmin has already deleted the volumes, the he will not be
able to delete the VM?
I think deleting the volume should not block deleting the VM.
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
> src/kimchi/model/vms.py | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 17bda04..3201fdd 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -426,14 +426,25 @@ class VMModel(object):
> if info['state'] == 'running':
> self.poweroff(name)
>
> + vols = []
> + for path in paths:
> + try:
> + vols.append(conn.storageVolLookupByPath(path))
> + except libvirt.libvirtError as e:
> + if e.get_error_code() == libvirt.VIR_ERR_NO_STORAGE_VOL:
> + raise OperationFailed(
> + "KCHVM0021E",
> + {'name': name, 'err': e.get_error_message()})
> + else:
> + raise
> +
> try:
> dom.undefine()
> except libvirt.libvirtError as e:
> raise OperationFailed("KCHVM0021E",
> {'name': name, 'err': e.get_error_message()})
>
> - for path in paths:
> - vol = conn.storageVolLookupByPath(path)
> + for vol in vols:
> pool = vol.storagePoolLookupByVolume()
> xml = pool.XMLDesc(0)
> pool_type = xmlutils.xpath_get_text(xml, "/pool/@type")[0]
More information about the Kimchi-devel
mailing list