diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index c669a13866..a9d1327124 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -1067,12 +1067,31 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): raise exception.NetAppException(msg % security_service['type']) @na_utils.trace - def enable_nfs(self): + def enable_nfs(self, versions): """Enables NFS on Vserver.""" self.send_request('nfs-enable') - self.send_request('nfs-service-modify', {'is-nfsv40-enabled': 'true'}) + self._enable_nfs_protocols(versions) + self._create_default_nfs_export_rule() - api_args = { + @na_utils.trace + def _enable_nfs_protocols(self, versions): + """Set the enabled NFS protocol versions.""" + nfs3 = 'true' if 'nfs3' in versions else 'false' + nfs40 = 'true' if 'nfs4.0' in versions else 'false' + nfs41 = 'true' if 'nfs4.1' in versions else 'false' + + nfs_service_modify_args = { + 'is-nfsv3-enabled': nfs3, + 'is-nfsv40-enabled': nfs40, + 'is-nfsv41-enabled': nfs41, + } + self.send_request('nfs-service-modify', nfs_service_modify_args) + + @na_utils.trace + def _create_default_nfs_export_rule(self): + """Create the default export rule for the NFS service.""" + + export_rule_create_args = { 'client-match': '0.0.0.0/0', 'policy-name': 'default', 'ro-rule': { @@ -1082,7 +1101,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): 'security-flavor': 'never', }, } - self.send_request('export-rule-create', api_args) + self.send_request('export-rule-create', export_rule_create_args) @na_utils.trace def configure_ldap(self, security_service): diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py index 1aec0e9a25..6b80736eba 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py @@ -172,7 +172,8 @@ class NetAppCmodeMultiSVMFileStorageLibrary( network_info, ipspace_name) - vserver_client.enable_nfs() + vserver_client.enable_nfs( + self.configuration.netapp_enabled_share_protocols) security_services = network_info.get('security_services') if security_services: diff --git a/manila/share/drivers/netapp/options.py b/manila/share/drivers/netapp/options.py index 24b04a2d23..22d7d6b02e 100644 --- a/manila/share/drivers/netapp/options.py +++ b/manila/share/drivers/netapp/options.py @@ -58,6 +58,12 @@ netapp_basicauth_opts = [ secret=True), ] netapp_provisioning_opts = [ + cfg.ListOpt('netapp_enabled_share_protocols', + default=['nfs3', 'nfs4.0'], + help='The NFS protocol versions that will be enabled. ' + 'Supported values include nfs3, nfs4.0, nfs4.1. This ' + 'option only applies when the option ' + 'driver_handles_share_servers is set to True. '), cfg.StrOpt('netapp_volume_name_template', deprecated_name='netapp_nas_volume_name_template', help='NetApp volume name template.', diff --git a/manila/tests/share/drivers/netapp/dataontap/client/fakes.py b/manila/tests/share/drivers/netapp/dataontap/client/fakes.py index e526d7c61b..24bd9812ef 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/fakes.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/fakes.py @@ -37,6 +37,7 @@ VSERVER_NAME = 'fake_vserver' VSERVER_NAME_2 = 'fake_vserver_2' ADMIN_VSERVER_NAME = 'fake_admin_vserver' NODE_VSERVER_NAME = 'fake_node_vserver' +NFS_VERSIONS = ['nfs3', 'nfs4.0'] ROOT_VOLUME_AGGREGATE_NAME = 'fake_root_aggr' ROOT_VOLUME_NAME = 'fake_root_volume' SHARE_AGGREGATE_NAME = 'fake_aggr1' diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py index 8f28e770f9..26ee9aefda 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py @@ -1927,10 +1927,46 @@ class NetAppClientCmodeTestCase(test.TestCase): def test_enable_nfs(self): self.mock_object(self.client, 'send_request') + self.mock_object(self.client, '_enable_nfs_protocols') + self.mock_object(self.client, '_create_default_nfs_export_rule') - self.client.enable_nfs() + self.client.enable_nfs(fake.NFS_VERSIONS) + + self.client.send_request.assert_called_once_with('nfs-enable') + self.client._enable_nfs_protocols.assert_called_once_with( + fake.NFS_VERSIONS) + self.client._create_default_nfs_export_rule.assert_called_once_with() + + @ddt.data((True, True, True), (True, False, False), (False, True, True)) + @ddt.unpack + def test_enable_nfs_protocols(self, v3, v40, v41): + + self.mock_object(self.client, 'send_request') + + versions = [] + if v3: + versions.append('nfs3') + if v40: + versions.append('nfs4.0') + if v41: + versions.append('nfs4.1') + + self.client._enable_nfs_protocols(versions) + + nfs_service_modify_args = { + 'is-nfsv3-enabled': 'true' if v3 else 'false', + 'is-nfsv40-enabled': 'true' if v40 else 'false', + 'is-nfsv41-enabled': 'true' if v41 else 'false', + } + self.client.send_request.assert_called_once_with( + 'nfs-service-modify', nfs_service_modify_args) + + def test_create_default_nfs_export_rule(self): + + self.mock_object(self.client, 'send_request') + + self.client._create_default_nfs_export_rule() - nfs_service_modify_args = {'is-nfsv40-enabled': 'true'} export_rule_create_args = { 'client-match': '0.0.0.0/0', 'policy-name': 'default', @@ -1941,11 +1977,8 @@ class NetAppClientCmodeTestCase(test.TestCase): 'security-flavor': 'never' } } - - self.client.send_request.assert_has_calls([ - mock.call('nfs-enable'), - mock.call('nfs-service-modify', nfs_service_modify_args), - mock.call('export-rule-create', export_rule_create_args)]) + self.client.send_request.assert_called_once_with( + 'export-rule-create', export_rule_create_args) def test_configure_ldap(self): diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py index 6c9df347a7..7ffc0354f2 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py @@ -273,6 +273,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): def test_create_vserver(self): + versions = ['fake_v1', 'fake_v2'] + self.library.configuration.netapp_enabled_share_protocols = versions vserver_id = fake.NETWORK_INFO['server_id'] vserver_name = fake.VSERVER_NAME_TEMPLATE % vserver_id vserver_client = mock.Mock() @@ -306,7 +308,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): vserver_name, vserver_client, fake.NETWORK_INFO, fake.IPSPACE) self.library._create_vserver_admin_lif.assert_called_with( vserver_name, vserver_client, fake.NETWORK_INFO, fake.IPSPACE) - self.assertTrue(vserver_client.enable_nfs.called) + vserver_client.enable_nfs.assert_called_once_with(versions) self.library._client.setup_security_services.assert_called_with( fake.NETWORK_INFO['security_services'], vserver_client, vserver_name) diff --git a/releasenotes/notes/netapp-cdot-configure-nfs-versions-83e3f319c4592c39.yaml b/releasenotes/notes/netapp-cdot-configure-nfs-versions-83e3f319c4592c39.yaml new file mode 100644 index 0000000000..534ad1baea --- /dev/null +++ b/releasenotes/notes/netapp-cdot-configure-nfs-versions-83e3f319c4592c39.yaml @@ -0,0 +1,10 @@ +--- +features: + - NFS Versions can be configured when using the NetApp cDOT driver with + driver mode ``driver_handles_share_servers = True``. +upgrade: + - Added new configuration option ``netapp_enabled_share_protocols`` + to configure NFS versions with the NetApp cDOT driver operating in + driver mode ``driver_handles_share_servers = True``. If this option is not + specified, new share servers (NetApp vServers) will be created supporting + NFS Version 3 and NFS Version 4.0.