[Kimchi-devel] [PATCH] bug fix: failed to update vm with unicode name

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Mon Jan 27 02:56:48 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.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.py b/src/kimchi/model.py
index 55de570..6590ca3 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -504,7 +504,7 @@ class Model(object):
         dom = self._get_vm(name)
         dom = self._static_vm_update(dom, params)
         self._live_vm_update(dom, params)
-        return dom.name()
+        return dom.name().decode('utf-8')
 
     def vm_lookup(self, name):
         dom = self._get_vm(name)
-- 
1.8.4.2




More information about the Kimchi-devel mailing list