mirror of
https://opendev.org/x/pyghmi
synced 2025-01-27 19:37:44 +00:00
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
This commit is contained in:
parent
d3fbe9c06c
commit
d28955e3ef
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user