From e41140e24f118cde5cb5d2fd343632913530320f Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 23 Apr 2014 10:59:22 -0400 Subject: [PATCH] Fix problem where only one notifier would fire when many nodes would be hooked for the information. --- confluent/config/configmanager.py | 8 ++++---- confluent/consoleserver.py | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 7bfe290f..c20e65ef 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -857,11 +857,11 @@ class ConfigManager(object): for node in nodeattrs.iterkeys(): if node not in attribwatchers: continue - attribwatchers = attribwatchers[node] + attribwatcher = attribwatchers[node] for attrname in nodeattrs[node].iterkeys(): - if attrname not in attribwatchers: + if attrname not in attribwatcher: continue - for notifierid in attribwatchers[attrname].iterkeys(): + for notifierid in attribwatcher[attrname].iterkeys(): if notifierid in notifdata: if node in notifdata[notifierid]['nodeattrs']: notifdata[notifierid]['nodeattrs'][node].append( @@ -872,7 +872,7 @@ class ConfigManager(object): else: notifdata[notifierid] = { 'nodeattrs': {node: [attrname]}, - 'callback': attribwatchers[attrname][notifierid] + 'callback': attribwatcher[attrname][notifierid] } for watcher in notifdata.itervalues(): callback = watcher['callback'] diff --git a/confluent/consoleserver.py b/confluent/consoleserver.py index b360a797..b18e3256 100644 --- a/confluent/consoleserver.py +++ b/confluent/consoleserver.py @@ -38,6 +38,7 @@ _genwatchattribs = frozenset(('console.method', 'console.logging')) class _ConsoleHandler(object): def __init__(self, node, configmanager): self._isondemand = False + self.error = None self.rcpts = {} self.cfgmgr = configmanager self.node = node @@ -137,6 +138,11 @@ class _ConsoleHandler(object): self._console = plugin.handle_path( "/nodes/%s/_console/session" % self.node, "create", self.cfgmgr) + if not isinstance(self._console, conapi.Console): + self.connectstate = 'unconnected' + self._send_rcpts({'connectstate': self.connectstate}) + self.error = 'misconfigured' + return self.send_break = self._console.send_break if self._attribwatcher: self.cfgmgr.remove_watcher(self._attribwatcher) @@ -150,6 +156,7 @@ class _ConsoleHandler(object): try: self._console.connect(self.get_console_output) except exc.TargetEndpointUnreachable: + self.error = 'unreachable' self.connectstate = 'unconnected' self._send_rcpts({'connectstate': self.connectstate}) retrytime = 30 + (30 * random.random())