glusterfs: Modify interface methods
- Modify interface methods to comply with changes to the share manager.
The changes were in the following commit,
4c8a658d95
Change-Id: I6fde3e6d351f18878dc55fb3535f1dd0b811c352
This commit is contained in:
parent
da0e39f175
commit
ad4eab1b94
|
@ -269,7 +269,7 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
data['free_capacity_gb'] = (smpv.f_bavail * smpv.f_frsize) >> 30
|
||||
self._stats = data
|
||||
|
||||
def create_share(self, ctx, share):
|
||||
def create_share(self, ctx, share, share_server=None):
|
||||
"""Create a directory that'd serve as a share in a Gluster volume."""
|
||||
local_share_path = self._get_local_share_path(share)
|
||||
cmd = ['mkdir', local_share_path]
|
||||
|
@ -283,7 +283,7 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
share['name'])
|
||||
return export_location
|
||||
|
||||
def delete_share(self, context, share):
|
||||
def delete_share(self, context, share, share_server=None):
|
||||
"""Remove a directory that served as a share in a Gluster volume."""
|
||||
local_share_path = self._get_local_share_path(share)
|
||||
cmd = ['rm', '-rf', local_share_path]
|
||||
|
@ -293,19 +293,20 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
LOG.error('Unable to delete share %s', share['name'])
|
||||
raise
|
||||
|
||||
def create_snapshot(self, context, snapshot):
|
||||
def create_snapshot(self, context, snapshot, share_server=None):
|
||||
"""TBD: Is called to create snapshot."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def create_share_from_snapshot(self, context, share, snapshot):
|
||||
def create_share_from_snapshot(self, context, share, snapshot,
|
||||
share_server=None):
|
||||
"""Is called to create share from snapshot."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def delete_snapshot(self, context, snapshot):
|
||||
def delete_snapshot(self, context, snapshot, share_server=None):
|
||||
"""TBD: Is called to remove snapshot."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def ensure_share(self, context, share):
|
||||
def ensure_share(self, context, share, share_server=None):
|
||||
"""Might not be needed?"""
|
||||
pass
|
||||
|
||||
|
@ -351,7 +352,7 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
LOG.error(_("Error in gluster volume set: %s") % exc.stderr)
|
||||
raise
|
||||
|
||||
def allow_access(self, context, share, access):
|
||||
def allow_access(self, context, share, access, share_server=None):
|
||||
"""Allow access to a share."""
|
||||
def cbk(ddict, edir, host):
|
||||
if edir not in ddict:
|
||||
|
@ -361,7 +362,7 @@ class GlusterfsShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
ddict[edir].append(host)
|
||||
self._manage_access(context, share, access, cbk)
|
||||
|
||||
def deny_access(self, context, share, access):
|
||||
def deny_access(self, context, share, access, share_server=None):
|
||||
"""Deny access to a share."""
|
||||
def cbk(ddict, edir, host):
|
||||
if edir not in ddict or host not in ddict[edir]:
|
||||
|
|
|
@ -410,6 +410,18 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self.assertRaises(exception.ProcessExecutionError,
|
||||
self._driver.create_share, self._context, self.share)
|
||||
|
||||
def test_create_share_can_be_called_with_extra_arg_share_server(self):
|
||||
share_server = None
|
||||
self._driver._get_local_share_path = Mock()
|
||||
with patch.object(os.path, 'join', return_value=None):
|
||||
ret = self._driver.create_share(self._context, self.share,
|
||||
share_server)
|
||||
self.assertEqual(ret, None)
|
||||
self._driver._get_local_share_path.assert_called_once_with(
|
||||
self.share)
|
||||
os.path.join.assert_called_once_with(
|
||||
self._driver.gluster_address.qualified, self.share['name'])
|
||||
|
||||
def test_delete_share(self):
|
||||
self._driver._get_local_share_path =\
|
||||
Mock(return_value='/mnt/nfs/testvol/fakename')
|
||||
|
@ -431,6 +443,14 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self.assertRaises(exception.ProcessExecutionError,
|
||||
self._driver.delete_share, self._context, self.share)
|
||||
|
||||
def test_delete_share_can_be_called_with_extra_arg_share_server(self):
|
||||
share_server = None
|
||||
self._driver._get_local_share_path = Mock()
|
||||
ret = self._driver.delete_share(self._context, self.share,
|
||||
share_server)
|
||||
self.assertEqual(ret, None)
|
||||
self._driver._get_local_share_path.assert_called_once_with(self.share)
|
||||
|
||||
def test_manage_access_bad_access_type(self):
|
||||
cbk = Mock()
|
||||
access = {'access_type': 'bad'}
|
||||
|
@ -535,6 +555,15 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self._driver.allow_access(self._context, self.share, access)
|
||||
self.assertFalse(self._driver.gluster_address.make_gluster_args.called)
|
||||
|
||||
def test_allow_access_can_be_called_with_extra_arg_share_server(self):
|
||||
access = None
|
||||
share_server = None
|
||||
self._driver._manage_access = Mock()
|
||||
ret = self._driver.allow_access(self._context, self.share, access,
|
||||
share_server)
|
||||
self.assertEqual(ret, None)
|
||||
self._driver._manage_access.assert_called_once()
|
||||
|
||||
def test_deny_access_with_share_having_noaccess(self):
|
||||
access = {'access_type': 'ip', 'access_to': '10.0.0.1'}
|
||||
self._driver._get_export_dir_dict = Mock(return_value={})
|
||||
|
@ -555,3 +584,12 @@ class GlusterfsShareDriverTestCase(test.TestCase):
|
|||
self.assertEqual(
|
||||
self._driver.gluster_address.make_gluster_args.call_args[0][-1],
|
||||
'/example.com(10.0.0.1)')
|
||||
|
||||
def test_deny_access_can_be_called_with_extra_arg_share_server(self):
|
||||
access = None
|
||||
share_server = None
|
||||
self._driver._manage_access = Mock()
|
||||
ret = self._driver.deny_access(self._context, self.share, access,
|
||||
share_server)
|
||||
self.assertEqual(ret, None)
|
||||
self._driver._manage_access.assert_called_once()
|
||||
|
|
Loading…
Reference in New Issue