Added mount fstype based validation of Quobyte mounts

The validation of Quobyte mounts is extended to validate based
on a mounts file system type being set to "fuse.quobyte".

Closes-Bug: #1730933

Change-Id: I50430d67c2b9952d0b0c200920491c31f88a7ad7
This commit is contained in:
Silvan Kaiser 2017-11-08 12:56:29 +01:00
parent 543bba9577
commit ac0583c94a
3 changed files with 31 additions and 3 deletions

View File

@ -944,7 +944,7 @@ class QuobyteDriverTestCase(test.TestCase):
@mock.patch.object(psutil, "disk_partitions")
@mock.patch.object(os, "stat")
def test_validate_volume_all_good(self, stat_mock, part_mock):
def test_validate_volume_all_good_prefix_val(self, stat_mock, part_mock):
part_mock.return_value = self.get_mock_partitions()
drv = self._driver
@ -961,6 +961,27 @@ class QuobyteDriverTestCase(test.TestCase):
stat_mock.assert_called_once_with(self.TEST_MNT_POINT)
part_mock.assert_called_once_with(all=True)
@mock.patch.object(psutil, "disk_partitions")
@mock.patch.object(os, "stat")
def test_validate_volume_all_good_subtype_val(self, stat_mock, part_mock):
part_mock.return_value = self.get_mock_partitions()
part_mock.return_value[0].device = "not_quobyte"
part_mock.return_value[0].fstype = "fuse.quobyte"
drv = self._driver
def statMockCall(*args):
if args[0] == self.TEST_MNT_POINT:
stat_result = mock.Mock()
stat_result.st_size = 0
return stat_result
return os.stat(args)
stat_mock.side_effect = statMockCall
drv._validate_volume(self.TEST_MNT_POINT)
stat_mock.assert_called_once_with(self.TEST_MNT_POINT)
part_mock.assert_called_once_with(all=True)
@mock.patch.object(psutil, "disk_partitions")
@mock.patch.object(os, "stat")
def test_validate_volume_mount_not_working(self, stat_mock, part_mock):

View File

@ -32,7 +32,7 @@ from cinder import utils
from cinder.volume import configuration
from cinder.volume.drivers import remotefs as remotefs_drv
VERSION = '1.1.6'
VERSION = '1.1.7'
LOG = logging.getLogger(__name__)
@ -86,6 +86,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
1.1.4 - Fixes capability to configure redundancy in quobyte_volume_url
1.1.5 - Enables extension of volumes with snapshots
1.1.6 - Optimizes volume creation
1.1.7 - Support fuse subtype based Quobyte mount validation
"""
@ -504,7 +505,8 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
partitions = psutil.disk_partitions(all=True)
for p in partitions:
if mount_path == p.mountpoint:
if p.device.startswith("quobyte@"):
if (p.device.startswith("quobyte@") or
(p.fstype == "fuse.quobyte")):
try:
statresult = os.stat(mount_path)
if statresult.st_size == 0:

View File

@ -0,0 +1,5 @@
---
features:
- |
The Quobyte Cinder driver now supports identifying Quobyte mounts
via the mounts fstype field.