]> xenbits.xensource.com Git - xen.git/commitdiff
Trap bad return values from Xen-API method handlers, and return an internal
authorEwan Mellor <ewan@xensource.com>
Wed, 14 Mar 2007 23:12:59 +0000 (23:12 +0000)
committerEwan Mellor <ewan@xensource.com>
Wed, 14 Mar 2007 23:12:59 +0000 (23:12 +0000)
error.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/util/xmlrpclib2.py

index a77b61b5ee0cb47a528a24024059c14c24d60a5e..0d0f3ade2076e9ec685743a303dfdf40f0c25538 100644 (file)
@@ -200,6 +200,18 @@ class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
             else:
                 response = self._dispatch(method, params)
 
+            if self.xenapi and \
+               (response is None or
+                not isinstance(response, dict) or
+                'Status' not in response):
+                log.exception('Internal error handling %s: Invalid result %s',
+                              method, response)
+                response = { "Status": "Failure",
+                             "ErrorDescription":
+                             ['INTERNAL_ERROR',
+                              'Invalid result %s handling %s' %
+                              (response, method)]}
+
             # With either Unicode or normal strings, we can only transmit
             # \t, \n, \r, \u0020-\ud7ff, \ue000-\ufffd, and \u10000-\u10ffff
             # in an XML document.  xmlrpclib does not escape these values