]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port remotefs driver to Python 3
authorVictor Stinner <vstinner@redhat.com>
Mon, 29 Jun 2015 20:15:18 +0000 (22:15 +0200)
committerVictor Stinner <vstinner@redhat.com>
Sat, 25 Jul 2015 01:10:07 +0000 (03:10 +0200)
* When parsing share configuration: replace "\040" with a space
  explicitly instead of using the Python unicode_escape encoding:
  see the bug #1180984.
* Encode Unicode to UTF-8 before hash it with MD5.
* tox.ini: add cinder.tests.unit.test_glusterfs to Python 3.4

Blueprint cinder-python3
Change-Id: Iea943a1f2dfb050fe43ff41411e258adb3f3b6d0

cinder/volume/drivers/remotefs.py
tox.ini

index f08b009c80a198c91cd7b724ed5068f3f67a9d5d..12b8f288eaaf4240a449765e71b24507843a2456 100644 (file)
@@ -25,6 +25,7 @@ import time
 from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_utils import units
+import six
 
 from cinder import compute
 from cinder import db
@@ -452,7 +453,9 @@ class RemoteFSDriver(driver.LocalVD, driver.TransferVD, driver.BaseVD):
                 # results in share_info =
                 #  [ 'address:/vol', '-o options=123,rw --other' ]
 
-                share_address = share_info[0].strip().decode('unicode_escape')
+                share_address = share_info[0].strip()
+                # Replace \040 with a space, to support paths with spaces
+                share_address = share_address.replace("\\040", " ")
                 share_opts = None
                 if len(share_info) > 1:
                     share_opts = share_info[1].strip()
@@ -749,6 +752,8 @@ class RemoteFSSnapDriver(RemoteFSDriver, driver.SnapshotVD):
         """Return a string that represents hash of base_str
         (in a hex format).
         """
+        if isinstance(base_str, six.text_type):
+            base_str = base_str.encode('utf-8')
         return hashlib.md5(base_str).hexdigest()
 
     def _get_mount_point_for_share(self, share):
diff --git a/tox.ini b/tox.ini
index f5d87a871333522942f6097b09eecbb5e65051eb..7f850bcb0e0b981f902a261329ef0798b2aa007b 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -60,6 +60,7 @@ commands =
     cinder.tests.unit.test_eqlx \
     cinder.tests.unit.test_evaluator \
     cinder.tests.unit.test_exception \
+    cinder.tests.unit.test_glusterfs \
     cinder.tests.unit.test_gpfs \
     cinder.tests.unit.test_hitachi_hbsd_horcm_fc \
     cinder.tests.unit.test_hitachi_hbsd_snm2_fc \