From: Crístian Viana <vianac(a)linux.vnet.ibm.com>
Some functions assume that a VM can only be in two states: shutoff and
running. However, that's not always the case (e.g. not being running
doesn't mean it's shutoff).
Update some functions so the VM state conditions are more accurate.
Signed-off-by: Crístian Deives <cristiandeives(a)gmail.com>
---
src/kimchi/model/vms.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index c39a407..fd5aad5 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -754,7 +754,7 @@ class VMModel(object):
try:
if 'name' in params:
state = DOM_STATE_MAP[dom.info()[0]]
- if state == 'running':
+ if state != 'shutoff':
msg_args = {'name': vm_name, 'new_name':
params['name']}
raise InvalidParameter("KCHVM0003E", msg_args)
@@ -891,7 +891,7 @@ class VMModel(object):
paths = self._vm_get_disk_paths(dom)
info = self.lookup(name)
- if info['state'] == 'running':
+ if info['state'] != 'shutoff':
self.poweroff(name)
# delete existing snapshots before deleting VM
--
2.1.0