Merge "NetApp cDOT driver isn't reentrant" into stable/liberty
This commit is contained in:
commit
55b184a0cd
|
@ -48,6 +48,8 @@ class NetAppCmodeFileStorageLibrary(object):
|
|||
SSC_UPDATE_INTERVAL_SECONDS = 3600 # hourly
|
||||
HOUSEKEEPING_INTERVAL_SECONDS = 600 # ten minutes
|
||||
|
||||
SUPPORTED_PROTOCOLS = ('nfs', 'cifs')
|
||||
|
||||
# Maps NetApp qualified extra specs keys to corresponding backend API
|
||||
# client library argument keywords. When we expose more backend
|
||||
# capabilities here, we will add them to this map.
|
||||
|
@ -77,7 +79,6 @@ class NetAppCmodeFileStorageLibrary(object):
|
|||
self.configuration.append_config_values(
|
||||
na_opts.netapp_provisioning_opts)
|
||||
|
||||
self._helpers = None
|
||||
self._licenses = []
|
||||
self._client = None
|
||||
self._clients = {}
|
||||
|
@ -94,7 +95,6 @@ class NetAppCmodeFileStorageLibrary(object):
|
|||
def do_setup(self, context):
|
||||
self._client = self._get_api_client()
|
||||
self._have_cluster_creds = self._client.check_for_cluster_credentials()
|
||||
self._setup_helpers()
|
||||
|
||||
@na_utils.trace
|
||||
def check_for_setup_error(self):
|
||||
|
@ -296,24 +296,21 @@ class NetAppCmodeFileStorageLibrary(object):
|
|||
"""Find all aggregates match pattern."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@na_utils.trace
|
||||
def _setup_helpers(self):
|
||||
"""Initializes protocol-specific NAS drivers."""
|
||||
self._helpers = {'CIFS': cifs_cmode.NetAppCmodeCIFSHelper(),
|
||||
'NFS': nfs_cmode.NetAppCmodeNFSHelper()}
|
||||
|
||||
@na_utils.trace
|
||||
def _get_helper(self, share):
|
||||
"""Returns driver which implements share protocol."""
|
||||
share_protocol = share['share_proto']
|
||||
share_protocol = share['share_proto'].lower()
|
||||
|
||||
if share_protocol not in self.SUPPORTED_PROTOCOLS:
|
||||
err_msg = _("Invalid NAS protocol supplied: %s.") % share_protocol
|
||||
raise exception.NetAppException(err_msg)
|
||||
|
||||
self._check_license_for_protocol(share_protocol)
|
||||
|
||||
for protocol in self._helpers.keys():
|
||||
if share_protocol.upper().startswith(protocol):
|
||||
return self._helpers[protocol]
|
||||
|
||||
err_msg = _("Invalid NAS protocol supplied: %s. ") % share_protocol
|
||||
raise exception.NetAppException(err_msg)
|
||||
if share_protocol == 'nfs':
|
||||
return nfs_cmode.NetAppCmodeNFSHelper()
|
||||
elif share_protocol == 'cifs':
|
||||
return cifs_cmode.NetAppCmodeCIFSHelper()
|
||||
|
||||
@na_utils.trace
|
||||
def _check_license_for_protocol(self, share_protocol):
|
||||
|
|
|
@ -78,14 +78,12 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
|||
self.assertEqual(fake.DRIVER_NAME, self.library.driver_name)
|
||||
self.assertEqual(1, na_utils.validate_driver_instantiation.call_count)
|
||||
self.assertEqual(1, na_utils.setup_tracing.call_count)
|
||||
self.assertIsNone(self.library._helpers)
|
||||
self.assertListEqual([], self.library._licenses)
|
||||
self.assertDictEqual({}, self.library._clients)
|
||||
self.assertDictEqual({}, self.library._ssc_stats)
|
||||
self.assertIsNotNone(self.library._app_version)
|
||||
|
||||
def test_do_setup(self):
|
||||
mock_setup_helpers = self.mock_object(self.library, '_setup_helpers')
|
||||
mock_get_api_client = self.mock_object(self.library, '_get_api_client')
|
||||
|
||||
self.library.do_setup(self.context)
|
||||
|
@ -93,7 +91,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
|||
mock_get_api_client.assert_called_once_with()
|
||||
self.library._client.check_for_cluster_credentials.\
|
||||
assert_called_once_with()
|
||||
mock_setup_helpers.assert_called_once_with()
|
||||
|
||||
def test_check_for_setup_error(self):
|
||||
|
||||
|
@ -396,41 +393,26 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
|||
self.assertRaises(NotImplementedError,
|
||||
self.library._find_matching_aggregates)
|
||||
|
||||
def test_setup_helpers(self):
|
||||
@ddt.data(('NFS', nfs_cmode.NetAppCmodeNFSHelper),
|
||||
('nfs', nfs_cmode.NetAppCmodeNFSHelper),
|
||||
('CIFS', cifs_cmode.NetAppCmodeCIFSHelper),
|
||||
('cifs', cifs_cmode.NetAppCmodeCIFSHelper))
|
||||
@ddt.unpack
|
||||
def test_get_helper(self, protocol, helper_type):
|
||||
|
||||
self.mock_object(cifs_cmode,
|
||||
'NetAppCmodeCIFSHelper',
|
||||
mock.Mock(return_value='fake_cifs_helper'))
|
||||
self.mock_object(nfs_cmode,
|
||||
'NetAppCmodeNFSHelper',
|
||||
mock.Mock(return_value='fake_nfs_helper'))
|
||||
self.library._helpers = None
|
||||
|
||||
self.library._setup_helpers()
|
||||
|
||||
self.assertDictEqual({'CIFS': 'fake_cifs_helper',
|
||||
'NFS': 'fake_nfs_helper'},
|
||||
self.library._helpers)
|
||||
|
||||
def test_get_helper(self):
|
||||
|
||||
self.library._helpers = {'CIFS': 'fake_cifs_helper',
|
||||
'NFS': 'fake_nfs_helper'}
|
||||
self.library._licenses = fake.LICENSES
|
||||
fake_share = fake.SHARE.copy()
|
||||
fake_share['share_proto'] = 'NFS'
|
||||
fake_share['share_proto'] = protocol
|
||||
mock_check_license_for_protocol = self.mock_object(
|
||||
self.library, '_check_license_for_protocol')
|
||||
|
||||
result = self.library._get_helper(fake_share)
|
||||
|
||||
mock_check_license_for_protocol.assert_called_once_with('NFS')
|
||||
self.assertEqual('fake_nfs_helper', result)
|
||||
mock_check_license_for_protocol.assert_called_once_with(
|
||||
protocol.lower())
|
||||
self.assertTrue(type(result) == helper_type)
|
||||
|
||||
def test_get_helper_invalid_protocol(self):
|
||||
|
||||
self.library._helpers = {'CIFS': 'fake_cifs_helper',
|
||||
'NFS': 'fake_nfs_helper'}
|
||||
fake_share = fake.SHARE.copy()
|
||||
fake_share['share_proto'] = 'iSCSI'
|
||||
self.mock_object(self.library, '_check_license_for_protocol')
|
||||
|
@ -462,8 +444,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
|||
self.mock_object(self.library,
|
||||
'_get_licenses',
|
||||
mock.Mock(return_value=['base', 'nfs']))
|
||||
self.library._helpers = {'CIFS': 'fake_cifs_helper',
|
||||
'NFS': 'fake_nfs_helper'}
|
||||
self.library._licenses = ['base']
|
||||
|
||||
result = self.library._check_license_for_protocol('NFS')
|
||||
|
@ -477,8 +457,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
|||
self.mock_object(self.library,
|
||||
'_get_licenses',
|
||||
mock.Mock(return_value=['base']))
|
||||
self.library._helpers = {'CIFS': 'fake_cifs_helper',
|
||||
'NFS': 'fake_nfs_helper'}
|
||||
self.library._licenses = ['base']
|
||||
|
||||
self.assertRaises(exception.NetAppException,
|
||||
|
|
Loading…
Reference in New Issue