mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1072 (40f3a59bA83EVS8nABepOIwfgijigQ)
Merge http://xen.bkbits.net:8080/xeno-unstable.bk into gandalf.hpl.hp.com:/var/bk/xeno-unstable.bk
This commit is contained in:
commit
f7fa043428
4 files changed
+43
-31
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import types
|
||||
import StringIO
|
||||
|
||||
import sxp
|
||||
|
||||
class ArgError(StandardError):
|
||||
@@ -50,39 +52,48 @@ class Args:
|
||||
def get_form_args(self, f, xargs=None):
|
||||
d = {}
|
||||
for (k, v) in f.items():
|
||||
n = len(v)
|
||||
if ((k not in self.arg_dict) and
|
||||
(k not in self.key_dict)):
|
||||
continue
|
||||
if n == 0:
|
||||
continue
|
||||
elif n == 1:
|
||||
d[k] = v[0]
|
||||
if isinstance(v, types.ListType):
|
||||
n = len(v)
|
||||
if n == 0:
|
||||
continue
|
||||
elif n == 1:
|
||||
val = v[0]
|
||||
else:
|
||||
raise ArgError('Too many values for %s' % k)
|
||||
else:
|
||||
raise ArgError('Too many values for %s' % k)
|
||||
val = v
|
||||
d[k] = val
|
||||
return self.get_args(d, xargs=xargs)
|
||||
|
||||
def coerce(self, type, v):
|
||||
try:
|
||||
if type == 'int':
|
||||
return int(v)
|
||||
if type == 'str':
|
||||
return str(v)
|
||||
if type == 'sxpr':
|
||||
return self.sxpr(v)
|
||||
val = int(v)
|
||||
elif type == 'str':
|
||||
val = str(v)
|
||||
elif type == 'sxpr':
|
||||
val = self.sxpr(v)
|
||||
else:
|
||||
raise ArgError('invalid type:' + str(type))
|
||||
return val
|
||||
except ArgError:
|
||||
raise
|
||||
except StandardError, ex:
|
||||
raise ArgError(str(ex))
|
||||
|
||||
def sxpr(self, v):
|
||||
if instanceof(v, types.ListType):
|
||||
return v
|
||||
if instanceof(v, types.File) or hasattr(v, 'readline'):
|
||||
return sxpr_file(v)
|
||||
if instanceof(v, types.StringType):
|
||||
return sxpr_file(StringIO(v))
|
||||
return str(v)
|
||||
if isinstance(v, types.ListType):
|
||||
val = v
|
||||
elif isinstance(v, types.FileType) or hasattr(v, 'readline'):
|
||||
val = self.sxpr_file(v)
|
||||
elif isinstance(v, types.StringType):
|
||||
val = self.sxpr_file(StringIO.StringIO(v))
|
||||
else:
|
||||
val = str(v)
|
||||
return val
|
||||
|
||||
def sxpr_file(self, fin):
|
||||
try:
|
||||
|
||||
@@ -228,14 +228,19 @@ class Xend:
|
||||
{'op' : 'create',
|
||||
'config' : fileof(conf) })
|
||||
|
||||
def xend_domain(self, id):
|
||||
return xend_get(self.domainurl(id))
|
||||
def xend_domain_restore(self, filename):
|
||||
return xend_call(self.domainurl(),
|
||||
{'op' : 'restore',
|
||||
'file' : filename })
|
||||
|
||||
def xend_domain_configure(self, id, config):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'configure',
|
||||
'config' : fileof(conf) })
|
||||
|
||||
def xend_domain(self, id):
|
||||
return xend_get(self.domainurl(id))
|
||||
|
||||
def xend_domain_unpause(self, id):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'unpause'})
|
||||
@@ -258,11 +263,6 @@ class Xend:
|
||||
{'op' : 'save',
|
||||
'file' : filename})
|
||||
|
||||
def xend_domain_restore(self, id, filename):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'restore',
|
||||
'file' : filename })
|
||||
|
||||
def xend_domain_migrate(self, id, dst):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'migrate',
|
||||
|
||||
@@ -111,7 +111,7 @@ class XfrdInfo:
|
||||
fn = self.unknown
|
||||
val = fn(xfrd, val)
|
||||
if val is not None:
|
||||
sxp.show(val, out=self.transport)
|
||||
sxp.show(val, out=xfrd.transport)
|
||||
|
||||
def unknown(self, xfrd, val):
|
||||
print 'unknown>', val
|
||||
@@ -134,11 +134,11 @@ class XfrdInfo:
|
||||
# print >>sys.stdout, "Error unpausing domain:", self.src_dom
|
||||
return None
|
||||
|
||||
def xfr_progress(self, val):
|
||||
def xfr_progress(self, xfrd, val):
|
||||
print 'xfr_progress>', val
|
||||
return None
|
||||
|
||||
def xfr_vm_pause(self, val):
|
||||
def xfr_vm_pause(self, xfrd, val):
|
||||
print 'xfr_vm_pause>', val
|
||||
try:
|
||||
vmid = sxp.child0(val)
|
||||
@@ -147,7 +147,7 @@ class XfrdInfo:
|
||||
val = errno.EINVAL
|
||||
return ['xfr.err', val]
|
||||
|
||||
def xfr_vm_unpause(self, val):
|
||||
def xfr_vm_unpause(self, xfrd, val):
|
||||
print 'xfr_vm_unpause>', val
|
||||
try:
|
||||
vmid = sxp.child0(val)
|
||||
@@ -156,7 +156,7 @@ class XfrdInfo:
|
||||
val = errno.EINVAL
|
||||
return ['xfr.err', val]
|
||||
|
||||
def xfr_vm_suspend(self, val):
|
||||
def xfr_vm_suspend(self, xfrd, val):
|
||||
print 'xfr_vm_suspend>', val
|
||||
try:
|
||||
vmid = sxp.child0(val)
|
||||
|
||||
@@ -19,9 +19,10 @@ class SrvDomain(SrvDir):
|
||||
self.xconsole = XendConsole.instance()
|
||||
|
||||
def op_configure(self, op, req):
|
||||
print 'op_configure>', op, req.args
|
||||
fn = FormFn(self.xd.domain_configure,
|
||||
[['dom', 'int'],
|
||||
['config', 'sxp']])
|
||||
['config', 'sxpr']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
#todo: may need to add ok and err callbacks.
|
||||
return val
|
||||
|
||||