From d391a2dddc20e4b8199b07f52e224eab60812c69 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 13:41:44 +0100 Subject: Handle exceptions caused during processing of requests, to improve error reporting. Signed-off-by: Ewan Mellor --- tools/python/xen/web/SrvBase.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/python/xen/web/SrvBase.py b/tools/python/xen/web/SrvBase.py index 49a9e058d1..e0b528fcc0 100644 --- a/tools/python/xen/web/SrvBase.py +++ b/tools/python/xen/web/SrvBase.py @@ -81,7 +81,14 @@ class SrvBase(resource.Resource): req.write("Operation not implemented: " + op) return '' else: - return op_method(op, req) + try: + res = op_method(op, req) + except Exception, exn: + log.exception("Request %s failed.", op) + if req.useSxp(): + return ['xend.err', "Exception: " + str(exn)] + else: + return "

%s

" % str(exn) def print_path(self, req): """Print the path with hyperlinks. -- cgit v1.2.3 From 0b7f903b29f7046a4a9ff03770354cb0719de8a7 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 13:43:07 +0100 Subject: Added behaviour to read() to read directly from the transaction's path if no arguments are specified. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/xenstore/xstransact.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index 14d8b0472d..503136ad76 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -42,8 +42,15 @@ class xstransact: '%s, while reading %s' % (ex.args[1], path)) def read(self, *args): + """If no arguments are given, return the value at this transaction's + path. If one argument is given, treat that argument as a subpath to + this transaction's path, and return the value at that path. + Otherwise, treat each argument as a subpath to this transaction's + path, and return a list composed of the values at each of those + instead. + """ if len(args) == 0: - raise TypeError + return xshandle().read(self.path) if len(args) == 1: return self._read(args[0]) ret = [] @@ -191,6 +198,13 @@ class xstransact: def Read(cls, path, *args): + """If only one argument is given (path), return the value stored at + that path. If two arguments are given, treat the second argument as a + subpath within the first, and return the value at the composed path. + Otherwise, treat each argument after the first as a subpath to the + given path, and return a list composed of the values at each of those + instead. This operation is performed inside a transaction. + """ while True: t = cls(path) try: @@ -234,6 +248,12 @@ class xstransact: Remove = classmethod(Remove) def List(cls, path, *args): + """If no arguments are given (path), list its contents, returning the + entries therein, or None if no entries are found. Otherwise, treat + each further argument as a subpath to the given path, and return the + cumulative listing of each of those instead. This operation is + performed inside a transaction. + """ while True: t = cls(path) try: -- cgit v1.2.3 From ad1a856c947678049e7c87db3be6bd045b61ab79 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 13:43:33 +0100 Subject: Added missing quote to HTML output. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/server/SrvNode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/python/xen/xend/server/SrvNode.py b/tools/python/xen/xend/server/SrvNode.py index c8b0ad6dfd..8f598a3bb6 100644 --- a/tools/python/xen/xend/server/SrvNode.py +++ b/tools/python/xen/xend/server/SrvNode.py @@ -62,7 +62,7 @@ class SrvNode(SrvDir): for d in self.info(): req.write('
  • %10s: %s' % (d[0], str(d[1]))) req.write('
  • Xen dmesg output' % url) - req.write('
  • Xend log' % url) req.write('') req.write('') -- cgit v1.2.3 From 85506dfc978c586df08ec488e8587678a1e301aa Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 13:44:15 +0100 Subject: Improve HTML output. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/server/SrvDomainDir.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/xend/server/SrvDomainDir.py b/tools/python/xen/xend/server/SrvDomainDir.py index 942a69ea9a..00a498d559 100644 --- a/tools/python/xen/xend/server/SrvDomainDir.py +++ b/tools/python/xen/xend/server/SrvDomainDir.py @@ -152,11 +152,11 @@ class SrvDomainDir(SrvDir): domains = self.xd.list_sorted() req.write('
      ') for d in domains: - req.write('
    • Domain %s' - % (url, d.getName(), d.getName())) - req.write('id=%s' % d.getDomain()) - req.write('memory=%d'% d.getMemoryTarget()) - req.write('ssidref=%d'% d.getSsidref()) + req.write( + '
    • Domain %s: id = %s, memory = %d, ' + 'ssidref = %d.' + % (url, d.getName(), d.getName(), d.getDomid(), + d.getMemoryTarget(), d.getSsidref())) req.write('
    • ') req.write('
    ') -- cgit v1.2.3 From bcf976db0e9b0b84b49e3540cc809f9d3dab33a1 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 14:02:38 +0100 Subject: Minor tidy. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendDomainInfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 21d365591c..45c0b2be44 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -615,7 +615,7 @@ class XendDomainInfo: if not reason in shutdown_reasons.values(): raise XendError('invalid reason:' + reason) self.storeVm("control/shutdown", reason) - if not reason in ['suspend']: + if not reason == 'suspend': self.storeVm('xend/shutdown_start_time', time.time()) -- cgit v1.2.3 From 34a989b22110bee89b34debd6f08734d2570f79e Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 14:03:06 +0100 Subject: Added logging of exceptions coming through callInfo, for better debugging. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendDomain.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index dd983e4984..0ec777f6ab 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -547,6 +547,7 @@ class XendDomain: except XendError: raise except Exception, exn: + log.exception("") raise XendError(str(exn)) -- cgit v1.2.3