From 4a392ca17d93847fd0ce8da70c8c4b750b4481c9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 12 Jun 2015 10:05:02 +0200 Subject: [PATCH] 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 --- ceilometer/ipmi/platform/intel_node_manager.py | 3 +++ tox.ini | 1 + 2 files changed, 4 insertions(+) diff --git a/ceilometer/ipmi/platform/intel_node_manager.py b/ceilometer/ipmi/platform/intel_node_manager.py index ca07849b..4bb91a8a 100644 --- a/ceilometer/ipmi/platform/intel_node_manager.py +++ b/ceilometer/ipmi/platform/intel_node_manager.py @@ -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): diff --git a/tox.ini b/tox.ini index 6305cbc0..0b894630 100644 --- a/tox.ini +++ b/tox.ini @@ -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 \