[PATCH] bug fix: remove decode for resouce ident when use cherrypy's default dispatcher

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Now there are two kinds of sub-collection/resource dispatchers. 1. Use cherrypy's default dispatcher Cherrypy will decode the ident automatically But now in kimchi we decode the ident manually. This is a bug. Kimchi can not list the resources with unicode name. For examle: create a pool with kīмсhī-pool name list this pool $ curl -u shhfeng -H 'Accept: application/json' \ -H 'Content-type: application/json' \ http://localhost:8000/storagepools/kīмсhī-pool kimchi will throw an UnicodeEncodeError. This patch fixes this bug. 2. customized dispatcher by overriding the cherrypy dispatcher We need to decode the ident explicitly. Now kimchi handles it correctly. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/control/storagepools.py | 2 +- src/kimchi/control/vms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py index 3b8ef79..881c61e 100644 --- a/src/kimchi/control/storagepools.py +++ b/src/kimchi/control/storagepools.py @@ -85,7 +85,7 @@ class StoragePool(Resource): self.uri_fmt = "/storagepools/%s" self.activate = self.generate_action_handler('activate') self.deactivate = self.generate_action_handler('deactivate') - self.storagevolumes = StorageVolumes(self.model, ident.decode("utf-8")) + self.storagevolumes = StorageVolumes(self.model, ident) @property def data(self): diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py index 06c7be3..60fc8ff 100644 --- a/src/kimchi/control/vms.py +++ b/src/kimchi/control/vms.py @@ -41,7 +41,7 @@ class VM(Resource): self.screenshot = VMScreenShot(model, ident) self.uri_fmt = '/vms/%s' for ident, node in sub_nodes.items(): - setattr(self, ident, node(model, self.ident.decode("utf-8"))) + setattr(self, ident, node(model, self.ident)) self.start = self.generate_action_handler('start') self.stop = self.generate_action_handler('stop') self.connect = self.generate_action_handler('connect') -- 1.8.4.2

On 01/27/2014 10:56 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Now there are two kinds of sub-collection/resource dispatchers. 1. Use cherrypy's default dispatcher Cherrypy will decode the ident automatically But now in kimchi we decode the ident manually. This is a bug. Kimchi can not list the resources with unicode name.
For examle: create a pool with kīмсhī-pool name list this pool $ curl -u shhfeng -H 'Accept: application/json' \ -H 'Content-type: application/json' \ http://localhost:8000/storagepools/kīмсhī-pool
kimchi will throw an UnicodeEncodeError.
This patch fixes this bug. This patch just fix bug. Do not support create a pool with unicode name.
2. customized dispatcher by overriding the cherrypy dispatcher We need to decode the ident explicitly. Now kimchi handles it correctly.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/control/storagepools.py | 2 +- src/kimchi/control/vms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py index 3b8ef79..881c61e 100644 --- a/src/kimchi/control/storagepools.py +++ b/src/kimchi/control/storagepools.py @@ -85,7 +85,7 @@ class StoragePool(Resource): self.uri_fmt = "/storagepools/%s" self.activate = self.generate_action_handler('activate') self.deactivate = self.generate_action_handler('deactivate') - self.storagevolumes = StorageVolumes(self.model, ident.decode("utf-8")) + self.storagevolumes = StorageVolumes(self.model, ident)
@property def data(self): diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py index 06c7be3..60fc8ff 100644 --- a/src/kimchi/control/vms.py +++ b/src/kimchi/control/vms.py @@ -41,7 +41,7 @@ class VM(Resource): self.screenshot = VMScreenShot(model, ident) self.uri_fmt = '/vms/%s' for ident, node in sub_nodes.items(): - setattr(self, ident, node(model, self.ident.decode("utf-8"))) + setattr(self, ident, node(model, self.ident)) self.start = self.generate_action_handler('start') self.stop = self.generate_action_handler('stop') self.connect = self.generate_action_handler('connect')
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

