2
0
mirror of https://opendev.org/x/pyghmi synced 2025-02-05 13:32:48 +00:00

Fix set_hostname on generic IPMI in Py3

Python3 has encoding requirements, be consistent with them.

Change-Id: I2388dd00f560b8ce29638c5e2c7622afddb7c50f
This commit is contained in:
Jarrod Johnson 2021-01-21 12:42:07 -05:00
parent e0d284b404
commit dc7e23d324

View File

@ -1285,6 +1285,8 @@ class Command(object):
"""Set the management controller identifier, per DCMI specification
"""
if not isinstance(mci, bytes):
mci = mci.encode('utf8')
return self._chunkwise_dcmi_set(0xa, mci + b'\x00')
def get_asset_tag(self):
@ -1322,7 +1324,7 @@ class Command(object):
chunks = [data[i:i + 15] for i in range(0, len(data), 15)]
offset = 0
for chunk in chunks:
chunk = bytearray(chunk, 'utf-8')
chunk = bytearray(chunk)
cmddata = bytearray((0xdc, offset, len(chunk)))
cmddata += chunk
self.xraw_command(netfn=0x2c, command=command, data=cmddata)