Merge "Huawei driver support access of all IPs"

This commit is contained in:
Jenkins 2016-07-21 17:51:05 +00:00 committed by Gerrit Code Review
commit e50114897c
3 changed files with 30 additions and 0 deletions

View File

@ -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:

View File

@ -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,

View File

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