From f4590dad58474ba63d296dc47a349c409bc2a53a Mon Sep 17 00:00:00 2001 From: Jarrod Johnon Date: Thu, 22 Jan 2015 11:18:27 -0500 Subject: [PATCH] Assign code to timeout behavior While 'timeout' is not something defined in the IPMI spec (it would make no sense), assign it an impossible value so that calling code will experience timeout condition as if it were a 'normal' ipmi error. Change-Id: I8165497704148b79bc7996229f6f889b011e6d56 --- pyghmi/ipmi/command.py | 2 +- pyghmi/ipmi/private/constants.py | 1 + pyghmi/ipmi/private/session.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 7e24dec2..b8028907 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -384,7 +384,7 @@ class Command(object): if 'error' in rsp: if rsp['code'] == 203: # Sensor does not exist, optional dev continue - raise Exception(rsp['error']) + raise exc.IpmiException(rsp['error'], code=rsp['code']) yield self._sdr.sensors[sensor].decode_sensor_reading(rsp['data']) def get_sensor_descriptions(self): diff --git a/pyghmi/ipmi/private/constants.py b/pyghmi/ipmi/private/constants.py index 553a3097..98cbe909 100644 --- a/pyghmi/ipmi/private/constants.py +++ b/pyghmi/ipmi/private/constants.py @@ -1174,4 +1174,5 @@ ipmi_completion_codes = { 0xd5: "Command not supported in present state", 0xd6: "Cannot execute command because subfunction disabled or unavailable", 0xff: "Unspecified", + 0xffff: "Timeout", # not ipmi, but used internally } diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index a4181036..b3940c3e 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -1436,7 +1436,7 @@ class Session(object): self.nowait = True self.timeout += 1 if self.timeout > self.maxtimeout: - response = {'error': 'timeout'} + response = {'error': 'timeout', 'code': 0xffff} self.ipmicallback(response) self.nowait = False self._mark_broken()