ia64/xen-unstable

changeset 9450:33df7d4eff23

1) Introduce new exception type XendInvalidDomain that maps to the high level
XEND_INVALID_DOMAIN faultType.
2) Fix exception logic in XMLRPCServer
3) Fix TCP server
4) Remove catching of ProtocolError in main.py. ProtocolErrors only occur
when there is an exception in the exception handling code which shouldn't
ever happen. I've reproduced the error cases described by Ewan with
xend_domain_setTargetMemory and once I fixed the exception logic, I get a
normal faultType of 1 as would be expected.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
author anthony@rhesis.austin.ibm.com
date Fri Mar 24 14:31:12 2006 +0100 (2006-03-24)
parents 905cfaa5986b
children 74e33cc868cf
files tools/python/xen/xend/XendError.py tools/python/xen/xend/server/XMLRPCServer.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendError.py	Fri Mar 24 12:28:58 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendError.py	Fri Mar 24 14:31:12 2006 +0100
     1.3 @@ -19,6 +19,10 @@ from xmlrpclib import Fault
     1.4  
     1.5  import XendClient
     1.6  
     1.7 +class XendInvalidDomain(Fault):
     1.8 +    def __init__(self, value):
     1.9 +        Fault.__init__(self, XendClient.ERROR_INVALID_DOMAIN, value)
    1.10 +
    1.11  class XendError(Fault):
    1.12      
    1.13      def __init__(self, value):
     2.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Fri Mar 24 12:28:58 2006 +0100
     2.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Fri Mar 24 14:31:12 2006 +0100
     2.3 @@ -23,35 +23,21 @@ from xen.xend import XendDomain, XendDom
     2.4  from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
     2.5  
     2.6  from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
     2.7 +from xen.xend.XendError import *
     2.8  
     2.9  def lookup(domid):
    2.10 -    try:
    2.11 -        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
    2.12 -    except exn:
    2.13 -        log.exception(exn)
    2.14 -        raise exn
    2.15 +    info = XendDomain.instance().domain_lookup_by_name_or_id(domid)
    2.16 +    if not info:
    2.17 +        raise XendInvalidDomain(str(domid))
    2.18 +    return info
    2.19  
    2.20  def dispatch(domid, fn, args):
    2.21      info = lookup(domid)
    2.22 -    if info:
    2.23 -        try:
    2.24 -            return getattr(info, fn)(*args)
    2.25 -        except exn:
    2.26 -            log.exception(exn)
    2.27 -            raise exn
    2.28 -    else:
    2.29 -        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
    2.30 +    return getattr(info, fn)(*args)
    2.31  
    2.32  def domain(domid):
    2.33      info = lookup(domid)
    2.34 -    if info:
    2.35 -        try:
    2.36 -            return info.sxpr()
    2.37 -        except exn:
    2.38 -            log.exception(exn)
    2.39 -            raise exn
    2.40 -    else:
    2.41 -        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
    2.42 +    return info.sxpr()
    2.43  
    2.44  def domains(detail=1):
    2.45      if detail < 1:
    2.46 @@ -90,7 +76,7 @@ class XMLRPCServer:
    2.47          if self.use_tcp:
    2.48              # bind to something fixed for now as we may eliminate
    2.49              # tcp support completely.
    2.50 -            self.server = TCPXMLRPCServer(("localhost", 8005, False))
    2.51 +            self.server = TCPXMLRPCServer(("localhost", 8005), logRequests=False)
    2.52          else:
    2.53              self.server = UnixXMLRPCServer(XML_RPC_SOCKET, False)
    2.54  
     3.1 --- a/tools/python/xen/xm/main.py	Fri Mar 24 12:28:58 2006 +0100
     3.2 +++ b/tools/python/xen/xm/main.py	Fri Mar 24 14:31:12 2006 +0100
     3.3 @@ -1102,12 +1102,6 @@ def main(argv=sys.argv):
     3.4              else:
     3.5                  err("Error connecting to xend: %s." % ex[1])
     3.6              sys.exit(1)
     3.7 -        except xmlrpclib.ProtocolError, ex:
     3.8 -            if os.geteuid() != 0:
     3.9 -                err("Most commands need root access.  Please try again as root.")
    3.10 -            else:
    3.11 -                err("Error connecting to xend: %s." % ex.errmsg)
    3.12 -            sys.exit(1)
    3.13          except SystemExit:
    3.14              sys.exit(1)
    3.15          except xmlrpclib.Fault, ex: