direct-io.hg

changeset 14385:acdfb333af53

Trap bad return values from Xen-API method handlers, and return an internal
error.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Mar 14 23:12:59 2007 +0000 (2007-03-14)
parents e4e1435e4c63
children 1ada28678762
files tools/python/xen/util/xmlrpclib2.py
line diff
     1.1 --- a/tools/python/xen/util/xmlrpclib2.py	Wed Mar 14 21:59:11 2007 +0000
     1.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Wed Mar 14 23:12:59 2007 +0000
     1.3 @@ -200,6 +200,18 @@ class TCPXMLRPCServer(SocketServer.Threa
     1.4              else:
     1.5                  response = self._dispatch(method, params)
     1.6  
     1.7 +            if self.xenapi and \
     1.8 +               (response is None or
     1.9 +                not isinstance(response, dict) or
    1.10 +                'Status' not in response):
    1.11 +                log.exception('Internal error handling %s: Invalid result %s',
    1.12 +                              method, response)
    1.13 +                response = { "Status": "Failure",
    1.14 +                             "ErrorDescription":
    1.15 +                             ['INTERNAL_ERROR',
    1.16 +                              'Invalid result %s handling %s' %
    1.17 +                              (response, method)]}
    1.18 +
    1.19              # With either Unicode or normal strings, we can only transmit
    1.20              # \t, \n, \r, \u0020-\ud7ff, \ue000-\ufffd, and \u10000-\u10ffff
    1.21              # in an XML document.  xmlrpclib does not escape these values