kontron / python-ipmi

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

AttributeError: 'NoneType' object has no attribute 'routing' #89

Open cristgal opened 3 years ago

cristgal commented 3 years ago

Hello Guys, anyone would know what am I doing wrong?

Here's one of my servers:

$ ipmitool -H 10.8.1.18 -U root -P pass -I lanplus fru print 0
     Board Mfg Date        : Wed Oct 24 05:37:00 2018
     Board Mfg             : MYMFG
     Board Product         : MYBPD
     Board Serial          : MYBSN
     Board Part Number     : MYBPN
     Product Manufacturer  : MYMFG
     Product Name          : MYPPN
     Product Version       : 01
     Product Serial        : MYSER
     Product Asset Tag     : MYAST

Trying to deal with FRU in a script:

#!/bin/env python
    import pyipmi
    import pyipmi.interfaces
    def main():
        interface = pyipmi.interfaces.create_interface('ipmitool',
                                        interface_type='lanplus')
        ipmi = pyipmi.create_connection(interface)
        ipmi.session.set_session_type_rmcp('10.8.1.18', port=623)
        ipmi.session.set_auth_type_user('root', 'pass')
        ipmi.session.establish()
        fru = ipmi.get_fru_inventory(0)
        ipmi.session.close()
    if __name__ == "__main__":
        main()

but I get this error:

# python ./ipmi11.py
Traceback (most recent call last):
  File "./ipmi11.py", line 18, in <module>
    main()
  File "./ipmi11.py", line 13, in main
    fru = ipmi.get_fru_inventory()
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 88, in get_fru_inventory
    return FruInventory(self.read_fru_data(fru_id=fru_id))
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 58, in read_fru_data
    area_size = self.get_fru_inventory_area_info(fru_id)
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 35, in get_fru_inventory_area_info
    fru_id=fru_id)
  File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 206, in send_message_with_name
    rsp = self.send_message(req)
  File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 190, in send_message
    rsp = self.interface.send_and_receive(req)
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 147, in send_and_receive
    req_data.tostring())
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 96, in send_and_receive_raw
    cmd = self._build_ipmitool_cmd(target, lun, netfn, raw_bytes)
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 205, in _build_ipmitool_cmd
    cmd += self._build_ipmitool_target(target)
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 165, in _build_ipmitool_target
    if target.routing is not None:
AttributeError: 'NoneType' object has no attribute 'routing'

Ideas? Thanks!

hthiery commented 3 years ago

Hi,

take a look into the example https://github.com/kontron/python-ipmi/blob/master/examples/dcmi.py.

You have to set a proper target.

cristgal commented 3 years ago

Thanks, I added the target, now I'm getting something different:

#!/bin/env python
    import pyipmi
    import pyipmi.interfaces
    def main():
        interface = pyipmi.interfaces.create_interface('ipmitool',
                                        interface_type='lanplus')
        ipmi = pyipmi.create_connection(interface)
        ipmi.session.set_session_type_rmcp('10.8.1.18', port=623)
        ipmi.session.set_auth_type_user('root', 'pass')
        ipmi.session.establish()
        ipmi.target = pyipmi.Target(ipmb_address=0x20)
        fru = ipmi.get_fru_inventory(0)
        ipmi.session.close()
    if __name__ == "__main__":
        main()

Error:

  File "./ipmi11.py", line 19, in <module>
    main()
  File "./ipmi11.py", line 14, in main
    fru = ipmi.get_fru_inventory()
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 88, in get_fru_inventory
    return FruInventory(self.read_fru_data(fru_id=fru_id))
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 58, in read_fru_data
    area_size = self.get_fru_inventory_area_info(fru_id)
  File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 35, in get_fru_inventory_area_info
    fru_id=fru_id)
  File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 206, in send_message_with_name
    rsp = self.send_message(req)
  File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 190, in send_message
    rsp = self.interface.send_and_receive(req)
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 147, in send_and_receive
    req_data.tostring())
  File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 119, in send_and_receive_raw
    raise RuntimeError('ipmitool failed with rc=%d' % rc)
RuntimeError: ipmitool failed with rc=127
cristgal commented 3 years ago

Heiko @hthiery I literally copy&pasted the script you referenced, and I get the same rc=127, on centos7/py2.7&py3.6 and centos8stream/py3.8, ubuntu2004/py3.8. Thanks.

Traceback (most recent call last):
  File "./dcmi.py", line 47, in <module>
    main()
  File "./dcmi.py", line 28, in main
    caps = ipmi.get_dcmi_capabilities(selector)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/dcmi.py", line 30, in get_dcmi_capabilities
    rsp = self.send_message_with_name('GetDcmiCapabilities',
  File "/usr/local/lib/python3.8/site-packages/pyipmi/__init__.py", line 206, in send_message_with_name
    rsp = self.send_message(req)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/__init__.py", line 190, in send_message
    rsp = self.interface.send_and_receive(req)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/interfaces/ipmitool.py", line 146, in send_and_receive
    rsp_data = self.send_and_receive_raw(req.target, req.lun, req.netfn,
  File "/usr/local/lib/python3.8/site-packages/pyipmi/interfaces/ipmitool.py", line 119, in send_and_receive_raw
    raise RuntimeError('ipmitool failed with rc=%d' % rc)
RuntimeError: ipmitool failed with rc=127
cristgal commented 3 years ago

now I got a different error:

Traceback (most recent call last):
  File "./fru.py", line 32, in <module>
    main()
  File "./fru.py", line 28, in main
    fru = ipmi.get_fru_inventory(0)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 88, in get_fru_inventory
    return FruInventory(self.read_fru_data(fru_id=fru_id))
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 391, in __init__
    self._from_data(data)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 402, in _from_data
    self.board_info_area = InventoryBoardInfoArea(
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 158, in __init__
    self._from_data(data)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 230, in _from_data
    self.manufacturer = FruDataField(data, offset)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 114, in __init__
    self._from_data(data, offset, force_lang_english)
  File "/usr/local/lib/python3.8/site-packages/pyipmi/fru.py", line 133, in _from_data
    self.value = chr_data.decode('6bitascii')
AttributeError: 'str' object has no attribute 'decode'
hthiery commented 3 years ago

What version of python-ipmi are you using?