Port IPMI to Python 3

binascii.hexlify() returns a byte string whereas the code expects a
native string, so Unicode on Python 3. On Python 3, decode the string
from ASCII to get Unicode.

Enable ipmi tests in tox.ini on Python 3.4.

Change-Id: I154723ad42efb61a06b71600975374441920a852
This commit is contained in:
Victor Stinner 2015-06-12 10:05:02 +02:00
parent 5977295daf
commit 4a392ca17d
2 changed files with 4 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import tempfile
import time
from oslo_config import cfg
import six
from ceilometer.i18n import _
from ceilometer.ipmi.platform import exception as nmexcept
@ -181,6 +182,8 @@ class NodeManager(object):
for line in bin_fp.readlines():
if line:
data_str = binascii.hexlify(line)
if six.PY3:
data_str = data_str.decode('ascii')
if prefix in data_str:
oem_id_index = data_str.index(prefix)
ret = data_str[oem_id_index + len(prefix):

View File

@ -56,6 +56,7 @@ commands = python -m testtools.run \
ceilometer.tests.dispatcher.test_file \
ceilometer.tests.dispatcher.test_http \
ceilometer.tests.energy.test_kwapi \
ceilometer.tests.ipmi.platform.test_intel_node_manager \
ceilometer.tests.network.services.test_fwaas \
ceilometer.tests.network.services.test_lbaas \
ceilometer.tests.network.services.test_vpnaas \