diff --git a/ansible_collections/netapp/azure/netapp-azure-20.8.0.tar.gz b/ansible_collections/netapp/azure/netapp-azure-20.8.0.tar.gz index 066a2c8b..ca1a6484 100644 Binary files a/ansible_collections/netapp/azure/netapp-azure-20.8.0.tar.gz and b/ansible_collections/netapp/azure/netapp-azure-20.8.0.tar.gz differ diff --git a/ansible_collections/netapp/ontap/README.md b/ansible_collections/netapp/ontap/README.md index 335d96a1..0c7ead51 100644 --- a/ansible_collections/netapp/ontap/README.md +++ b/ansible_collections/netapp/ontap/README.md @@ -32,7 +32,7 @@ Join our Slack Channel at [Netapp.io](http://netapp.io/slack) ### New Options - na_ontap_aggregate: support `disk_size_with_unit` option. - na_ontap_ldap_client: support `ad_domain` and `preferred_ad_server` options. -- na_ontap_rest_info: Support for gather subsets - `cloud_targets_info, cluster_chassis_info, cluster_jobs_info, cluster_metrics_info, cluster_schedules, broadcast_domains_info, cluster_software_history, cluster_software_packages, network_ports_info, ip_interfaces_info, ip_routes_info, ip_service_policies, network_ipspaces_info`. +- na_ontap_rest_info: Support for gather subsets - `cloud_targets_info, cluster_chassis_info, cluster_jobs_info, cluster_metrics_info, cluster_schedules, broadcast_domains_info, cluster_software_history, cluster_software_packages, network_ports_info, ip_interfaces_info, ip_routes_info, ip_service_policies, network_ipspaces_info, san_fc_logins_info, san_fc_wppn-aliases, svm_dns_config_info, svm_ldap_config_info, svm_name_mapping_config_info, svm_nis_config_info, svm_peers_info, svm_peer-permissions_info`. - na_ontap_rest_info: Support for gather subsets for 9.8+ - `cluster_metrocluster_diagnostics. - na_ontap_qtree: `force_delete` option with a DEFAULT of `true` so that ZAPI behavior is aligned with REST. - na_ontap_security_certificates:`ignore_name_if_not_supported` option to not fail if `name` is present since `name` is not supported in ONTAP 9.6 and 9.7. diff --git a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_flexcache.py b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_flexcache.py index f9af7ec5..9dea364b 100644 --- a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_flexcache.py +++ b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_flexcache.py @@ -407,25 +407,6 @@ def volume_unmount(self): % (to_native(error)), exception=traceback.format_exc()) - def flexcache_delete_async(self): - """ - Delete FlexCache relationship at destination cluster - """ - options = {'volume': self.parameters['volume']} - flexcache_delete = netapp_utils.zapi.NaElement.create_node_with_children( - 'flexcache-destroy-async', **options) - try: - result = self.server.invoke_successfully(flexcache_delete, enable_tunneling=True) - except netapp_utils.zapi.NaApiError as error: - self.module.fail_json(msg='Error deleting FlexCache : %s' - % (to_native(error)), - exception=traceback.format_exc()) - results = dict() - for key in ('result-status', 'result-jobid'): - if result.get_child_by_name(key): - results[key] = result[key] - return results - def flexcache_delete(self): """ Delete FlexCache relationship at destination cluster diff --git a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_rest_info.py b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_rest_info.py index bde8a7f7..c1680933 100644 --- a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_rest_info.py +++ b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_rest_info.py @@ -50,12 +50,20 @@ "cluster_schedules" or "cluster/schedules", "cluster_software_history" or "cluster/software/history", "cluster_software_packages" or "cluster/software/packages", - "network_ports_info" or "network/ethernet/ports", + "disk_info" or "storage/disks", "ip_interfaces_info" or "network/ip/interfaces", "ip_routes_info" or "network/ip/routes", "ip_service_policies" or "network/ip/service-policies", "network_ipspaces_info" or "network/ipspaces", - "disk_info" or "storage/disks", + "network_ports_info" or "network/ethernet/ports", + "san_fc_logins_info" or "network/fc/logins", + "san_fc_wppn-aliases" or "network/fc/wwpn-aliases", + "svm_dns_config_info" or "name-services/dns", + "svm_ldap_config_info" or "name-services/ldap", + "svm_name_mapping_config_info" or "name-services/name-mappings", + "svm_nis_config_info" or "name-services/nis", + "svm_peers_info" or "svm/peers", + "svm_peer-permissions_info" or "svm/peer-permissions", "vserver_info" or "svm/svms", "volume_info" or "storage/volumes", Can specify a list of values to include a larger subset. @@ -270,12 +278,20 @@ def convert_subsets(self): "cluster_schedules": "cluster/schedules", "cluster_software_history": "cluster/software/history", "cluster_software_packages": "cluster/software/packages", - "network_ports_info": "network/ethernet/ports", + "disk_info": "storage/disks", "ip_interfaces_info": "network/ip/interfaces", "ip_routes_info": "network/ip/routes", "ip_service_policies": "network/ip/service-policies", "network_ipspaces_info": "network/ipspaces", - "disk_info": "storage/disks", + "network_ports_info": "network/ethernet/ports", + "san_fc_logins_info": "network/fc/logins", + "san_fc_wppn-aliases": "network/fc/wwpn-aliases", + "svm_dns_config_info": "name-services/dns", + "svm_ldap_config_info": "name-services/ldap", + "svm_name_mapping_config_info": "name-services/name-mappings", + "svm_nis_config_info": "name-services/nis", + "svm_peers_info": "svm/peers", + "svm_peer-permissions_info": "svm/peer-permissions", "vserver_info": "svm/svms", "volume_info": "storage/volumes" } @@ -302,15 +318,6 @@ def apply(self): # Defining gather_subset and appropriate api_call get_ontap_subset_info = { - 'storage/aggregates': { - 'api_call': 'storage/aggregates', - }, - 'protocols/cifs/services': { - 'api_call': 'protocols/cifs/services', - }, - 'protocols/cifs/shares': { - 'api_call': 'protocols/cifs/shares', - }, 'cloud/targets': { 'api_call': 'cloud/targets', }, @@ -342,9 +349,30 @@ def apply(self): 'cluster/software/packages': { 'api_call': 'cluster/software/packages', }, + 'name-services/dns': { + 'api_call': 'name-services/dns', + }, + 'name-services/ldap': { + 'api_call': 'name-services/ldap', + }, + 'name-services/name-mappings': { + 'api_call': 'name-services/name-mappings', + }, + 'name-services/nis': { + 'api_call': 'name-services/nis', + }, + 'network/ethernet/broadcast-domains': { + 'api_call': 'network/ethernet/broadcast-domains', + }, 'network/ethernet/ports': { 'api_call': 'network/ethernet/ports', }, + 'network/fc/logins': { + 'api_call': 'network/fc/logins', + }, + 'network/fc/wwpn-aliases': { + 'api_call': 'network/fc/wwpn-aliases', + }, 'network/ip/interfaces': { 'api_call': 'network/ip/interfaces', }, @@ -357,18 +385,30 @@ def apply(self): 'network/ipspaces': { 'api_call': 'network/ipspaces', }, - 'network/ethernet/broadcast-domains': { - 'api_call': 'network/ethernet/broadcast-domains', + 'storage/aggregates': { + 'api_call': 'storage/aggregates', }, 'storage/disks': { 'api_call': 'storage/disks', }, + 'storage/volumes': { + 'api_call': 'storage/volumes', + }, + 'svm/peers': { + 'api_call': 'svm/peers', + }, + 'svm/peer-permissions': { + 'api_call': 'svm/peer-permissions', + }, 'svm/svms': { 'api_call': 'svm/svms', }, - 'storage/volumes': { - 'api_call': 'storage/volumes', + 'protocols/cifs/services': { + 'api_call': 'protocols/cifs/services', }, + 'protocols/cifs/shares': { + 'api_call': 'protocols/cifs/shares', + } } if 'all' in self.parameters['gather_subset']: diff --git a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_snapmirror.py b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_snapmirror.py index 5091cabe..00338142 100644 --- a/ansible_collections/netapp/ontap/plugins/modules/na_ontap_snapmirror.py +++ b/ansible_collections/netapp/ontap/plugins/modules/na_ontap_snapmirror.py @@ -680,8 +680,7 @@ def snapmirror_update(self): snapmirror_update = netapp_utils.zapi.NaElement.create_node_with_children( 'snapmirror-update', **options) try: - result = self.server.invoke_successfully(snapmirror_update, - enable_tunneling=True) + self.server.invoke_successfully(snapmirror_update, enable_tunneling=True) except netapp_utils.zapi.NaApiError as error: self.module.fail_json(msg='Error updating SnapMirror : %s' % (to_native(error)), diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_dns.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_dns.py index 071d8062..92ba524b 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_dns.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_dns.py @@ -152,6 +152,7 @@ def test_module_fail_when_required_args_missing(self): def test_idempotent_modify_dns(self): data = self.mock_args() + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_dns_mock_object('zapi', 'enable', 'false').apply() @@ -160,6 +161,7 @@ def test_idempotent_modify_dns(self): def test_successfully_modify_dns(self): data = self.mock_args() data['domains'] = ['new_test.com'] + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_dns_mock_object('zapi', 'enable', 'false').apply() @@ -168,6 +170,7 @@ def test_successfully_modify_dns(self): @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.ems_log_event') def test_idempotent_create_dns(self, mock_ems_log_event): data = self.mock_args() + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_dns_mock_object('zapi').apply() @@ -178,6 +181,7 @@ def test_successfully_create_dns(self, mock_ems_log_event): data = self.mock_args() print("create dns") data['domains'] = ['new_test.com'] + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_dns_mock_object('zapi', 'create').apply() diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_export_policy.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_export_policy.py index 3b190d34..1ed9f2b0 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_export_policy.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_export_policy.py @@ -130,7 +130,8 @@ def mock_args(self, rest=False): 'name': self.mock_export_policy['name'], 'hostname': 'test', 'username': 'test_user', - 'password': 'test_pass!' + 'password': 'test_pass!', + 'use_rest': 'never' } def get_export_policy_mock_object(self, type='zapi', kind=None): diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_flexcache.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_flexcache.py index a7b5929d..ae93f142 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_flexcache.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_flexcache.py @@ -520,8 +520,10 @@ def test_create_flexcache_time_out(self): if not self.onbox: my_obj.server = MockONTAPConnection(job_error='time_out') with patch.object(my_module, 'flexcache_create', wraps=my_obj.flexcache_create) as mock_create: - with pytest.raises(AnsibleFailJson) as exc: - my_obj.apply() + # replace time.sleep with a noop + with patch('time.sleep', lambda a: None): + with pytest.raises(AnsibleFailJson) as exc: + my_obj.apply() print('Create: ' + repr(exc.value)) msg = 'Error when creating flexcache: job completion exceeded expected timer of: %s seconds' \ % args['time_out'] diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_ipspace.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_ipspace.py index 1b4140ec..d615ac24 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_ipspace.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_ipspace.py @@ -117,7 +117,7 @@ def get_ipspace_mock_object(type='zapi', kind=None, status=None): if kind is None: ipspace_obj.server = MockONTAPConnection() else: - ipspace_obj.server = MockONTAPConnection(kind=kind, data=status) + ipspace_obj.server = MockONTAPConnection(kind=kind, parm1=status) return ipspace_obj def test_fail_requiredargs_missing(self): @@ -127,8 +127,13 @@ def test_fail_requiredargs_missing(self): my_module() print('Info: %s' % exc.value.args[0]['msg']) - def test_get_ipspace_iscalled(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_get_ipspace_iscalled(self, mock_request): ''' test if get_ipspace() is called ''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] set_module_args(self.set_default_args()) my_obj = my_module() my_obj.server = self.server @@ -136,8 +141,13 @@ def test_get_ipspace_iscalled(self): print('Info: test_get_ipspace: %s' % repr(ipspace)) assert ipspace is None - def test_ipspace_apply_iscalled(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_ipspace_apply_iscalled(self, mock_request): ''' test if apply() is called ''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] module_args = {'name': 'test_apply_ips'} module_args.update(self.set_default_args()) set_module_args(module_args) diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_job_schedule.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_job_schedule.py index 479441a1..40a8aaf9 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_job_schedule.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_job_schedule.py @@ -102,9 +102,6 @@ def invoke_successfully(self, xml, enable_tunneling): # pylint: disable=unused- xml = self.build_job_schedule_cron_info(self.params) elif self.kind == 'job_multiple': xml = self.build_job_schedule_multiple_cron_info(self.params) - # TODO: mock invoke_elem for autosupport calls - elif self.kind == 'vserver': - xml = self.build_vserver_info() self.xml_out = xml return xml @@ -188,7 +185,8 @@ def mock_args(self, rest=False): 'job_minutes': [self.mock_job['minutes']], 'hostname': 'test', 'username': 'test_user', - 'password': 'test_pass!' + 'password': 'test_pass!', + 'use_rest': 'never' } def get_job_mock_object(self, kind=None, call_type='zapi'): diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_login_messages.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_login_messages.py index 51ee985e..c001bde1 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_login_messages.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_login_messages.py @@ -173,6 +173,7 @@ def test_module_fail_when_required_args_missing(self): def test_successfully_create_banner(self): data = self.mock_args() data['banner'] = 'test banner' + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_login_mock_object('zapi', 'create', data).apply() @@ -181,6 +182,7 @@ def test_successfully_create_banner(self): def test_create_banner_idempotency(self): data = self.mock_args() data['banner'] = 'test banner' + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_login_mock_object('zapi', 'create_idempotency', data).apply() @@ -189,6 +191,7 @@ def test_create_banner_idempotency(self): def test_successfully_create_motd(self): data = self.mock_args() data['motd_message'] = 'test message' + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_login_mock_object('zapi', 'create', data).apply() @@ -197,6 +200,7 @@ def test_successfully_create_motd(self): def test_create_motd_idempotency(self): data = self.mock_args() data['motd_message'] = 'test message' + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_login_mock_object('zapi', 'create_idempotency', data).apply() @@ -204,6 +208,7 @@ def test_create_motd_idempotency(self): def test_get_banner_error(self): data = self.mock_args() + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleFailJson) as exc: self.get_login_mock_object('zapi', 'error', data).apply() @@ -213,6 +218,7 @@ def test_get_banner_error(self): def test_modify_banner_error(self, get_info): data = self.mock_args() data['banner'] = 'modify to new banner' + data['use_rest'] = 'never' set_module_args(data) get_info.side_effect = [ { @@ -228,6 +234,7 @@ def test_modify_banner_error(self, get_info): def test_modify_motd_error(self, get_info): data = self.mock_args() data['motd_message'] = 'modify to new motd' + data['use_rest'] = 'never' set_module_args(data) get_info.side_effect = [ { diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_object_store.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_object_store.py index 1f618b45..de8953b8 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_object_store.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_object_store.py @@ -151,22 +151,37 @@ def test_module_fail_when_required_args_missing(self): my_module() print('Info: %s' % exc.value.args[0]['msg']) - def test_ensure_object_store_get_called(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_ensure_object_store_get_called(self, mock_request): ''' fetching details of object store ''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] set_module_args(self.set_default_args()) my_obj = my_module() my_obj.server = self.server assert my_obj.get_aggr_object_store() is not None - def test_ensure_get_called_existing(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_ensure_get_called_existing(self, mock_request): ''' test for existing object store''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] set_module_args(self.set_default_args()) my_obj = my_module() my_obj.server = MockONTAPConnection(kind='object_store') assert my_obj.get_aggr_object_store() - def test_object_store_create(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_object_store_create(self, mock_request): ''' test for creating object store''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] module_args = { 'provider_type': 'abc', 'server': 'abc', @@ -185,8 +200,13 @@ def test_object_store_create(self): my_obj.apply() assert not exc.value.args[0]['changed'] - def test_object_store_delete(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_object_store_delete(self, mock_request): ''' test for deleting object store''' + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] module_args = { 'state': 'absent', } @@ -195,6 +215,10 @@ def test_object_store_delete(self): @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') def test_rest_error(self, mock_request): + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] set_module_args(self.set_default_args()) mock_request.side_effect = [ SRR['is_rest'], @@ -248,7 +272,12 @@ def test_rest_successful_delete(self, mock_request): my_obj.apply() assert exc.value.args[0]['changed'] - def test_if_all_methods_catch_exception(self): + @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') + def test_if_all_methods_catch_exception(self, mock_request): + mock_request.side_effect = [ + SRR['is_zapi'], + SRR['end_of_sequence'] + ] module_args = { 'provider_type': 'abc', 'server': 'abc', diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_rest_info.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_rest_info.py index abdd1ebf..5552ecd7 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_rest_info.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_rest_info.py @@ -316,12 +316,14 @@ def test_run_Ontap_gather_facts_for_volume_info_pass(self, mock_request): def test_run_Ontap_gather_facts_for_all_subsets_pass(self, mock_request): set_module_args(self.set_args_run_Ontap_gather_facts_for_all_subsets()) my_obj = ontap_rest_info_module() - gather_subset = ['storage/aggregates', 'svm/svms', 'storage/volumes', 'cloud/targets', - 'cluster/chassis', 'cluster/jobs', 'cluster/metrics', 'cluster/nodes', - 'cluster/peers', 'cluster/schedules', 'protocols/cifs/services', 'protocols/cifs/shares', - 'storage/disks', 'cluster/software/history', 'cluster/software/packages', 'network/ethernet/ports', - 'network/ip/interfaces', 'network/ip/routes', 'network/ip/service-policies', 'network/ipspaces', - 'network/ethernet/broadcast-domains', 'cluster/metrocluster/diagnostics'] + gather_subset = ['cloud/targets', 'cluster/chassis', 'cluster/jobs', 'cluster/metrocluster/diagnostics', + 'cluster/metrics', 'cluster/nodes', 'cluster/peers', 'cluster/schedules', 'cluster/software/history', + 'cluster/software/packages', 'name-services/dns', 'name-services/ldap', 'name-services/name-mappings', + 'name-services/nis', 'network/ethernet/broadcast-domains', 'network/ethernet/ports', + 'network/fc/logins', 'network/fc/wwpn-aliases', 'network/ip/interfaces', 'network/ip/routes', + 'network/ip/service-policies', 'network/ipspaces', 'storage/aggregates', 'storage/disks', + 'storage/volumes', 'svm/peers', 'svm/peer-permissions', 'svm/svms', 'protocols/cifs/services', + 'protocols/cifs/shares'] mock_request.side_effect = [ SRR['validate_ontap_version_pass'], SRR['get_subset_info'], @@ -348,6 +350,14 @@ def test_run_Ontap_gather_facts_for_all_subsets_pass(self, mock_request): SRR['get_subset_info'], SRR['get_subset_info'], SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], ] with pytest.raises(AnsibleExitJson) as exc: @@ -361,12 +371,14 @@ def test_run_Ontap_gather_facts_for_all_subsets_pass(self, mock_request): def test_run_Ontap_gather_facts_for_all_subsets_with_fields_section_pass(self, mock_request): set_module_args(self.set_args_run_Ontap_gather_facts_for_all_subsets_with_fields_section_pass()) my_obj = ontap_rest_info_module() - gather_subset = ['storage/aggregates', 'svm/svms', 'storage/volumes', 'cloud/targets', - 'cluster/chassis', 'cluster/jobs', 'cluster/metrics', 'cluster/nodes', - 'cluster/peers', 'cluster/schedules', 'protocols/cifs/services', 'protocols/cifs/shares', - 'storage/disks', 'cluster/software/history', 'cluster/software/packages', 'network/ethernet/ports', - 'network/ip/interfaces', 'network/ip/routes', 'network/ip/service-policies', 'network/ipspaces', - 'network/ethernet/broadcast-domains', 'cluster/metrocluster/diagnostics'] + gather_subset = ['cloud/targets', 'cluster/chassis', 'cluster/jobs', 'cluster/metrocluster/diagnostics', + 'cluster/metrics', 'cluster/nodes', 'cluster/peers', 'cluster/schedules', 'cluster/software/history', + 'cluster/software/packages', 'name-services/dns', 'name-services/ldap', 'name-services/name-mappings', + 'name-services/nis', 'network/ethernet/broadcast-domains', 'network/ethernet/ports', + 'network/fc/logins', 'network/fc/wwpn-aliases', 'network/ip/interfaces', 'network/ip/routes', + 'network/ip/service-policies', 'network/ipspaces', 'storage/aggregates', 'storage/disks', + 'storage/volumes', 'svm/peers', 'svm/peer-permissions', 'svm/svms', 'protocols/cifs/services', + 'protocols/cifs/shares'] mock_request.side_effect = [ SRR['validate_ontap_version_pass'], SRR['get_subset_info'], @@ -393,7 +405,14 @@ def test_run_Ontap_gather_facts_for_all_subsets_with_fields_section_pass(self, m SRR['get_subset_info'], SRR['get_subset_info'], SRR['get_subset_info'], - + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], + SRR['get_subset_info'], ] with pytest.raises(AnsibleExitJson) as exc: diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_snapmirror.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_snapmirror.py index 2f9a84ec..b568e218 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_snapmirror.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_snapmirror.py @@ -205,7 +205,9 @@ def test_failure_break(self): if not self.onbox: my_obj.server = MockONTAPConnection('snapmirror', 'snapmirrored', status='idle', quiesce_status='InProgress') with pytest.raises(AnsibleFailJson) as exc: - my_obj.apply() + # replace time.sleep with a noop + with patch('time.sleep', lambda a: None): + my_obj.apply() assert 'Taking a long time to Quiescing SnapMirror, try again later' in exc.value.args[0]['msg'] def test_successful_break(self): @@ -478,8 +480,7 @@ def test_elementsw_volume_exists(self): mock_helper.volume_id_exists.side_effect = [1000, None] if not self.onbox: my_obj.server = MockONTAPConnection('snapmirror', status='idle', parm='snapmirrored') - res = my_obj.check_if_elementsw_volume_exists('10.10.10.10:/lun/1000', mock_helper) - assert res is None + my_obj.check_if_elementsw_volume_exists('10.10.10.10:/lun/1000', mock_helper) with pytest.raises(AnsibleFailJson) as exc: my_obj.check_if_elementsw_volume_exists('10.10.10.10:/lun/1000', mock_helper) assert 'Error: Source volume does not exist in the ElementSW cluster' in exc.value.args[0]['msg'] @@ -494,8 +495,7 @@ def test_elementsw_svip_exists(self): mock_helper.get_cluster_info.return_value.cluster_info.svip = '10.10.10.10' if not self.onbox: my_obj.server = MockONTAPConnection('snapmirror', status='idle', parm='snapmirrored') - res = my_obj.validate_elementsw_svip('10.10.10.10:/lun/1000', mock_helper) - assert res is None + my_obj.validate_elementsw_svip('10.10.10.10:/lun/1000', mock_helper) def test_elementsw_svip_exists_negative(self): ''' svip_exists negative testing''' diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_software_update.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_software_update.py index 241b6471..2c7c858b 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_software_update.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_software_update.py @@ -162,6 +162,8 @@ def test_ensure_apply_for_update_called(self): if not self.use_vsim: my_obj.server = MockONTAPConnection('software_update', 'async_pkg_get_phase_complete', 'abc') with pytest.raises(AnsibleExitJson) as exc: - my_obj.apply() + # replace time.sleep with a noop + with patch('time.sleep', lambda a: None): + my_obj.apply() print('Info: test_software_update_apply: %s' % repr(exc.value)) assert exc.value.args[0]['changed'] diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_user.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_user.py index 4e450ee8..15aed4aa 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_user.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_user.py @@ -148,11 +148,16 @@ def set_default_args(self, rest=False): vserver = 'vserver' application = 'console' authentication_method = 'password' + if rest: + use_rest = 'auto' + else: + use_rest = 'never' return dict({ 'hostname': hostname, 'username': username, 'password': password, + 'use_rest': use_rest, 'name': user_name, 'vserver': vserver, 'applications': application, @@ -353,7 +358,7 @@ def test_if_all_methods_catch_exception(self): @patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request') def test_rest_error_applications_snmp(self, mock_request): - data = self.set_default_args() + data = self.set_default_args(rest=True) data.update({'applications': 'snmp'}) data.update({'name': 'create'}) data.update({'role_name': 'test123'}) diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_volume_autosize.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_volume_autosize.py index fc03eb6f..3ac1236a 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_volume_autosize.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_volume_autosize.py @@ -151,7 +151,8 @@ def mock_args(self, rest=False): 'shrink_threshold_percent': self.mock_autosize['shrink_threshold_percent'], 'hostname': 'test', 'username': 'test_user', - 'password': 'test_pass!' + 'password': 'test_pass!', + 'use_rest': 'never' } def get_autosize_mock_object(self, type='zapi', kind=None): @@ -192,6 +193,7 @@ def test_successful_reset(self): data['password'] = 'test_pass!' data['volume'] = 'test_vol' data['vserver'] = 'test_vserver' + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_autosize_mock_object('zapi', 'autosize').apply() diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vscan.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vscan.py index 90f41c4a..9e2ccb4a 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vscan.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vscan.py @@ -131,6 +131,7 @@ def test_module_fail_when_required_args_missing(self): def test_successfully_enable(self): data = self.mock_args() data['enable'] = True + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_vscan_mock_object('zapi', 'enable', 'false').apply() @@ -139,6 +140,7 @@ def test_successfully_enable(self): def test_idempotently_enable(self): data = self.mock_args() data['enable'] = True + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_vscan_mock_object('zapi', 'enable', 'true').apply() @@ -147,6 +149,7 @@ def test_idempotently_enable(self): def test_successfully_disable(self): data = self.mock_args() data['enable'] = False + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_vscan_mock_object('zapi', 'enable', 'true').apply() @@ -155,6 +158,7 @@ def test_successfully_disable(self): def test_idempotently_disable(self): data = self.mock_args() data['enable'] = False + data['use_rest'] = 'never' set_module_args(data) with pytest.raises(AnsibleExitJson) as exc: self.get_vscan_mock_object('zapi', 'enable', 'false').apply()