Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cristgal opened this issue Dec 18, 2020 · 5 comments
Open

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

cristgal opened this issue Dec 18, 2020 · 5 comments
Labels

Comments

@cristgal
Copy link

cristgal commented Dec 18, 2020

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
Copy link
Contributor

hthiery commented Dec 18, 2020

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
Copy link
Author

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
Copy link
Author

cristgal commented Dec 18, 2020

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
Copy link
Author

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
Copy link
Contributor

hthiery commented Dec 19, 2020

What version of python-ipmi are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants