From 6ad361a1858e9b349e3b379e720ff95bd38ac7ff Mon Sep 17 00:00:00 2001 From: Maurice Escher Date: Wed, 15 Jul 2020 10:31:29 +0200 Subject: [PATCH] [NetApp] update set_preferred_dc for ontapi 1.150 ONTAP 9.5 adds vserver cifs domain preferred-dc configuration validation. The parameter 'skip-config-validation' is mandatory for 'cifs-domain-preferred-dc-add' now and is set to false, i.e. an invalid config will raise early. Change-Id: I5eb97ba1b29ad24b296e12064f81eb93533c6b99 Closes-Bug: 1887643 (cherry picked from commit 3057d0643e8a93c4ae857159d96e94541ad0be4d) (cherry picked from commit 7248532de8927c953a6d32491060b11b1e4f2a6b) --- .../netapp/dataontap/client/client_cmode.py | 6 +++++ .../dataontap/client/test_client_cmode.py | 27 +++++++++++++++++-- ...fs-dc-add-skip-check-c8ea9b952cedb643.yaml | 7 +++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1887643-netapp-add-cifs-dc-add-skip-check-c8ea9b952cedb643.yaml diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index bf87129232..73682dd36a 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -70,6 +70,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): ontapi_1_2x = (1, 20) <= ontapi_version < (1, 30) ontapi_1_30 = ontapi_version >= (1, 30) ontapi_1_110 = ontapi_version >= (1, 110) + ontapi_1_150 = ontapi_version >= (1, 150) self.features.add_feature('SNAPMIRROR_V2', supported=ontapi_1_20) self.features.add_feature('SYSTEM_METRICS', supported=ontapi_1_2x) @@ -82,6 +83,8 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): self.features.add_feature('ADVANCED_DISK_PARTITIONING', supported=ontapi_1_30) self.features.add_feature('FLEXVOL_ENCRYPTION', supported=ontapi_1_110) + self.features.add_feature('CIFS_DC_ADD_SKIP_CHECK', + supported=ontapi_1_150) def _invoke_vserver_api(self, na_element, vserver): server = copy.copy(self.connection) @@ -1527,6 +1530,9 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): for dc_ip in security_service['server'].split(','): api_args['preferred-dc'].append({'string': dc_ip.strip()}) + if self.features.CIFS_DC_ADD_SKIP_CHECK: + api_args['skip-config-validation'] = 'false' + try: self.send_request('cifs-domain-preferred-dc-add', api_args) except netapp_api.NaApiError as e: 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 3447ef0c3f..55b147ce05 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 @@ -2724,8 +2724,28 @@ class NetAppClientCmodeTestCase(test.TestCase): self.client.configure_dns, fake.KERBEROS_SECURITY_SERVICE) - @ddt.data('', '10.0.0.1', ['10.0.0.2', '10.0.0.3']) - def test_set_preferred_dc(self, server): + @ddt.data( + { + 'server': '', + 'check_feature': False + }, + { + 'server': ['10.0.0.2', '10.0.0.3'], + 'check_feature': False + }, + { + 'server': '10.0.0.1', + 'check_feature': False + }, + { + 'server': '10.0.0.1', + 'check_feature': True + } + ) + @ddt.unpack + def test_set_preferred_dc(self, server, check_feature): + if check_feature: + self.client.features.add_feature('CIFS_DC_ADD_SKIP_CHECK') self.mock_object(self.client, 'send_request') security_service = copy.deepcopy(fake.CIFS_SECURITY_SERVICE) @@ -2741,6 +2761,9 @@ class NetAppClientCmodeTestCase(test.TestCase): 'preferred-dc': [{'string': dc_ip} for dc_ip in server] } + if check_feature: + preferred_dc_add_args['skip-config-validation'] = 'false' + self.client.send_request.assert_has_calls([ mock.call('cifs-domain-preferred-dc-add', preferred_dc_add_args)]) diff --git a/releasenotes/notes/bug-1887643-netapp-add-cifs-dc-add-skip-check-c8ea9b952cedb643.yaml b/releasenotes/notes/bug-1887643-netapp-add-cifs-dc-add-skip-check-c8ea9b952cedb643.yaml new file mode 100644 index 0000000000..ee4d9b662e --- /dev/null +++ b/releasenotes/notes/bug-1887643-netapp-add-cifs-dc-add-skip-check-c8ea9b952cedb643.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + The NetApp cDOT driver now validates the configuration of preferred domain + controller(s) added in CIFS security service server setup. The mandatory + option ``skip-config-validation`` was introduced to + ``cifs-domain-preferred-dc-add`` with ONTAP 9.5.