HNAS: Fix syntax to make shares read-only in snapshot create
Fixing driver syntax to make NFS shares read-only while snapshots are being taken. Read/Write permission in HNAS can be added in 3 ways: rw, readwrite and read_write, all of them should be handled by the driver. Change-Id: Ib9ba3c1717c8000a5393ea7b8d731d66f7237b2e Closes-Bug: #1661271
This commit is contained in:
parent
6b4171bff2
commit
e824e8ba8d
@ -969,7 +969,9 @@ class HitachiHNASDriver(driver.ShareDriver):
|
|||||||
saved_list = self.hnas.get_nfs_host_list(hnas_share_id)
|
saved_list = self.hnas.get_nfs_host_list(hnas_share_id)
|
||||||
new_list = []
|
new_list = []
|
||||||
for access in saved_list:
|
for access in saved_list:
|
||||||
new_list.append(access.replace('(rw)', '(ro)'))
|
for rw in ('read_write', 'readwrite', 'rw'):
|
||||||
|
access = access.replace(rw, 'ro')
|
||||||
|
new_list.append(access)
|
||||||
self.hnas.update_nfs_access_rule(new_list, share_id=hnas_share_id)
|
self.hnas.update_nfs_access_rule(new_list, share_id=hnas_share_id)
|
||||||
else: # CIFS
|
else: # CIFS
|
||||||
if (self.hnas.is_cifs_in_use(hnas_share_id) and
|
if (self.hnas.is_cifs_in_use(hnas_share_id) and
|
||||||
|
@ -497,6 +497,22 @@ class HitachiHNASTestCase(test.TestCase):
|
|||||||
@ddt.data(snapshot_nfs, snapshot_cifs)
|
@ddt.data(snapshot_nfs, snapshot_cifs)
|
||||||
def test_create_snapshot(self, snapshot):
|
def test_create_snapshot(self, snapshot):
|
||||||
hnas_id = snapshot['share_id']
|
hnas_id = snapshot['share_id']
|
||||||
|
access_list = ['172.24.44.200(rw,norootsquash)',
|
||||||
|
'172.24.49.180(all_squash,read_write,secure)',
|
||||||
|
'172.24.49.110(ro, secure)',
|
||||||
|
'172.24.49.112(secure,readwrite,norootsquash)',
|
||||||
|
'172.24.49.142(read_only, secure)',
|
||||||
|
'172.24.49.201(rw,read_write,readwrite)',
|
||||||
|
'172.24.49.218(rw)']
|
||||||
|
|
||||||
|
ro_list = ['172.24.44.200(ro,norootsquash)',
|
||||||
|
'172.24.49.180(all_squash,ro,secure)',
|
||||||
|
'172.24.49.110(ro, secure)',
|
||||||
|
'172.24.49.112(secure,ro,norootsquash)',
|
||||||
|
'172.24.49.142(read_only, secure)',
|
||||||
|
'172.24.49.201(ro,ro,ro)',
|
||||||
|
'172.24.49.218(ro)']
|
||||||
|
|
||||||
export_locations = [
|
export_locations = [
|
||||||
self._get_export(
|
self._get_export(
|
||||||
snapshot['id'], snapshot['share']['share_proto'],
|
snapshot['id'], snapshot['share']['share_proto'],
|
||||||
@ -511,7 +527,7 @@ class HitachiHNASTestCase(test.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.mock_object(ssh.HNASSSHBackend, "get_nfs_host_list", mock.Mock(
|
self.mock_object(ssh.HNASSSHBackend, "get_nfs_host_list", mock.Mock(
|
||||||
return_value=['172.24.44.200(rw)']))
|
return_value=access_list))
|
||||||
self.mock_object(ssh.HNASSSHBackend, "update_nfs_access_rule",
|
self.mock_object(ssh.HNASSSHBackend, "update_nfs_access_rule",
|
||||||
mock.Mock())
|
mock.Mock())
|
||||||
self.mock_object(ssh.HNASSSHBackend, "is_cifs_in_use", mock.Mock(
|
self.mock_object(ssh.HNASSSHBackend, "is_cifs_in_use", mock.Mock(
|
||||||
@ -531,9 +547,9 @@ class HitachiHNASTestCase(test.TestCase):
|
|||||||
ssh.HNASSSHBackend.get_nfs_host_list.assert_called_once_with(
|
ssh.HNASSSHBackend.get_nfs_host_list.assert_called_once_with(
|
||||||
hnas_id)
|
hnas_id)
|
||||||
ssh.HNASSSHBackend.update_nfs_access_rule.assert_any_call(
|
ssh.HNASSSHBackend.update_nfs_access_rule.assert_any_call(
|
||||||
['172.24.44.200(ro)'], share_id=hnas_id)
|
ro_list, share_id=hnas_id)
|
||||||
ssh.HNASSSHBackend.update_nfs_access_rule.assert_any_call(
|
ssh.HNASSSHBackend.update_nfs_access_rule.assert_any_call(
|
||||||
['172.24.44.200(rw)'], share_id=hnas_id)
|
access_list, share_id=hnas_id)
|
||||||
else:
|
else:
|
||||||
ssh.HNASSSHBackend.is_cifs_in_use.assert_called_once_with(
|
ssh.HNASSSHBackend.is_cifs_in_use.assert_called_once_with(
|
||||||
hnas_id)
|
hnas_id)
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixed HNAS driver creating snapshots of NFS shares
|
||||||
|
without first changing it to read-only.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user