WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XEND] Exposing the XendAPI module in the

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND] Exposing the XendAPI module in the XMLRPCServer
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Nov 2006 22:08:34 +0000
Delivery-date: Thu, 02 Nov 2006 21:41:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEND] Exposing the XendAPI module in the XMLRPCServer, Xen patchbot-unstable <=