On 01/27/2014 11:05 AM, Sheldon wrote:
On 01/27/2014 10:56 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Now there are two kinds of sub-collection/resource dispatchers. 1. Use cherrypy's default dispatcher Cherrypy will decode the ident automatically But now in kimchi we decode the ident manually. This is a bug. Kimchi can not list the resources with unicode name.
For examle: create a pool with kīмсhī-pool name list this pool $ curl -u shhfeng -H 'Accept: application/json' \ -H 'Content-type: application/json' \ http://localhost:8000/storagepools/kīмсhī-pool
kimchi will throw an UnicodeEncodeError.
This patch fixes this bug. This patch just fix bug. Do not support create a pool with unicode name. see [PATCH] Storage pool support unicode correctly
2. customized dispatcher by overriding the cherrypy dispatcher We need to decode the ident explicitly. Now kimchi handles it correctly.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/control/storagepools.py | 2 +- src/kimchi/control/vms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py index 3b8ef79..881c61e 100644 --- a/src/kimchi/control/storagepools.py +++ b/src/kimchi/control/storagepools.py @@ -85,7 +85,7 @@ class StoragePool(Resource): self.uri_fmt = "/storagepools/%s" self.activate = self.generate_action_handler('activate') self.deactivate = self.generate_action_handler('deactivate') - self.storagevolumes = StorageVolumes(self.model, ident.decode("utf-8")) + self.storagevolumes = StorageVolumes(self.model, ident)
@property def data(self): diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py index 06c7be3..60fc8ff 100644 --- a/src/kimchi/control/vms.py +++ b/src/kimchi/control/vms.py @@ -41,7 +41,7 @@ class VM(Resource): self.screenshot = VMScreenShot(model, ident) self.uri_fmt = '/vms/%s' for ident, node in sub_nodes.items(): - setattr(self, ident, node(model, self.ident.decode("utf-8"))) + setattr(self, ident, node(model, self.ident)) self.start = self.generate_action_handler('start') self.stop = self.generate_action_handler('stop') self.connect = self.generate_action_handler('connect')
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 01/27/2014 12:56 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Now there are two kinds of sub-collection/resource dispatchers. 1. Use cherrypy's default dispatcher Cherrypy will decode the ident automatically But now in kimchi we decode the ident manually. This is a bug. Kimchi can not list the resources with unicode name.
For examle: create a pool with kīмсhī-pool name list this pool $ curl -u shhfeng -H 'Accept: application/json' \ -H 'Content-type: application/json' \ http://localhost:8000/storagepools/kīмсhī-pool
kimchi will throw an UnicodeEncodeError.
This patch fixes this bug.
2. customized dispatcher by overriding the cherrypy dispatcher We need to decode the ident explicitly. Now kimchi handles it correctly.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/control/storagepools.py | 2 +- src/kimchi/control/vms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py index 3b8ef79..881c61e 100644 --- a/src/kimchi/control/storagepools.py +++ b/src/kimchi/control/storagepools.py @@ -85,7 +85,7 @@ class StoragePool(Resource): self.uri_fmt = "/storagepools/%s" self.activate = self.generate_action_handler('activate') self.deactivate = self.generate_action_handler('deactivate') - self.storagevolumes = StorageVolumes(self.model, ident.decode("utf-8")) + self.storagevolumes = StorageVolumes(self.model, ident)
@property def data(self): diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py index 06c7be3..60fc8ff 100644 --- a/src/kimchi/control/vms.py +++ b/src/kimchi/control/vms.py @@ -41,7 +41,7 @@ class VM(Resource): self.screenshot = VMScreenShot(model, ident) self.uri_fmt = '/vms/%s' for ident, node in sub_nodes.items(): - setattr(self, ident, node(model, self.ident.decode("utf-8"))) + setattr(self, ident, node(model, self.ident)) self.start = self.generate_action_handler('start') self.stop = self.generate_action_handler('stop') self.connect = self.generate_action_handler('connect')
participants (3)
-
Aline Manera
-
shaohef@linux.vnet.ibm.com
-
Sheldon