python-ipmi icon indicating copy to clipboard operation
python-ipmi copied to clipboard

ipmitool backend example not works: option -l not recognized

Open mark99i opened this issue 10 months ago • 2 comments

import logging
logging.basicConfig(level=logging.DEBUG)

interface = pyipmi.interfaces.create_interface('ipmitool', interface_type='lan')

connection = pyipmi.create_connection(interface)

connection.target = pyipmi.Target(0x82)
connection.target.set_routing([(0x81,0x20,0),(0x20,0x82,7)])

connection.session.set_session_type_rmcp(ipmi_addr, port=623)
connection.session.set_auth_type_user(ipmi_login, ipmi_passw)
connection.session.set_priv_level("ADMINISTRATOR")
connection.session.establish()

connection.get_device_id()
DEBUG:pyipmi:IPMI Request [GetDeviceIdReq [netfn=6, cmd=1, grp=None]]
DEBUG:pyipmi:Running ipmitool "ipmitool -I lan -H 192.168.100.116 -p 623 -L ADMINISTRATOR -U "pyipmitest" -P "oRd7fQSUv2" -t 0x82 -b 0 -l 0 raw 0x06 0x01 2>&1"
DEBUG:pyipmi:return with rc=2, output was:
b'option -l not recognized\r\nipmitool vdev\r\nusage: ipmitool [options...] <command>\r\nOptions:\r\n  -t <addr>        Set target IPMB address\r\n  -b <channel>     Set target channel\r\n  -r <rtr>         Set target routing (not supported atm)\r\n  -h               Show this help\r\n  -v               Be verbose\r\n  -V               Print version\r\n  -I <interface>   Set interface (available: rmcp, aardvark, ipmitool, ipmbdev)\r\n  -H <host>        Set RMCP host\r\n  -U <user>        Set RMCP user\r\n  -L <level>       Set RMCP priviledge level\r\n  -P <password>    Set RMCP password\r\n  -o <options>     Set interface specific options (name=value, separated\r\n                   by commas, see below for available options).\r\n\r\nAardvark interface options:\r\n  serial=<SN>       Serial number of the device\r\n  pullups=<on|off>  Enable/disable pullups\r\n  power=<on|off>    Enable/disable target power\r\n  fastmode=<on|off> Enable/disable 400kHz I2C bitrate (Default 100kHz)\r\n\r\nIpmitool interface options:\r\n  interface_type    Set the interface type to be used (lan, lanplus, serial, open)\r\n  cipher            Set the cipher to be used (0-255)\r\n\r\nIpmbdev interface options:\r\n  port=<path>       Specify path to Linux IPMB device (/dev/ipmb-0 by default)\r\n\r\nCommands:\r\n  raw       Send a RAW IPMI request and print response\r\n  fru       Print built-in FRU and scan SDR for FRU locators\r\n  sensor    None\r\n  sel       Print System Event Log (SEL)\r\n  sdr       Print Sensor Data Repository entries and readings\r\n  bmc       Management Controller status and global enables\r\n  picmg     PICMG commands\r\n  hpm       HPM.1 commands\r\n  chassis   Get chassis status and set power state\r\n'
Traceback (most recent call last):
  File "C:\Users\mark\PycharmProjects\tests\tests\pyipmi-example.py", line 36, in <module>
    connection.get_device_id()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\bmc.py", line 25, in get_device_id
    return DeviceId(self.send_message_with_name('GetDeviceId'))
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\__init__.py", line 212, in send_message_with_name
    rsp = self.send_message(req)
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\__init__.py", line 196, in send_message
    rsp = self.interface.send_and_receive(req)
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\interfaces\ipmitool.py", line 178, in send_and_receive
    rsp_data = self.send_and_receive_raw(req.target, req.lun, req.netfn,
                                         py3_array_tobytes(req_data))
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\interfaces\ipmitool.py", line 153, in send_and_receive_raw
    cc, rsp = self._parse_output(output)
              ~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\mark\PycharmProjects\tests\.venv-3.13\Lib\site-packages\pyipmi\interfaces\ipmitool.py", line 135, in _parse_output
    int(value, 16) for value in hexstr.split(' ')
    ~~~^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: 'option'

mark99i avatar Feb 18 '25 17:02 mark99i

Hi, what ipmitool version you are using.

hthiery avatar Feb 27 '25 07:02 hthiery

I just checked the output. You are using the ipmitool.py that is part of this lib as ipmitool.

What should actually be used here is ipmitool from here: https://codeberg.org/IPMITool/ipmitool. This is used as backend for interfaces that not implemented in this lib.

This lib supports native RMCP interface (not RMCP+ or lanplus). So you could try this. See: https://github.com/kontron/python-ipmi/blob/master/examples/interface_rmcp.py

hthiery avatar Feb 27 '25 07:02 hthiery