[Kimchi-devel] [PATCH V2 1/3] bug fix: failed to update vm with unicode name
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Mon Feb 10 07:48:39 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
update a vm's name with unicode name, kimchi will report error.
$ curl -u <user> -H 'Accept: application/json' \
-H 'Content-type: application/json' \
http://localhost:8000/vms/u13.10 -X PUT -d '
{"name": "kīмсhī-∨м"}'
There are two bugs:
1. typo
encode the ident with "utf8" when HTTPRedirect
change it to "utf-8"
2. The name form libvirt is str, need decode.
ref:
https://github.com/kimchi-project/kimchi/wiki/support-unicode
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/control/base.py | 2 +-
src/kimchi/model/vms.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index f50ff6e..0b656ab 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -154,7 +154,7 @@ class Resource(object):
ident = update(self.ident, params)
if ident != self.ident:
uri_params = list(self.model_args[:-1])
- uri_params += [urllib2.quote(ident.encode('utf8'))]
+ uri_params += [urllib2.quote(ident.encode('utf-8'))]
raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), 303)
return self.get()
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index d4384a1..1244eeb 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -222,7 +222,7 @@ class VMModel(object):
dom = self.get_vm(name, self.conn)
dom = self._static_vm_update(dom, params)
self._live_vm_update(dom, params)
- return dom.name()
+ return dom.name().decode('utf-8')
def _static_vm_update(self, dom, params):
state = DOM_STATE_MAP[dom.info()[0]]
--
1.8.4.2
More information about the Kimchi-devel
mailing list