ia64/xen-unstable

changeset 1762:b9fc18608f2b

bitkeeper revision 1.1072 (40f3a59bA83EVS8nABepOIwfgijigQ)

Merge http://xen.bkbits.net:8080/xeno-unstable.bk
into gandalf.hpl.hp.com:/var/bk/xeno-unstable.bk
author xenbk@gandalf.hpl.hp.com
date Tue Jul 13 09:04:27 2004 +0000 (2004-07-13)
parents bfc886b99735 94c04c061734
children b7c469ef6b99 c2f673cea5e4
files tools/python/xen/xend/Args.py tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendMigrate.py tools/python/xen/xend/server/SrvDomain.py
line diff
     1.1 --- a/tools/python/xen/xend/Args.py	Tue Jul 13 00:30:45 2004 +0000
     1.2 +++ b/tools/python/xen/xend/Args.py	Tue Jul 13 09:04:27 2004 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4  import types
     1.5 +import StringIO
     1.6 +
     1.7  import sxp
     1.8  
     1.9  class ArgError(StandardError):
    1.10 @@ -50,39 +52,48 @@ class Args:
    1.11      def get_form_args(self, f, xargs=None):
    1.12          d = {}
    1.13          for (k, v) in f.items():
    1.14 -            n = len(v)
    1.15              if ((k not in self.arg_dict) and
    1.16                  (k not in self.key_dict)):
    1.17                  continue
    1.18 -            if n == 0:
    1.19 -                continue
    1.20 -            elif n == 1:
    1.21 -                d[k] = v[0]
    1.22 +            if isinstance(v, types.ListType):
    1.23 +                n = len(v)
    1.24 +                if n == 0:
    1.25 +                    continue
    1.26 +                elif n == 1:
    1.27 +                    val = v[0]
    1.28 +                else:
    1.29 +                    raise ArgError('Too many values for %s' % k)
    1.30              else:
    1.31 -                raise ArgError('Too many values for %s' % k)
    1.32 +                val = v
    1.33 +            d[k] = val
    1.34          return self.get_args(d, xargs=xargs)
    1.35  
    1.36      def coerce(self, type, v):
    1.37          try:
    1.38              if type == 'int':
    1.39 -                return int(v)
    1.40 -            if type == 'str':
    1.41 -                return str(v)
    1.42 -            if type == 'sxpr':
    1.43 -                return self.sxpr(v)
    1.44 +                val = int(v)
    1.45 +            elif type == 'str':
    1.46 +                val = str(v)
    1.47 +            elif type == 'sxpr':
    1.48 +                val = self.sxpr(v)
    1.49 +            else:
    1.50 +                raise ArgError('invalid type:' + str(type))
    1.51 +            return val
    1.52          except ArgError:
    1.53              raise
    1.54          except StandardError, ex:
    1.55              raise ArgError(str(ex))
    1.56  
    1.57      def sxpr(self, v):
    1.58 -        if instanceof(v, types.ListType):
    1.59 -            return v
    1.60 -        if instanceof(v, types.File) or hasattr(v, 'readline'):
    1.61 -            return sxpr_file(v)
    1.62 -        if instanceof(v, types.StringType):
    1.63 -            return sxpr_file(StringIO(v))
    1.64 -        return str(v)
    1.65 +        if isinstance(v, types.ListType):
    1.66 +            val = v
    1.67 +        elif isinstance(v, types.FileType) or hasattr(v, 'readline'):
    1.68 +            val = self.sxpr_file(v)
    1.69 +        elif isinstance(v, types.StringType):
    1.70 +            val = self.sxpr_file(StringIO.StringIO(v))
    1.71 +        else:
    1.72 +            val = str(v)
    1.73 +        return val
    1.74  
    1.75      def sxpr_file(self, fin):
    1.76          try:
     2.1 --- a/tools/python/xen/xend/XendClient.py	Tue Jul 13 00:30:45 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendClient.py	Tue Jul 13 09:04:27 2004 +0000
     2.3 @@ -228,14 +228,19 @@ class Xend:
     2.4                           {'op'      : 'create',
     2.5                            'config'  : fileof(conf) })
     2.6  
     2.7 -    def xend_domain(self, id):
     2.8 -        return xend_get(self.domainurl(id))
     2.9 +    def xend_domain_restore(self, filename):
    2.10 +        return xend_call(self.domainurl(),
    2.11 +                         {'op'      : 'restore',
    2.12 +                          'file'    : filename })
    2.13  
    2.14      def xend_domain_configure(self, id, config):
    2.15          return xend_call(self.domainurl(id),
    2.16                           {'op'      : 'configure',
    2.17                            'config'  : fileof(conf) })
    2.18  
    2.19 +    def xend_domain(self, id):
    2.20 +        return xend_get(self.domainurl(id))
    2.21 +
    2.22      def xend_domain_unpause(self, id):
    2.23          return xend_call(self.domainurl(id),
    2.24                           {'op'      : 'unpause'})
    2.25 @@ -258,11 +263,6 @@ class Xend:
    2.26                           {'op'      : 'save',
    2.27                            'file'    : filename})
    2.28  
    2.29 -    def xend_domain_restore(self, id, filename):
    2.30 -        return xend_call(self.domainurl(id),
    2.31 -                         {'op'      : 'restore',
    2.32 -                          'file'    : filename })
    2.33 -
    2.34      def xend_domain_migrate(self, id, dst):
    2.35          return xend_call(self.domainurl(id),
    2.36                           {'op'      : 'migrate',
     3.1 --- a/tools/python/xen/xend/XendMigrate.py	Tue Jul 13 00:30:45 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendMigrate.py	Tue Jul 13 09:04:27 2004 +0000
     3.3 @@ -111,7 +111,7 @@ class XfrdInfo:
     3.4              fn = self.unknown
     3.5          val = fn(xfrd, val)
     3.6          if val is not None:
     3.7 -            sxp.show(val, out=self.transport)
     3.8 +            sxp.show(val, out=xfrd.transport)
     3.9  
    3.10      def unknown(self, xfrd, val):
    3.11          print 'unknown>', val
    3.12 @@ -134,11 +134,11 @@ class XfrdInfo:
    3.13          #    print >>sys.stdout, "Error unpausing domain:", self.src_dom
    3.14          return None
    3.15  
    3.16 -    def xfr_progress(self, val):
    3.17 +    def xfr_progress(self, xfrd, val):
    3.18          print 'xfr_progress>', val
    3.19          return None
    3.20  
    3.21 -    def xfr_vm_pause(self, val):
    3.22 +    def xfr_vm_pause(self, xfrd, val):
    3.23          print 'xfr_vm_pause>', val
    3.24          try:
    3.25              vmid = sxp.child0(val)
    3.26 @@ -147,7 +147,7 @@ class XfrdInfo:
    3.27              val = errno.EINVAL
    3.28          return ['xfr.err', val]
    3.29  
    3.30 -    def xfr_vm_unpause(self, val):
    3.31 +    def xfr_vm_unpause(self, xfrd, val):
    3.32          print 'xfr_vm_unpause>', val
    3.33          try:
    3.34              vmid = sxp.child0(val)
    3.35 @@ -156,7 +156,7 @@ class XfrdInfo:
    3.36              val = errno.EINVAL
    3.37          return ['xfr.err', val]
    3.38  
    3.39 -    def xfr_vm_suspend(self, val):
    3.40 +    def xfr_vm_suspend(self, xfrd, val):
    3.41          print 'xfr_vm_suspend>', val
    3.42          try:
    3.43              vmid = sxp.child0(val)
     4.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Tue Jul 13 00:30:45 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Tue Jul 13 09:04:27 2004 +0000
     4.3 @@ -19,9 +19,10 @@ class SrvDomain(SrvDir):
     4.4          self.xconsole = XendConsole.instance()
     4.5  
     4.6      def op_configure(self, op, req):
     4.7 +        print 'op_configure>', op, req.args
     4.8          fn = FormFn(self.xd.domain_configure,
     4.9                      [['dom', 'int'],
    4.10 -                     ['config', 'sxp']])
    4.11 +                     ['config', 'sxpr']])
    4.12          val = fn(req.args, {'dom': self.dom.id})
    4.13          #todo: may need to add ok and err callbacks.
    4.14          return val