Use six.test_type instead str format

Change-Id: I74139f2acfd3e0dd48372ba7cb49d8932973589c
Signed-off-by: Yuanbin.Chen <cybing4@gmail.com>
This commit is contained in:
Yuanbin.Chen 2018-05-02 21:54:56 +08:00
parent 9d982ae1bd
commit 3b84935921
4 changed files with 11 additions and 6 deletions

View File

@ -99,5 +99,5 @@ class DockerHTTPClient(docker.APIClient):
except errors.APIError as e:
if "process not found for container" in str(e):
raise exception.Invalid(_(
"no such exec instance: %s") % str(e))
"no such exec instance: %s") % six.text_type(e))
raise

View File

@ -41,7 +41,7 @@ class DockerDriver(driver.ContainerImageDriver):
except errors.ImageNotFound:
return
except errors.APIError as api_error:
raise exception.ZunException(str(api_error))
raise exception.ZunException(six.text_type(api_error))
except Exception as e:
LOG.exception('Unknown exception occurred while deleting '
'image %s in glance:%s',
@ -103,7 +103,7 @@ class DockerDriver(driver.ContainerImageDriver):
# TODO(hongbin): search image by both repo and tag
images = docker.search(repo)
except errors.APIError as api_error:
raise exception.ZunException(str(api_error))
raise exception.ZunException(six.text_type(api_error))
except Exception as e:
msg = _('Cannot search image in docker: {0}')
raise exception.ZunException(msg.format(e))

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import sys
from oslo_log import log as logging
@ -50,7 +51,7 @@ def load_image_driver(image_driver=None):
if not isinstance(driver, ContainerImageDriver):
raise Exception(_('Expected driver of type: %s') %
str(ContainerImageDriver))
six.text_type(ContainerImageDriver))
return driver
except Exception:

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from cinderclient import exceptions as cinder_exception
from os_brick import exception as os_brick_exception
from os_brick.initiator import connector as brick_connector
@ -151,7 +153,8 @@ class CinderWorkflow(object):
try:
cinder_api.begin_detaching(volume_id)
except cinder_exception.BadRequest as e:
raise exception.Invalid(_("Invalid volume: %s") % str(e))
raise exception.Invalid(_("Invalid volume: %s") %
six.text_type(e))
conn_info = jsonutils.loads(volume.connection_info)
try:
@ -172,4 +175,5 @@ class CinderWorkflow(object):
try:
cinder_api.delete_volume(volume_id)
except cinder_exception as e:
raise exception.Invalid(_("Delete Volume failed: %s") % str(e))
raise exception.Invalid(_("Delete Volume failed: %s") %
six.text_type(e))