WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [Xen-changelog] Improve error handling, in particular fi

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [Xen-changelog] Improve error handling, in particular fixing the ProtocolError that is thrown
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Thu, 23 Mar 2006 14:11:07 -0600
Cc: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Delivery-date: Thu, 23 Mar 2006 20:12:30 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <E1FMQAe-0001GC-KH@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <E1FMQAe-0001GC-KH@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mail/News 1.5 (X11/20060309)
Xen patchbot -unstable wrote:
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID da24df1ea484cf72dc9d367d52e828777e0e20cd
# Parent  c1bb4eb565296bdb00aed84fcc877befbcebd8e9
Improve error handling, in particular fixing the ProtocolError that is thrown
when a domain is specified by the user that does not exist.  Added a few
error codes -- many more to come, I expect.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r c1bb4eb56529 -r da24df1ea484 
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py      Thu Mar 23 10:58:19 2006
+++ b/tools/python/xen/xend/server/XMLRPCServer.py      Thu Mar 23 11:59:43 2006
@@ -13,25 +13,45 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #============================================================================
 # Copyright (C) 2006 Anthony Liguori <aliguori@xxxxxxxxxx>
-# Copyright (C) 2006 XenSource Ltd
+# Copyright (C) 2006 XenSource Ltd.
 #============================================================================
+
+import xmlrpclib
from xen.xend import XendDomain, XendDomainInfo, XendNode, \
                      XendLogging, XendDmesg
 from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
-from xen.xend.XendClient import XML_RPC_SOCKET
+from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
def lookup(domid):
-    return XendDomain.instance().domain_lookup_by_name_or_id(domid)
+    try:
+        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
+    except exn:
+        log.exception(exn)
+        raise exn
def dispatch(domid, fn, args):
     info = lookup(domid)
-    return getattr(info, fn)(*args)
+    if info:
+        try:
+            return getattr(info, fn)(*args)
+        except exn:
+            log.exception(exn)

log doesn't appear to be defined in this scope.

Also, there appears to be a problem with the except syntax.  Don't you mean:

except Exception, exn:

Regards,

Anthony Liguori

+            raise exn
+    else:
+        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
def domain(domid):
     info = lookup(domid)
-    return info.sxpr()
+    if info:
+        try:
+            return info.sxpr()
+        except exn:
+            log.exception(exn)
+            raise exn
+    else:
+        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
def domains(detail=1):
     if detail < 1:
diff -r c1bb4eb56529 -r da24df1ea484 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Mar 23 10:58:19 2006
+++ b/tools/python/xen/xm/main.py       Thu Mar 23 11:59:43 2006
@@ -1,6 +1,6 @@
 # (C) Copyright IBM Corp. 2005
 # Copyright (C) 2004 Mike Wray
-# Copyright (c) 2005 XenSource Ltd
+# Copyright (c) 2005-2006 XenSource Ltd.
 #
 # Authors:
 #     Sean Dague <sean at dague dot net>
@@ -38,7 +38,7 @@
 from xen.xm.opts import *
import console
-
+import xen.xend.XendClient
 from xen.xend.XendClient import server
# getopt.gnu_getopt is better, but only exists in Python 2.3+. Use
@@ -1111,7 +1111,10 @@
         except SystemExit:
             sys.exit(1)
         except xmlrpclib.Fault, ex:
-            print "Error: %s" % ex.faultString
+            if ex.faultCode == xen.xend.XendClient.ERROR_INVALID_DOMAIN:
+                print "Error: the domain '%s' does not exist." % ex.faultString
+            else:
+                print "Error: %s" % ex.faultString
             sys.exit(1)
         except:
             print "Unexpected error:", sys.exc_info()[0]

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] Re: [Xen-changelog] Improve error handling, in particular fixing the ProtocolError that is thrown, Anthony Liguori <=