[Kimchi-devel] [RESEND][PATCH 2/4] reset VM in backend.
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Mon Apr 14 05:52:05 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
update mockmodel, model and controller.
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/control/vms.py | 1 +
src/kimchi/i18n.py | 1 +
src/kimchi/mockmodel.py | 3 +++
src/kimchi/model/vms.py | 8 ++++++++
4 files changed, 13 insertions(+)
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index e75b27f..b84df76 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -39,6 +39,7 @@ class VM(Resource):
setattr(self, ident, node(model, self.ident))
self.start = self.generate_action_handler('start')
self.poweroff = self.generate_action_handler('poweroff')
+ self.reset = self.generate_action_handler('reset')
self.connect = self.generate_action_handler('connect')
@property
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index ae8d24e..96220d8 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -80,6 +80,7 @@ messages = {
"KCHVM0019E": _("Unable to start virtual machine %(name)s. Details: %(err)s"),
"KCHVM0020E": _("Unable to power off virtual machine %(name)s. Details: %(err)s"),
"KCHVM0021E": _("Unable to delete virtual machine %(name)s. Details: %(err)s"),
+ "KCHVM0022E": _("Unable to reset virtual machine %(name)s. Details: %(err)s"),
"KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
"KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index bf17975..69eee3c 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -133,6 +133,9 @@ class MockModel(object):
def vm_poweroff(self, name):
self._get_vm(name).info['state'] = 'shutoff'
+ def vm_reset(self, name):
+ pass
+
def vm_connect(self, name):
pass
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 2425a43..7c48583 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -391,6 +391,14 @@ class VMModel(object):
raise OperationFailed("KCHVM0020E",
{'name': name, 'err': e.get_error_message()})
+ def reset(self, name):
+ dom = self.get_vm(name, self.conn)
+ try:
+ dom.reset(flags=0)
+ except libvirt.libvirtError as e:
+ raise OperationFailed("KCHVM0022E",
+ {'name': name, 'err': e.get_error_message()})
+
def _vm_get_graphics(self, name):
dom = self.get_vm(name, self.conn)
xml = dom.XMLDesc(0)
--
1.8.5.3
More information about the Kimchi-devel
mailing list