Currently, the Gluster server port is included in the volume path,
i.e., <host>:<port>:<volumeid>, but the mount.glusterfs script requires
to explicitly specify the server port using the '-o server-port=port'
option. This would cause the port setting to be ignored and a default of
24007 to be used when using glusterfs versions later than 3.3.0 with
Ganeti, while for newer versions glusterfs mount fails.

This patch modifies '_GetFUSEMountString' method to generate the correct
argument string for the mount.glusterfs script. Also, it updates the
'ganeti.storage.gluster_unittest.py' unit test to correspond to the new
changes.

This fixes issue #984.

Signed-off-by: Dimitris Bliablias <[email protected]>
---
 lib/storage/gluster.py                     |    4 ++--
 test/py/ganeti.storage.gluster_unittest.py |    7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/storage/gluster.py b/lib/storage/gluster.py
index eb6d950..656474f 100644
--- a/lib/storage/gluster.py
+++ b/lib/storage/gluster.py
@@ -192,8 +192,8 @@ class GlusterVolume(object):
     @rtype: str
     """
 
-    return "{ip}:{port}:{volume}" \
-              .format(ip=self.server_ip, port=self.port, volume=self.volume)
+    return "-o server-port={port} {ip}:/{volume}" \
+              .format(port=self.port, ip=self.server_ip, volume=self.volume)
 
   def GetKVMMountString(self, path):
     """Return the string KVM needs to use this volume.
diff --git a/test/py/ganeti.storage.gluster_unittest.py 
b/test/py/ganeti.storage.gluster_unittest.py
index 40e3031..b75bf6d 100644
--- a/test/py/ganeti.storage.gluster_unittest.py
+++ b/test/py/ganeti.storage.gluster_unittest.py
@@ -119,7 +119,7 @@ class TestGlusterVolume(testutils.GanetiTestCase):
                                           vol_name="testvol")
     self.assertEqual(
       vol_1._GetFUSEMountString(),
-      "203.0.113.42:24007:testvol"
+      "-o server-port=24007 203.0.113.42:/testvol"
     )
 
     vol_2 = 
TestGlusterVolume._MakeVolume(addr=TestGlusterVolume.testAddrIpv[6],
@@ -128,7 +128,7 @@ class TestGlusterVolume(testutils.GanetiTestCase):
     # This _ought_ to work. https://bugzilla.redhat.com/show_bug.cgi?id=764188
     self.assertEqual(
       vol_2._GetFUSEMountString(),
-      "2001:db8:0:74:65:28:6:69:24007:testvol"
+      "-o server-port=24007 2001:db8:0:74:65:28:6:69:/testvol"
     )
 
     vol_3 = TestGlusterVolume._MakeVolume(addr="localhost",
@@ -136,7 +136,8 @@ class TestGlusterVolume(testutils.GanetiTestCase):
                                           vol_name="testvol")
     fuseMountString = vol_3._GetFUSEMountString()
     self.assertTrue(fuseMountString in
-                    ["127.0.0.1:9001:testvol", "::1:9001:testvol"],
+                    ["-o server-port=9001 127.0.0.1:/testvol",
+                     "-o server-port=9001 ::1:/testvol"],
                     msg="%s not testvol on localhost:9001" % 
(fuseMountString,))
 
 
-- 
1.7.10.4

Reply via email to