Crístian Viana (2):
Return empty dict when request body is empty
bugfix: Use correct error code when current snapshot does not exist
src/kimchi/control/utils.py | 3 +++
src/kimchi/model/vmsnapshots.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
--
1.9.3
Show replies by thread
If Kimchi receives a POST or PUT command with an empty body, a 400 error
is returned because the server cannot parse the [empty] body.
Add an additional check on the server so the request body is only parsed
if it has content; otherwise, an empty dict will be returned.
Signed-off-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/control/utils.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/kimchi/control/utils.py b/src/kimchi/control/utils.py
index 64e0ac5..d26fe48 100644
--- a/src/kimchi/control/utils.py
+++ b/src/kimchi/control/utils.py
@@ -74,6 +74,9 @@ def parse_request():
return {}
if mime_in_header('Content-Type', 'application/json'):
+ if cherrypy.request.body.length == 0:
+ return {}
+
rawbody = cherrypy.request.body.read()
try:
return json.loads(rawbody)
--
1.9.3
If a VM has no current snapshot, a NotFoundError is raised by the
backend. However, the error reason is 'KCHSNAP007E', which is invalid.
Use the correct error value (KCHSNAP0007E) when raising the exception
described above.
Signed-off-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
---
src/kimchi/model/vmsnapshots.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmsnapshots.py b/src/kimchi/model/vmsnapshots.py
index e8e2294..ad8460e 100644
--- a/src/kimchi/model/vmsnapshots.py
+++ b/src/kimchi/model/vmsnapshots.py
@@ -177,7 +177,7 @@ class CurrentVMSnapshotModel(object):
snap_name = vir_snap.getName().decode('utf-8')
except libvirt.libvirtError, e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN_SNAPSHOT:
- raise NotFoundError('KCHSNAP007E', {'vm': vm_name})
+ raise NotFoundError('KCHSNAP0007E', {'vm': vm_name})
raise OperationFailed('KCHSNAP0008E',
{'vm': vm_name, 'err': e.message})
--
1.9.3
Applied. Thanks.
Regards,
Aline Manera