From 87c7840c09260e9be0cd15e466d9aedd50203001 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 11 Oct 2019 09:29:51 -0400 Subject: [PATCH] Fix python3 for ipmi set user First normalize to bytes and then use byte to null pad and finally use bytearray to normalize the 2 and 3 to behave the same on indexing and use that for extending the command. Change-Id: I9e3e89f5f8ac411c770f1a6371f9b365868e8c87 --- pyghmi/ipmi/command.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index b69266f1..bd38e7ae 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1674,10 +1674,13 @@ class Command(object): :param name: username (limit of 16bytes) """ data = [uid] + if not isinstance(name, bytes): + name = name.encode('utf-8') if len(name) > 16: raise Exception('name must be less than or = 16 chars') - name = name.ljust(16, "\x00") - data.extend([ord(x) for x in name]) + name = name.ljust(16, b'\x00') + name = bytearray(name) + data.extend(name) self.xraw_command(netfn=0x06, command=0x45, data=data) return True