From c7bfeed1947b2301a5b3a9cc4b6fe726a301cece Mon Sep 17 00:00:00 2001 From: Naoki Saito Date: Wed, 21 Aug 2019 20:58:01 +0900 Subject: [PATCH] NEC Driver: Python3 compatibility This patch fixes Python3 incompatible codes in NEC driver. Change-Id: Ife4586de6fab2150334a06bf90031df4c81a045b (cherry picked from commit c6c26a56a214337e82dac78aae6291b42ad22fee) --- cinder/volume/drivers/nec/cli.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cinder/volume/drivers/nec/cli.py b/cinder/volume/drivers/nec/cli.py index 7bb9664fc0e..e726bb137da 100644 --- a/cinder/volume/drivers/nec/cli.py +++ b/cinder/volume/drivers/nec/cli.py @@ -28,6 +28,7 @@ from cinder import coordination from cinder import exception from cinder.i18n import _ from cinder import ssh_utils +from cinder import utils LOG = logging.getLogger(__name__) @@ -162,7 +163,8 @@ class MStorageISMCLI(object): break LOG.debug('`%(command)s` done. status=%(status)d.', {'command': command, 'status': status}) - out, err = ''.join(_out), ''.join(_err) + out = self._join_and_convert_str(_out) + err = self._join_and_convert_str(_err) if expected_status is not None and status not in expected_status: LOG.debug('`%(command)s` failed. status=%(status)d, ' 'out="%(out)s", err="%(err)s".', @@ -671,6 +673,14 @@ class MStorageISMCLI(object): 'cvnumber': cvnumber}) self._execute(cmd) + def _join_and_convert_str(self, src_list): + if len(src_list) == 0: + return '' + if isinstance(src_list[0], bytes): + return utils.convert_str(b''.join(src_list)) + else: + return ''.join(src_list) + class UnpairWait(object):