python-ipmi
python-ipmi copied to clipboard
options `-R`(retry) request
Do you have any plans to provide -R
(retry) option?
-R retry Set the number of retries for lan/lanplus interface [default=4]
If ipmitool request to a hostname that does not exist, the following error occurs after about 5 seconds.
ipmitool
$ ipmitool -I lanplus -U user-P password -H 172.16.1.10 chassis status
Error: Unable to establish IPMI v2 / RMCP+ session
python-ipmi
ipmi.get_chassis_status()
Traceback (most recent call last):
File "ipmitool/ipmi.py", line 16, in <module>
device_id = ipmi.get_device_id()
File "pyipmi/bmc.py", line 25, in get_device_id
return DeviceId(self.send_message_with_name('GetDeviceId'))
File "pyipmi/init.py", line 206, in send_message_with_name
rsp = self.send_message(req)
File "pyipmi/init.py", line 190, in send_message
rsp = self.interface.send_and_receive(req)
File "pyipmi/interfaces/ipmitool.py", line 146, in send_and_receive
rsp_data = self.send_and_receive_raw(req.target, req.lun, req.netfn,
File "pyipmi/interfaces/ipmitool.py", line 119, in send_and_receive_raw
raise RuntimeError('ipmitool failed with rc=%d' % rc)
RuntimeError: ipmitool failed with rc=1
Since this time is too long, if i use the -R 1
option, an error is returned within 2 seconds.
$ ipmitool -I lanplus -U user -P password -H 172.16.1.10 chassis status -R 1
So, I want the following change. https://github.com/kontron/python-ipmi/blob/0.4.2/pyipmi/interfaces/ipmitool.py#L187
...
cmd += (' -R "%d"' % 1) # '1' is example, to be variable
...
Do you agree to offer these options? If you agree, I will send you an MR.
If you make the chane configurable I'm fine with that.