1
From 9e2073580b0080613f7860aee56d6399d463ad30 Mon Sep 17 00:00:00 2001
2
From: Ben Swartzlander <bswartz@netapp.com>
3
Date: Wed, 19 Sep 2012 17:30:22 -0400
4
Subject: [PATCH 39/39] Replace builtin hash with MD5 to solve 32/64-bit
7
It seems that Python's builtin hash returns different
8
values on 32-bit and 64-bit architectures, so it's
9
safer to use a well-defined hash like MD5.
13
Change-Id: Ibb49f7b9028085d2aedaf05b94e1e1dcdf5e4cb4
15
nova/tests/test_nfs.py | 9 +++++----
16
nova/volume/nfs.py | 4 ++--
17
2 files changed, 7 insertions(+), 6 deletions(-)
19
diff --git a/nova/tests/test_nfs.py b/nova/tests/test_nfs.py
20
index 8a931b0..4c97f12 100644
21
--- a/nova/tests/test_nfs.py
22
+++ b/nova/tests/test_nfs.py
23
@@ -109,8 +109,9 @@ class NfsDriverTestCase(test.TestCase):
24
volume['provider_location'] = self.TEST_NFS_EXPORT1
25
volume['name'] = 'volume-123'
27
- self.assertEqual('/mnt/test/12118957640568004265/volume-123',
28
- drv.local_path(volume))
30
+ '/mnt/test/2f4f60214cf43c595666dd815f0360a4/volume-123',
31
+ drv.local_path(volume))
33
def test_mount_nfs_should_mount_correctly(self):
34
"""_mount_nfs common case usage"""
35
@@ -212,7 +213,7 @@ class NfsDriverTestCase(test.TestCase):
36
"""_get_hash_str should calculation correct value"""
39
- self.assertEqual('12118957640568004265',
40
+ self.assertEqual('2f4f60214cf43c595666dd815f0360a4',
41
drv._get_hash_str(self.TEST_NFS_EXPORT1))
43
def test_get_mount_point_for_share(self):
44
@@ -221,7 +222,7 @@ class NfsDriverTestCase(test.TestCase):
46
nfs.FLAGS.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
48
- self.assertEqual('/mnt/test/12118957640568004265',
49
+ self.assertEqual('/mnt/test/2f4f60214cf43c595666dd815f0360a4',
50
drv._get_mount_point_for_share(self.TEST_NFS_EXPORT1))
52
def test_get_available_capacity_with_df(self):
53
diff --git a/nova/volume/nfs.py b/nova/volume/nfs.py
54
index f91b520..7a6ca83 100644
55
--- a/nova/volume/nfs.py
56
+++ b/nova/volume/nfs.py
58
# License for the specific language governing permissions and limitations
66
from nova import exception
67
@@ -290,4 +290,4 @@ class NfsDriver(driver.VolumeDriver):
69
def _get_hash_str(self, base_str):
70
"""returns string that represents hash of base_str (in a hex format)"""
71
- return str(ctypes.c_uint64(hash(base_str)).value)
72
+ return hashlib.md5(base_str).hexdigest()