Do not call GET for PowerOff, Shutdown, and Reset actions for
transient VMs.
Also return an error for Delete of transient VMs, since
libvirt does not support this operation.
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/control/vms.py | 9 ++++++---
src/kimchi/i18n.py | 1 +
src/kimchi/model/vms.py | 3 +++
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index 1a84b6c..5068b7c 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -40,9 +40,12 @@ def __init__(self, model, ident):
for ident, node in sub_nodes.items():
setattr(self, ident, node(model, self.ident))
self.start = self.generate_action_handler('start')
- self.poweroff = self.generate_action_handler('poweroff')
- self.shutdown = self.generate_action_handler('shutdown')
- self.reset = self.generate_action_handler('reset')
+ self.poweroff = self.generate_action_handler('poweroff',
+ destructive=True)
+ self.shutdown = self.generate_action_handler('shutdown',
+ destructive=True)
+ self.reset = self.generate_action_handler('reset',
+ destructive=True)
self.connect = self.generate_action_handler('connect')
self.clone = self.generate_action_handler_task('clone')
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 4eccc3e..4ab08d1 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -106,6 +106,7 @@
"KCHVM0033E": _("Virtual machine '%(name)s' must be stopped
before cloning it."),
"KCHVM0034E": _("Insufficient disk space to clone virtual machine
'%(name)s'"),
"KCHVM0035E": _("Unable to clone VM '%(name)s'. Details:
%(err)s"),
+ "KCHVM0036E": _("Invalid operation for non-persistent virtual machine
%(name)s"),
"KCHVMHDEV0001E": _("VM %(vmid)s does not contain directly assigned
host device %(dev_name)s."),
"KCHVMHDEV0002E": _("The host device %(dev_name)s is not allowed to
directly assign to VM."),
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 9987786..86a2a1f 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -836,6 +836,9 @@ def get_vm(name, conn):
def delete(self, name):
conn = self.conn.get()
dom = self.get_vm(name, self.conn)
+ if not dom.isPersistent():
+ raise InvalidOperation("KCHVM0036E", {'name': name})
+
self._vmscreenshot_delete(dom.UUIDString())
paths = self._vm_get_disk_paths(dom)
info = self.lookup(name)
--
1.9.3