Make Quobyte shares actually read-only when requested

The string `access_level` won't ever be equal to `ro` in Quobyte Driver.
Do the right thing:
retrieve the `access_level` value from the `access` dict and
compare the result, as most likely intended but incorrectly implemented
and not tested. Also add the missing test.

Closes-Bug: 1498401

Change-Id: I735e5d0c91b5c8b258f4aa3461731ff293784995
This commit is contained in:
Nicolas Trangez 2015-06-12 15:43:44 +02:00 committed by Silvan Kaiser
parent a8e5154cf3
commit ec1d787885
2 changed files with 20 additions and 2 deletions

View File

@ -218,8 +218,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,):
self._get_project_name(context, share['project_id']))
self.rpc.call('exportVolume', dict(
volume_uuid=volume_uuid,
read_only='access_level' == (manila.common.constants.
ACCESS_LEVEL_RO),
read_only=access['access_level'] == (manila.common.constants.
ACCESS_LEVEL_RO),
add_allow_ip=access['access_to']))
def deny_access(self, context, share, access, share_server=None):

View File

@ -170,6 +170,24 @@ class QuobyteShareDriverTestCase(test.TestCase):
'read_only': False,
'add_allow_ip': '10.0.0.1'})
def test_allow_ro_access(self):
def rpc_handler(name, *args):
if name == 'resolveVolumeName':
return {'volume_uuid': 'voluuid'}
elif name == 'exportVolume':
return {'nfs_server_ip': '10.10.1.1',
'nfs_export_path': '/voluuid'}
self._driver.rpc.call = mock.Mock(wraps=rpc_handler)
ro_access = fake_share.fake_access(access_level='ro')
self._driver.allow_access(self._context, self.share, ro_access)
self._driver.rpc.call.assert_called_with(
'exportVolume', {'volume_uuid': 'voluuid',
'read_only': True,
'add_allow_ip': '10.0.0.1'})
def test_allow_access_nonip(self):
self._driver.rpc.call = mock.Mock(wraps=fake_rpc_handler)