Fix `exportfs -u
` usage in generic driver.
When the generic driver extends or shrinks a share it disables access to the share by removing its export. Currently it uses the command ``exportfs -u local_path`` to do so, but this fails with current nfs packages. Fix the error by calling ``exportfs -u host:local_path`` instead. Change-Id: Ic489a1607bf82964bf2859e89b3da1f572436d17 Closes-Bug: #1649782
This commit is contained in:
parent
dc43f741f8
commit
7a7c182e35
@ -327,7 +327,11 @@ class NFSHelper(NASHelperBase):
|
|||||||
|
|
||||||
local_path = os.path.join(self.configuration.share_mount_path,
|
local_path = os.path.join(self.configuration.share_mount_path,
|
||||||
share_name)
|
share_name)
|
||||||
self._ssh_exec(server, ['sudo', 'exportfs', '-u', local_path])
|
out, err = self._ssh_exec(server, ['sudo', 'exportfs'])
|
||||||
|
hosts = self.get_host_list(out, local_path)
|
||||||
|
for host in hosts:
|
||||||
|
self._ssh_exec(server, ['sudo', 'exportfs', '-u',
|
||||||
|
':'.join((host, local_path))])
|
||||||
self._sync_nfs_temp_and_perm_files(server)
|
self._sync_nfs_temp_and_perm_files(server)
|
||||||
|
|
||||||
@nfs_synchronized
|
@nfs_synchronized
|
||||||
|
@ -247,11 +247,32 @@ class NFSHelperTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.assertEqual('/foo/bar', result)
|
self.assertEqual('/foo/bar', result)
|
||||||
|
|
||||||
def test_disable_access_for_maintenance(self):
|
@ddt.data(
|
||||||
|
('/shares/fake_share1\n\t\t1.1.1.10\n'
|
||||||
|
'/shares/fake_share2\n\t\t1.1.1.16\n'
|
||||||
|
'/mnt/fake_share1 1.1.1.11', False),
|
||||||
|
('/shares/fake_share_name\n\t\t1.1.1.10\n'
|
||||||
|
'/shares/fake_share_name\n\t\t1.1.1.16\n'
|
||||||
|
'/mnt/fake_share1\n\t\t1.1.1.11', True),
|
||||||
|
('/mnt/fake_share_name\n\t\t1.1.1.11\n'
|
||||||
|
'/shares/fake_share_name\n\t\t1.1.1.10\n'
|
||||||
|
'/shares/fake_share_name\n\t\t1.1.1.16\n', True))
|
||||||
|
@ddt.unpack
|
||||||
|
def test_disable_access_for_maintenance(self, output, hosts_match):
|
||||||
fake_maintenance_path = "fake.path"
|
fake_maintenance_path = "fake.path"
|
||||||
share_mount_path = os.path.join(
|
self._helper.configuration.share_mount_path = '/shares'
|
||||||
self._helper.configuration.share_mount_path, self.share_name)
|
local_path = os.path.join(self._helper.configuration.share_mount_path,
|
||||||
self.mock_object(self._helper, '_ssh_exec')
|
self.share_name)
|
||||||
|
|
||||||
|
def fake_ssh_exec(*args, **kwargs):
|
||||||
|
if 'exportfs' in args[1] and '-u' not in args[1]:
|
||||||
|
return output, ''
|
||||||
|
else:
|
||||||
|
return '', ''
|
||||||
|
|
||||||
|
self.mock_object(self._helper, '_ssh_exec',
|
||||||
|
mock.Mock(side_effect=fake_ssh_exec))
|
||||||
|
|
||||||
self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
|
self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
|
||||||
self.mock_object(self._helper, '_get_maintenance_file_path',
|
self.mock_object(self._helper, '_get_maintenance_file_path',
|
||||||
mock.Mock(return_value=fake_maintenance_path))
|
mock.Mock(return_value=fake_maintenance_path))
|
||||||
@ -265,10 +286,18 @@ class NFSHelperTestCase(test.TestCase):
|
|||||||
'|', 'grep', self.share_name,
|
'|', 'grep', self.share_name,
|
||||||
'|', 'sudo', 'tee', fake_maintenance_path]
|
'|', 'sudo', 'tee', fake_maintenance_path]
|
||||||
)
|
)
|
||||||
self._helper._ssh_exec.assert_any_call(
|
self._helper._ssh_exec.assert_has_calls([
|
||||||
self.server,
|
mock.call(self.server, ['sudo', 'exportfs']),
|
||||||
['sudo', 'exportfs', '-u', share_mount_path]
|
])
|
||||||
)
|
|
||||||
|
if hosts_match:
|
||||||
|
self._helper._ssh_exec.assert_has_calls([
|
||||||
|
mock.call(self.server, ['sudo', 'exportfs', '-u',
|
||||||
|
':'.join(['1.1.1.10', local_path])]),
|
||||||
|
mock.call(self.server, ['sudo', 'exportfs', '-u',
|
||||||
|
':'.join(['1.1.1.16', local_path])]),
|
||||||
|
])
|
||||||
|
|
||||||
self._helper._sync_nfs_temp_and_perm_files.assert_called_once_with(
|
self._helper._sync_nfs_temp_and_perm_files.assert_called_once_with(
|
||||||
self.server
|
self.server
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixed incorrect exportfs command used while extending and shrinking
|
||||||
|
shares on Generic driver.
|
Loading…
Reference in New Issue
Block a user