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: 'ByteBuffer' object has no attribute 'tobytes' #80

Closed
bdrung opened this issue Sep 18, 2020 · 0 comments · Fixed by #81
Closed

AttributeError: 'ByteBuffer' object has no attribute 'tobytes' #80

bdrung opened this issue Sep 18, 2020 · 0 comments · Fixed by #81

Comments

@bdrung
Copy link
Contributor

bdrung commented Sep 18, 2020

When using the latest version from git, python-ipmi fails on Ubuntu 20.04. Relevant code snippet:

interface = pyipmi.interfaces.create_interface(interface='ipmitool', interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp(host=fqdn, port=port)
ipmi.session.set_auth_type_user(username=username, password=password)
ipmi.target = pyipmi.Target()
ipmi.session.establish()
ipmi_info = ipmi.get_device_id()
Traceback (most recent call last):
  File "example.py", line 7
    ipmi_info = ipmi.get_device_id()
  File "/usr/lib/python3/dist-packages/pyipmi/bmc.py", line 25, in get_device_id
    return DeviceId(self.send_message_with_name('GetDeviceId'))
  File "/usr/lib/python3/dist-packages/pyipmi/__init__.py", line 206, in send_message_with_name
    rsp = self.send_message(req)
  File "/usr/lib/python3/dist-packages/pyipmi/__init__.py", line 190, in send_message
    rsp = self.interface.send_and_receive(req)
  File "/usr/lib/python3/dist-packages/pyipmi/interfaces/ipmitool.py", line 147, in send_and_receive
    py3_array_tobytes(req_data))
  File "/usr/lib/python3/dist-packages/pyipmi/utils.py", line 57, in py3_array_tobytes
    return msg.tobytes()
AttributeError: 'ByteBuffer' object has no attribute 'tobytes'
bdrung added a commit to bdrung/python-ipmi that referenced this issue Sep 28, 2020
Following Python code fails:

```python
interface = pyipmi.interfaces.create_interface(interface='ipmitool', interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp(host=fqdn, port=port)
ipmi.session.set_auth_type_user(username=username, password=password)
ipmi.target = pyipmi.Target()
ipmi.session.establish()
ipmi_info = ipmi.get_device_id()
```

```
Traceback (most recent call last):
  File "example.py", line 7
    ipmi_info = 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 147, in send_and_receive
    py3_array_tobytes(req_data))
  File "pyipmi/utils.py", line 57, in py3_array_tobytes
    return msg.tobytes()
AttributeError: 'ByteBuffer' object has no attribute 'tobytes'
```

Add a `ByteBuffer.tobytes` method. `ByteBuffer.tobytes` will only be
called if Python's array.array has a `tobytes` method. Therefore the
helper `py3_array_tobytes` is not needed.

Bug: kontron#80
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
hthiery pushed a commit that referenced this issue Sep 28, 2020
Following Python code fails:

```python
interface = pyipmi.interfaces.create_interface(interface='ipmitool', interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp(host=fqdn, port=port)
ipmi.session.set_auth_type_user(username=username, password=password)
ipmi.target = pyipmi.Target()
ipmi.session.establish()
ipmi_info = ipmi.get_device_id()
```

```
Traceback (most recent call last):
  File "example.py", line 7
    ipmi_info = 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 147, in send_and_receive
    py3_array_tobytes(req_data))
  File "pyipmi/utils.py", line 57, in py3_array_tobytes
    return msg.tobytes()
AttributeError: 'ByteBuffer' object has no attribute 'tobytes'
```

Add a `ByteBuffer.tobytes` method. `ByteBuffer.tobytes` will only be
called if Python's array.array has a `tobytes` method. Therefore the
helper `py3_array_tobytes` is not needed.

Bug: #80
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant