Gluster: fix mount.glusterfs argument passing
authorDimitris Bliablias <bl.dimitris@gmail.com>
Mon, 5 Jan 2015 15:09:33 +0000 (17:09 +0200)
committerHrvoje Ribicic <riba@google.com>
Wed, 21 Jan 2015 14:04:50 +0000 (15:04 +0100)
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 <bl.dimitris@gmail.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

lib/storage/gluster.py
test/py/ganeti.storage.gluster_unittest.py

index eb6d950..656474f 100644 (file)
@@ -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.
index 40e3031..b75bf6d 100644 (file)
@@ -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,))