Charles Duffy
2006-Feb-09 16:35 UTC
[Xen-devel] xenstore watches not firing for external-to-xend code using xen.xend.xenstore classes
I''m trying to write a simple xenstore-based watchdog, as discussed previously on this list (quite some time ago -- it got pushed to the back of my priority list for a bit). In any event, I''m trying to use the below code to test the ability of a program external to xend to place watches on xenstore. However, the callbacks aren''t firing except on initial startup, either when I use xenstore-write to update /tool/watchdog/test or when I start or shutdown domains (to invoke the @introduceDomain or @releaseDomain triggers). Obviously I''m missing something here. If this is a simple error on my part, or if I''m expecting behaviour that wasn''t designed for, I''d appreciate a pointer or two. Thanks! --------- #!/usr/bin/env python from xen.xend.xenstore.xstransact import xstransact from xen.xend.xenstore.xswatch import xswatch from pprint import pprint import time, logging logging.basicConfig(level=logging.DEBUG) TROOT = ''/tool/watchdog'' class XenWatchdog: def __init__(self): xswatch(''@releaseDomain'', self.callback, ''releaseDomain'') xswatch(''@introduceDomain'', self.callback, ''introduceDomain'') xswatch(''%(TROOT)s/test'' % locals(), self.callback, ''test'') def callback(self, *args, **kwargs): pprint([ ''onReleaseDomain'', args, kwargs ]) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Feb-09 16:55 UTC
Re: [Xen-devel] xenstore watches not firing for external-to-xend code using xen.xend.xenstore classes
On Thu, Feb 09, 2006 at 10:35:50AM -0600, Charles Duffy wrote:> I''m trying to write a simple xenstore-based watchdog, as discussed > previously on this list (quite some time ago -- it got pushed to the > back of my priority list for a bit). > > [Snip] > > > #!/usr/bin/env python > > from xen.xend.xenstore.xstransact import xstransact > from xen.xend.xenstore.xswatch import xswatch > > from pprint import pprint > import time, logging > logging.basicConfig(level=logging.DEBUG) > > TROOT = ''/tool/watchdog'' > > class XenWatchdog: > def __init__(self): > xswatch(''@releaseDomain'', self.callback, ''releaseDomain'') > xswatch(''@introduceDomain'', self.callback, ''introduceDomain'') > xswatch(''%(TROOT)s/test'' % locals(), self.callback, ''test'') > def callback(self, *args, **kwargs): > pprint([ ''onReleaseDomain'', args, kwargs ])callback needs to return True to say that it would like to stay registered. As it is, you are returning nothing, which looks like False, which means your callback is deregistered after the first call. This changed a couple of months ago, and it still bites people. (My kingdom for a static type system ;-) Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Charles Duffy
2006-Feb-09 17:16 UTC
Re: [Xen-devel] xenstore watches not firing for external-to-xend code using xen.xend.xenstore classes
Ewan Mellor wrote:> callback needs to return True to say that it would like to stay > registered. As it is, you are returning nothing, which looks like > False, which means your callback is deregistered after the first call. >That was it, indeed. Thanks! _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel