[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEND] Exposing the XendAPI module in the XMLRPCServer
# HG changeset patch # User Alastair Tse <atse@xxxxxxxxxxxxx> # Node ID f297eef12823da23dec386d83db912d66419d85e # Parent edb546bbfff0ab9d9929e658d55a436197f3312b [XEND] Exposing the XendAPI module in the XMLRPCServer Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx> --- tools/python/xen/xend/server/XMLRPCServer.py | 40 +++++++++++++++++---------- 1 files changed, 26 insertions(+), 14 deletions(-) diff -r edb546bbfff0 -r f297eef12823 tools/python/xen/xend/server/XMLRPCServer.py --- a/tools/python/xen/xend/server/XMLRPCServer.py Thu Oct 05 17:29:19 2006 +0100 +++ b/tools/python/xen/xend/server/XMLRPCServer.py Thu Oct 05 17:29:19 2006 +0100 @@ -16,7 +16,7 @@ # Copyright (C) 2006 XenSource Ltd. #============================================================================ -from types import ListType +import types import xmlrpclib from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer @@ -24,10 +24,23 @@ from xen.xend import XendLogging, XendDm from xen.xend import XendLogging, XendDmesg from xen.xend.XendClient import XML_RPC_SOCKET from xen.xend.XendLogging import log +from xen.xend.XendAPI import XendAPI from xen.xend.XendError import XendInvalidDomain +# vcpu_avail is a long and is not needed by the clients. It's far easier +# to just remove it then to try and marshal the long. +def fixup_sxpr(sexpr): + ret = [] + for k in sexpr: + if type(k) in (types.ListType, types.TupleType): + if len(k) != 2 or k[0] != 'vcpu_avail': + ret.append(fixup_sxpr(k)) + else: + ret.append(k) + return ret + def lookup(domid): - info = XendDomain.instance().domain_lookup_by_name_or_id(domid) + info = XendDomain.instance().domain_lookup_nr(domid) if not info: raise XendInvalidDomain(str(domid)) return info @@ -35,18 +48,6 @@ def dispatch(domid, fn, args): def dispatch(domid, fn, args): info = lookup(domid) return getattr(info, fn)(*args) - -# vcpu_avail is a long and is not needed by the clients. It's far easier -# to just remove it then to try and marshal the long. -def fixup_sxpr(sexpr): - ret = [] - for k in sexpr: - if type(k) is ListType: - if len(k) != 2 or k[0] != 'vcpu_avail': - ret.append(fixup_sxpr(k)) - else: - ret.append(k) - return ret def domain(domid): info = lookup(domid) @@ -92,6 +93,7 @@ class XMLRPCServer: self.ready = False self.running = True + self.xenapi = XendAPI() def run(self): if self.use_tcp: @@ -100,6 +102,16 @@ class XMLRPCServer: else: self.server = UnixXMLRPCServer(self.path, logRequests = False) + # Register Xen API Functions + # ------------------------------------------------------------------- + # exportable functions are ones that do not begin with '_' + # and has the 'api' attribute. + + for meth_name in dir(self.xenapi): + meth = getattr(self.xenapi, meth_name) + if meth_name[0] != '_' and callable(meth) and hasattr(meth, 'api'): + self.server.register_function(meth, getattr(meth, 'api')) + # Legacy deprecated xm xmlrpc api # -------------------------------------------------------------------- _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |