From 3606780826c2c7d80cf593d96b900b30d062d5fb Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 15 Dec 2021 09:35:12 -0500 Subject: [PATCH] Better tolerate issues during pause Unrelated issue can derail an update process. Make pause unlikely to throw unexpected issues, but print it out just in case. Further, give a hint when one specific scenario comes up that was seen and hard to debug. Change-Id: I635d3fc8df10b9bee9fc261d88beb7002b689a7e --- pyghmi/ipmi/private/session.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index 763db680..c7f629a1 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -1115,9 +1115,12 @@ class Session(object): @classmethod def pause(cls, timeout): - starttime = _monotonic_time() - while _monotonic_time() - starttime < timeout: - cls.wait_for_rsp(timeout - (_monotonic_time() - starttime)) + try: + starttime = _monotonic_time() + while _monotonic_time() - starttime < timeout: + cls.wait_for_rsp(timeout - (_monotonic_time() - starttime)) + except Exception as e: + print(repr(e)) @classmethod def wait_for_rsp(cls, timeout=None, callout=True): @@ -1529,8 +1532,12 @@ class Session(object): + self.remoteguid + struct.pack( "2B", self.nameonly | self.privlevel, userlen) + self.userid) - expectedhash = hmac.new(self.password, hmacdata, - self.currhashlib).digest() + try: + expectedhash = hmac.new(self.password, hmacdata, + self.currhashlib).digest() + except TypeError: + print('Password for {0} is somehow malformed'.format(self.bmc)) + return -9 hashlen = len(expectedhash) givenhash = struct.pack("%dB" % hashlen, *data[40:hashlen + 40]) if givenhash != expectedhash: