kontron / python-ipmi

A pure python IPMI library
GNU Lesser General Public License v2.1
187 stars 74 forks source link

ipmitool errors are not read correctly #108

Closed RomainTT closed 2 years ago

RomainTT commented 2 years ago

When using ipmitool I can have the following error message :

Error: Unable to establish IPMI v2 / RMCP+ session

But the following function does not handle this message correctly:

 94         def _parse_output(self, output):
 95             cc, rsp = None, None
 96             hexstr = ''
 97
 98             for line in py3dec_unic_bytes_fix(output).split('\n'):
 99                 # Don't try to parse ipmitool error messages
100                 if 'failed' in line:
101                     continue
102
103                 # Check for timeout
104                 if self.re_timeout.match(line):
105                     raise IpmiTimeoutError()
106
107                 # Check for completion code
108                 match_completion_code = self.re_completion_code.match(line)
109                 if match_completion_code:
110                     cc = int(match_completion_code.group(1), 16)
111                     break
112
113                 hexstr += line.replace('\r', '').strip() + ' '
114
115             hexstr = hexstr.strip()
116             if len(hexstr):
117                 rsp = array('B', [
118                     int(value, 16) for value in hexstr.split(' ')
119                 ])
120
121             return cc, rsp

It tries to cast the string into base16 values.

RomainTT commented 2 years ago

Thank you for your reactivity !