From 2f62e9e6bbe8bee9bed22ad3f410aba56c66ea12 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 7 Feb 2014 18:59:32 -0500 Subject: [PATCH] Key console session objects by tenant and node Previously, was just keying by node. The problem of course being that the first tenant to connect for a given node name dictates the console object for everyone else. Correct this by keying by the tuple of tenant and node together. --- confluent/consoleserver.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/confluent/consoleserver.py b/confluent/consoleserver.py index b152d73a..8c36d7e5 100644 --- a/confluent/consoleserver.py +++ b/confluent/consoleserver.py @@ -122,24 +122,27 @@ class ConsoleSession(object): """ def __init__(self, node, configmanager, datacallback=None): - if node not in _handled_consoles: - _handled_consoles[node] = _ConsoleHandler(node, configmanager) + self.tenant = configmanager.tenant + consk = (node, self.tenant) + self.ckey = consk + if consk not in _handled_consoles: + _handled_consoles[consk] = _ConsoleHandler(node, configmanager) self._evt = threading.Event() self.node = node - self.conshdl = _handled_consoles[node] - self.write = _handled_consoles[node].write + self.conshdl = _handled_consoles[consk] + self.write = _handled_consoles[consk].write if datacallback is None: self.reaper = eventlet.spawn_after(15, self.destroy) - self.databuffer = _handled_consoles[node].get_recent() - self.reghdl = _handled_consoles[node].register_rcpt(self.got_data) + self.databuffer = _handled_consoles[consk].get_recent() + self.reghdl = _handled_consoles[consk].register_rcpt(self.got_data) else: - self.reghdl = _handled_consoles[node].register_rcpt(datacallback) - recdata = _handled_consoles[node].get_recent() + self.reghdl = _handled_consoles[consk].register_rcpt(datacallback) + recdata = _handled_consoles[consk].get_recent() if recdata: datacallback(recdata) def destroy(self): - _handled_consoles[self.node].unregister_rcpt(self.reghdl) + _handled_consoles[self.ckey].unregister_rcpt(self.reghdl) self.databuffer = None self._evt = None self.reghdl = None