diff --git a/manila/share/drivers/huawei/v3/connection.py b/manila/share/drivers/huawei/v3/connection.py index ed5e94c417..e1c6c8964b 100644 --- a/manila/share/drivers/huawei/v3/connection.py +++ b/manila/share/drivers/huawei/v3/connection.py @@ -657,6 +657,10 @@ class V3StorageConnection(driver.HuaweiBase): return access_to = access['access_to'] + # Huawei array uses * to represent IP addresses of all clients + if (share_proto == 'NFS' and access_type == 'ip' and + access_to == '0.0.0.0/0'): + access_to = '*' share = self.helper._get_share_by_name(share_name, share_url_type) if not share: LOG.warning(_LW('Can not get share %s.'), share_name) @@ -698,6 +702,10 @@ class V3StorageConnection(driver.HuaweiBase): access_level = constants.ACCESS_NFS_RW else: access_level = constants.ACCESS_NFS_RO + # Huawei array uses * to represent IP addresses of all clients + if access_to == '0.0.0.0/0': + access_to = '*' + elif share_proto == 'CIFS': if access_type == 'user': if access_level == common_constants.ACCESS_LEVEL_RW: diff --git a/manila/tests/share/drivers/huawei/test_huawei_nas.py b/manila/tests/share/drivers/huawei/test_huawei_nas.py index 65b8971139..4d2d437d88 100644 --- a/manila/tests/share/drivers/huawei/test_huawei_nas.py +++ b/manila/tests/share/drivers/huawei/test_huawei_nas.py @@ -2467,6 +2467,25 @@ class HuaweiShareDriverTestCase(test.TestCase): self.driver.update_access, self._context, self.share_nfs, rules, None, None, self.share_server) + @ddt.data(True, False) + def test_nfs_access_for_all_ip_addresses(self, is_allow): + access_all = { + 'access_type': 'ip', + 'access_to': '0.0.0.0/0', + 'access_level': 'rw', + } + self.driver.plugin.helper.login() + method = (self.driver.allow_access if is_allow + else self.driver.deny_access) + with mock.patch.object(self.driver.plugin.helper, + '_get_access_from_share') as mock_call: + mock_call.return_value = None + + method(self._context, self.share_nfs, + access_all, self.share_server) + + mock_call.assert_called_with('1', '*', 'NFS') + def test_get_share_client_type_fail(self): share_proto = 'fake_proto' self.assertRaises(exception.InvalidInput, diff --git a/releasenotes/notes/huawei-support-access-all-ip-4994c10ff75ac683.yaml b/releasenotes/notes/huawei-support-access-all-ip-4994c10ff75ac683.yaml new file mode 100644 index 0000000000..6dcdf5ba2f --- /dev/null +++ b/releasenotes/notes/huawei-support-access-all-ip-4994c10ff75ac683.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Huawei driver now properly handles access for all IP addresses (0.0.0.0/0).