
Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 02/10/2014 05:48 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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@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]]