]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port zfssa driver to Python 3
authorVictor Stinner <vstinner@redhat.com>
Sun, 8 Nov 2015 21:13:14 +0000 (22:13 +0100)
committerVictor Stinner <vstinner@redhat.com>
Sun, 8 Nov 2015 21:14:38 +0000 (22:14 +0100)
* Replace base64.encodestring() with
  oslo_serialization.base64.encode_as_text() to accept Unicode as
  input (encoded to UTF-8). On Python 3, the function decodes base64
  from ASCII to get Unicode.
* tests-py3.txt: add cinder.tests.unit.test_zfssa

Partial-Implements: blueprint cinder-python3
Change-Id: I29a1a752d4cad5796fba1f21fe88238cb4414717

cinder/volume/drivers/zfssa/zfssaiscsi.py
cinder/volume/drivers/zfssa/zfssanfs.py
tests-py3.txt

index 389182b0bd55651bcc02f960a3e3b5112f510383..ccbcb74a79d2beb8d3e4f5a39adfb97d068a0513 100644 (file)
 ZFS Storage Appliance Cinder Volume Driver
 """
 import ast
-import base64
 import math
 
 from oslo_config import cfg
 from oslo_log import log
+from oslo_serialization import base64
 from oslo_utils import units
 import six
 
@@ -135,9 +135,8 @@ class ZFSSAISCSIDriver(driver.ISCSIDriver):
         self.zfssa = factory_zfssa()
         self.tgt_zfssa = factory_zfssa()
         self.zfssa.set_host(lcfg.san_ip, timeout=lcfg.zfssa_rest_timeout)
-        auth_str = base64.encodestring('%s:%s' %
-                                       (lcfg.san_login,
-                                        lcfg.san_password))[:-1]
+        auth_str = '%s:%s' % (lcfg.san_login, lcfg.san_password)
+        auth_str = base64.encode_as_text(auth_str)[:-1]
         self.zfssa.login(auth_str)
 
         self.zfssa.create_project(lcfg.zfssa_pool, lcfg.zfssa_project,
@@ -401,9 +400,8 @@ class ZFSSAISCSIDriver(driver.ISCSIDriver):
         host = lcfg.san_ip
         pool = lcfg.zfssa_pool
         project = lcfg.zfssa_project
-        auth_str = base64.encodestring('%s:%s' %
-                                       (lcfg.san_login,
-                                        lcfg.san_password))[:-1]
+        auth_str = '%s:%s' % (lcfg.san_login, lcfg.san_password)
+        auth_str = base64.encode_as_text(auth_str)[:-1]
         zfssa_tgt_group = lcfg.zfssa_target_group
         repl_ip = lcfg.zfssa_replication_ip
 
index 71dcc32b6e1aa139af248490ea71f2f6bbc81b2e..519606d573e23d0209ae11647b7fea1a1f051487 100644 (file)
 """
 ZFS Storage Appliance NFS Cinder Volume Driver
 """
-import base64
 import datetime as dt
 import errno
 import math
 
 from oslo_config import cfg
 from oslo_log import log
+from oslo_serialization import base64
 from oslo_utils import excutils
 from oslo_utils import units
 import six
@@ -133,7 +133,7 @@ class ZFSSANFSDriver(nfs.NfsDriver):
         self.zfssa = factory_zfssa()
         self.zfssa.set_host(host, timeout=lcfg.zfssa_rest_timeout)
 
-        auth_str = base64.encodestring('%s:%s' % (user, password))[:-1]
+        auth_str = base64.encode_as_text('%s:%s' % (user, password))[:-1]
         self.zfssa.login(auth_str)
 
         self.zfssa.create_project(lcfg.zfssa_nfs_pool, lcfg.zfssa_nfs_project,
index 179e93af11d443bc5ec3f836ce07b62a904c127d..11ef1e25aba5fdc36773fe66aeeb25675815597b 100644 (file)
@@ -121,6 +121,7 @@ cinder.tests.unit.test_volume_types
 cinder.tests.unit.test_volume_types_extra_specs
 cinder.tests.unit.test_volume_utils
 cinder.tests.unit.test_vzstorage
+cinder.tests.unit.test_zfssa
 cinder.tests.unit.volume.drivers.emc.scaleio
 cinder.tests.unit.volume.flows.test_create_volume_flow
 cinder.tests.unit.windows.test_smbfs