|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [RFC] Xend XML-RPC Refactoring
Ewan Mellor wrote: Anthony, I've reviewed your XML-RPC patches. It all looks good, so I'm in favour of putting them in straight away. Thanks! Okay. So I'm going to take this to mean that we would deprecate S-Expression/HTTP for 3.0.2 and remove it in 3.0.3? That would be really nice.I'd like to get the second patch in straight away as well as the first, that is (for those watching at home) to change xm to using XML-RPC, because I would like to deprecate the old protocol sooner, rather than later. Making the XML-RPC interface the primary control path for Xen 3.0.2 will encourage third-parties to code to that rather than to the s-expression protocol, and that's a good thing.
Yeah, this is certainly sane.
Haven't seen that before. Quite useful :-) +from xen.xend import (XendDomain, XendDomainInfo, XendNode, + XendLogging, XendDmesg) Yeah, thanks for the catch. [Snip] +def get_log(): + f = open(XendLogging.getLogFilename(), 'r') + ret = f.read() + f.close() + return ret Yeah, again, thanks for the catch :-)
Okay. I'm fine with that. Yes, skanky is very much an understatement. I found XendDomain and XendDomainInfo particularly nasty to work with considering that they use different naming conventions too.+ # Functions in XendNode and XendDmesg + for type, lst, n in [(XendNode, ['info', 'cpu_bvt_slice_set'], 'node'), + (XendDmesg, ['info', 'clear'], 'node.dmesg')]: + inst = type.instance() + for name in lst: + self.server.register_function(getattr(inst, name), + "xend.%s.%s" % (n, name)) +This is all a bit skanky, and could be easily cleaned up by introducing a naming convention for XendDomain, XendNode, etc. Isn't using an underscore a convention for making methods private in Python? I think, at least, pydoc ignores functions that start with an underscore.How about if we prefixed every function that we wish to expose to the messaging layer with "public_"? So for example XendDomainInfo.send_sysrq would be named public_send_sysrq instead. Then, we could use that to guide the function registration, rather than having exclude lists and inline lists of callable methods. Yes, that would make things much nicer so I'm happy to do it. I clearly wanted to avoid making more changes than necessary at first :-)This would make your patch a bit more invasive, in that the renaming would cause it to touch more files, but I don't have a problem with that -- I think the change is justified. Nope. Just compatibility. I know there are people using the XendClient API. I also know we've never declared that to be a fixed API. I didn't want to be the one to break it though :-)[Snip the rest of this patch] # HG changeset patch # User anthony@xxxxxxxxxxxxxxxxxxxxx # Node ID 951f0d589164e0cffc785cf23d82118b3e0b0495 # Parent 095ac0d95d9cc154ec8fc3dba1a67f02f79771ac This changeset is a major refactoring of XendClient to use the XML-RPC transport for Xend and also to make a few changes to xm so that it knows about the new Exception types. xm-test has been passing with this changeset for the past couple of weeks. Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx> diff -r 095ac0d95d9c -r 951f0d589164 tools/python/xen/xend/XendClient.py --- a/tools/python/xen/xend/XendClient.py Tue Feb 28 22:08:47 2006 +++ b/tools/python/xen/xend/XendClient.py Tue Feb 28 22:10:14 2006 [Snip lots]def xend_node_get_dmesg(self): Yes, this would be great. If we don't mind breaking XendClient, I'm happy to do it.What I'd do here is just this: XendClient.py: XEND_XMLRPC_UNIX_SOCKET = '/var/run/xend-xmlrpc.sock'server = ServerProxy('httpu://' + XEND_XMLRPC_UNIX_SOCKET) Yeah, lookup() is a bit of a hack. I can go through and audit the functions to make sure that they all accept either names or IDs. + # FIXME + def xend_domain_restore(self, filename): + return self.srv.xend.domain.restore(filename)What does this FIXME mean? Sorry, that shouldn't have been there. I already fixed that one :-)
Ok, sounds sane to me. Why? If a public_ function expects a domid and gets passed a string, it ought to throw an exception and the client should get it as an error.The reason I noticed is that I have been trying to make it so that XendDomain and XendDomainInfo only receive arguments of the correct type, with the casts to integers etc handled by the messaging layer. This change you've made highlights the fact that there is now nowhere for that type conversion to take place, because the messaging layer is more generic, and doesn't understand the calls that it is dispatching. That's OK -- it's a consequence of the removal of all that code in SrvDomain -- but it's something to be aware of. If we adopt the naming convention that I suggest above, then all methods accept only arguments of the correct type _except_ for those named "public_xyz" -- those methods must validate and convert their arguments appropriately. This particular hack was to account for a place in xm where it was passing a string version of the domain ID. The real problem here was the xm code. I wanted to avoid modifying that code though to demonstrate that the XML-RPC stuff could be a drop-in-replacement. Of course, now that that exercise is complete, there's no reason not to go in and fix the original source of the problem.
Yeah, sorry, I missed that. We can pass whatever we want. xmlrpclib.Fault contain an integer code and a string message. For now, I'm just always passing a 1 for the faultCode and sending the Xend traceback as the faultMessage. I'm not sure how fancy we want to get for the first drop of this code. Any suggestions? BTW, it's printing 'Internal Xend Error' because xm-test has a test case that checks for that specific result :-) Thanks for looking at the code! I don't think there's that much change necessary. I should be able to turn around another patch in a couple days. Regards, Anthony Liguori Cheers, Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |