From d28955e3efbc42e70ed130ae6594583435ed02ad Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 12 Oct 2018 13:57:39 -0400 Subject: [PATCH] Fix early life mark_broken call If mark_broken called early, it would incorrectly fail due to self.socket not existing yet. Address this by ensuring the attribute exists earlier and ignoring the pool accounting if socket is not yet assigned. Additionally, fix a problem where the callback for console could happen before console actually had the ipmi_session attribute. Change-Id: Idb93ca23d4a43760698bdc55d19418210daa7a62 --- pyghmi/ipmi/console.py | 8 ++++++++ pyghmi/ipmi/private/session.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index 727420fe..a15a835a 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -58,6 +58,8 @@ class Console(object): self.activated = False self.force_session = force self.port = port + self.ipmi_session = None + self.callgotsession = None self.ipmi_session = session.Session(bmc=bmc, userid=userid, password=password, @@ -67,6 +69,9 @@ class Console(object): # induce one iteration of the loop, now that we would be # prepared for it in theory session.Session.wait_for_rsp(0) + if self.callgotsession is not None: + self._got_session(self.callgotsession) + self.callgotsession = None def _got_session(self, response): """Private function to navigate SOL payload activation @@ -74,6 +79,9 @@ class Console(object): if 'error' in response: self._print_error(response['error']) return + if not self.ipmi_session: + self.callgotsession = response + return # Send activate sol payload directive # netfn= 6 (application) # command = 0x48 (activate payload) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index f41fe0d2..0cd20439 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -484,6 +484,7 @@ class Session(object): self.iterwaiters.append(onlogon) return self.broken = False + self.socket = None self.logged = 0 self.privlevel = privlevel self.maxtimeout = 3 # be aggressive about giving up on initial packet @@ -556,7 +557,8 @@ class Session(object): self.errormsg = error if not self.broken: self.broken = True - self.socketpool[self.socket] -= 1 + if self.socket: + self.socketpool[self.socket] -= 1 def onlogon(self, parameter): if 'error' in parameter: