From c98cf2d8d9dacce854e3faf1181964cfe73eb48e Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Thu, 25 Jul 2013 00:19:56 +0800 Subject: [PATCH] use encode('utf8') instead of str() It is not clear for converting a unicode to string by using str(). Instead we should use var.encode('utf8') to do this. Change-Id: I8ce4c98f819c98e835a6d8298fe22f2fd0ca18b6 --- cinder/backup/drivers/ceph.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cinder/backup/drivers/ceph.py b/cinder/backup/drivers/ceph.py index d9c734194..c7d2c7b8e 100644 --- a/cinder/backup/drivers/ceph.py +++ b/cinder/backup/drivers/ceph.py @@ -112,9 +112,11 @@ class CephBackupDriver(BackupDriver): self.rbd_stripe_count = 0 self.rbd_stripe_unit = 0 - self._ceph_backup_user = str(CONF.backup_ceph_user) - self._ceph_backup_pool = str(CONF.backup_ceph_pool) - self._ceph_backup_conf = str(CONF.backup_ceph_conf) + _utf8 = lambda s: s if isinstance(s, str) else s.encode('utf8') + + self._ceph_backup_user = _utf8(CONF.backup_ceph_user) + self._ceph_backup_pool = _utf8(CONF.backup_ceph_pool) + self._ceph_backup_conf = _utf8(CONF.backup_ceph_conf) def _validate_string_args(self, *args): """Ensure all args are non-None and non-empty.""" -- 2.45.2