diff --git a/confluent/consoleserver.py b/confluent/consoleserver.py index e483d15b..399ddb5a 100644 --- a/confluent/consoleserver.py +++ b/confluent/consoleserver.py @@ -16,11 +16,11 @@ _handled_consoles = {} class _ConsoleHandler(object): def __init__(self, node, configmanager): + self.rcpts = {} self._console = plugin.handle_path("/node/%s/_console/session" % node, "create", configmanager) self.buffer = bytearray() self._console.connect(self.get_console_output) - self.rcpts = {} def unregister_rcpt(self, handle): if handle in self.rcpts: diff --git a/confluent/interface/console.py b/confluent/interface/console.py index 36eeac1e..97410041 100644 --- a/confluent/interface/console.py +++ b/confluent/interface/console.py @@ -1,3 +1,11 @@ +class ConsoleEvent(object): + """This represents a number of specific events to be sent between + consoleserver and console objects. Disconnect indicates that the console + object has lost connection. The response to this will be to dispose of the + Console object and try to request a new one, rather than requesting + reconnect or anything like that. Break is a serial break.""" + Disconnect, Break = range(2) + class Console(object): """This is the class defining the interface a console plugin must return for the _console/session element""" diff --git a/plugins/hardwaremanagement/ipmi.py b/plugins/hardwaremanagement/ipmi.py index bcb942d2..9aa1198f 100644 --- a/plugins/hardwaremanagement/ipmi.py +++ b/plugins/hardwaremanagement/ipmi.py @@ -123,10 +123,17 @@ class IpmiConsole(confluent.interface.console.Console): self.port = connparams['port'] # Cannot actually create console until 'connect', when we get callback + def handle_data(self, data): + if type(data) == dict: + #TODO: convert dict into a confluent.interface.console.ConsoleEvent + else: + self.datacallback(data) + def connect(self,callback): global _ipmithread global pullchain global chainpulled + self.datacallback = callback if _ipmithread is None: pullchain = os.pipe() _ipmithread = eventlet.spawn(_ipmi_evtloop) @@ -137,7 +144,7 @@ class IpmiConsole(confluent.interface.console.Console): 'password': self.password, 'kg': self.kg, 'force': True, - 'iohandler': callback}, self.got_consobject)) + 'iohandler': self.handle_data}, self.got_consobject)) if not chainpulled: chainpulled = True os.write(pullchain[1],'1')