ia64/xen-unstable

changeset 2608:b44a94edc865

bitkeeper revision 1.1159.103.1 (4163f41dBS1Bak4UfPFZYlBrHnut8w)

Merge xenbk@gandalf:/var/bk/xeno-unstable.bk
into wray-m-3.hpl.hp.com:/home/mjw/repos-bk/xeno-unstable.bk
author mjw@wray-m-3.hpl.hp.com
date Wed Oct 06 13:33:17 2004 +0000 (2004-10-06)
parents ff4e7a241335 8bc05c989fb3
children 03d1ce22b0b2
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDomainDir.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Oct 05 21:58:07 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Oct 06 13:33:17 2004 +0000
     1.3 @@ -288,6 +288,18 @@ def append_deferred(dlist, v):
     1.4      if isinstance(v, defer.Deferred):
     1.5          dlist.append(v)
     1.6  
     1.7 +def dlist_err(val):
     1.8 +    """Error callback suitable for a deferred list.
     1.9 +    In a deferred list the error callback is called with with Failure((error, index)).
    1.10 +    This callback extracts the error and returns it.
    1.11 +
    1.12 +    @param val: Failure containing (error, index)
    1.13 +    @type val: twisted.internet.failure.Failure 
    1.14 +    """
    1.15 +    
    1.16 +    (error, index) = val.value
    1.17 +    return error
    1.18 +
    1.19  class XendDomainInfo:
    1.20      """Virtual machine object."""
    1.21  
    1.22 @@ -760,6 +772,7 @@ class XendDomainInfo:
    1.23              append_deferred(dlist, v)
    1.24              index[dev_name] = dev_index + 1
    1.25          deferred = defer.DeferredList(dlist, fireOnOneErrback=1)
    1.26 +        deferred.addErrback(dlist_err)
    1.27          return deferred
    1.28  
    1.29      def device_create(self, dev_config):
    1.30 @@ -991,6 +1004,7 @@ class XendDomainInfo:
    1.31                  log.warning("Unknown config field %s", field_name)
    1.32              index[field_name] = field_index + 1
    1.33          d = defer.DeferredList(dlist, fireOnOneErrback=1)
    1.34 +        deferred.addErrback(dlist_err)
    1.35          return d
    1.36  
    1.37  
     2.1 --- a/tools/python/xen/xend/server/SrvDomainDir.py	Tue Oct 05 21:58:07 2004 +0000
     2.2 +++ b/tools/python/xen/xend/server/SrvDomainDir.py	Wed Oct 06 13:33:17 2004 +0000
     2.3 @@ -5,6 +5,7 @@ from StringIO import StringIO
     2.4  
     2.5  from twisted.protocols import http
     2.6  from twisted.web import error
     2.7 +from twisted.python.failure import Failure
     2.8  
     2.9  from xen.xend import sxp
    2.10  from xen.xend import XendDomain
    2.11 @@ -94,6 +95,8 @@ class SrvDomainDir(SrvDir):
    2.12      def _op_create_err(self, err, req):
    2.13          """Callback to handle errors in deferred domain creation.
    2.14          """
    2.15 +        if isinstance(err, Failure):
    2.16 +            err = err.getErrorMessage()
    2.17          print 'op_create> Deferred Exception creating domain:', err
    2.18          req.setResponseCode(http.BAD_REQUEST, "Error creating domain: " + str(err))
    2.19          return str(err)
    2.20 @@ -127,6 +130,8 @@ class SrvDomainDir(SrvDir):
    2.21              return val
    2.22  
    2.23      def _op_restore_err(self, err, req):
    2.24 +        if isinstance(err, Failure):
    2.25 +            err = err.getErrorMessage()
    2.26          print 'op_create> Deferred Exception restoring domain:', err
    2.27          req.setResponseCode(http.BAD_REQUEST, "Error restoring domain: "+ str(err))
    2.28          return str(err)