Huawei driver support access of all IPs

In access-allow and access-deny, change 0.0.0.0/0 to asterisk(*)
to represent IP addresses of all clients.

Change-Id: I7b79cf5fde88ba8eb273d71d6eb40bea5b744673
Closes-Bug: #1576557
This commit is contained in:
zhaohua 2016-04-29 15:45:25 +08:00
parent 62e01f076a
commit aa6a0e229b
3 changed files with 30 additions and 0 deletions

View File

@ -654,6 +654,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)
@ -695,6 +699,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:

View File

@ -2368,6 +2368,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,

View File

@ -0,0 +1,3 @@
---
fixes:
- Huawei driver now properly handles access for all IP addresses (0.0.0.0/0).