Merge "[NetApp] guard already existing cifs access"
This commit is contained in:
@@ -3837,12 +3837,16 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
|
||||
|
||||
@na_utils.trace
|
||||
def add_cifs_share_access(self, share_name, user_name, readonly):
|
||||
api_args = {
|
||||
'permission': 'read' if readonly else 'full_control',
|
||||
'share': share_name,
|
||||
'user-or-group': user_name,
|
||||
}
|
||||
self.send_request('cifs-share-access-control-create', api_args)
|
||||
try:
|
||||
api_args = {
|
||||
'permission': 'read' if readonly else 'full_control',
|
||||
'share': share_name,
|
||||
'user-or-group': user_name,
|
||||
}
|
||||
self.send_request('cifs-share-access-control-create', api_args)
|
||||
except netapp_api.NaApiError as e:
|
||||
if e.code != netapp_api.EDUPLICATEENTRY:
|
||||
raise
|
||||
|
||||
@na_utils.trace
|
||||
def modify_cifs_share_access(self, share_name, user_name, readonly):
|
||||
|
@@ -5641,10 +5641,19 @@ class NetAppClientCmodeTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual({}, result)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_add_cifs_share_access(self, readonly):
|
||||
@ddt.data({'readonly': False, 'exception': True},
|
||||
{'readonly': True, 'exception': False},
|
||||
{'readonly': False, 'exception': False},
|
||||
{'readonly': True, 'exception': True})
|
||||
@ddt.unpack
|
||||
def test_add_cifs_share_access(self, readonly, exception):
|
||||
|
||||
self.mock_object(self.client, 'send_request')
|
||||
mock_exception = mock.Mock(side_effect=netapp_api.NaApiError(
|
||||
code=netapp_api.EDUPLICATEENTRY))
|
||||
|
||||
self.mock_object(
|
||||
self.client, 'send_request',
|
||||
mock_exception if exception else mock.Mock(return_value=None))
|
||||
|
||||
self.client.add_cifs_share_access(fake.SHARE_NAME,
|
||||
fake.USER_NAME,
|
||||
|
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
NetApp ONTAP driver CIFS access control creation fixed for duplicate entry
|
||||
exception which means access already exist. For more details, please check
|
||||
`Launchpad bug #2114969 <https://bugs.launchpad.net/manila/+bug/2114969>`_
|
Reference in New Issue
Block a user