diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/units/module_utils/facts/network/test_iscsi_get_initiator.py | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test/units/module_utils/facts/network/test_iscsi_get_initiator.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/units/module_utils/facts/network/test_iscsi_get_initiator.py b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py new file mode 100644 index 0000000..2048ba2 --- /dev/null +++ b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.module_utils.facts.network import iscsi +from units.compat.mock import Mock + + +# AIX # lsattr -E -l iscsi0 +LSATTR_OUTPUT = """ +disc_filename /etc/iscsi/targets Configuration file False +disc_policy file Discovery Policy True +initiator_name iqn.localhost.hostid.7f000002 iSCSI Initiator Name True +isns_srvnames auto iSNS Servers IP Addresses True +isns_srvports iSNS Servers Port Numbers True +max_targets 16 Maximum Targets Allowed True +num_cmd_elems 200 Maximum number of commands to queue to driver True +""" + +# HP-UX # iscsiutil -l +ISCSIUTIL_OUTPUT = """ +Initiator Name : iqn.2001-04.com.hp.stor:svcio +Initiator Alias : +Authentication Method : None +CHAP Method : CHAP_UNI +Initiator CHAP Name : +CHAP Secret : +NAS Hostname : +NAS Secret : +Radius Server Hostname : +Header Digest : None,CRC32C (default) +Data Digest : None,CRC32C (default) +SLP Scope list for iSLPD : +""" + + +def test_get_iscsi_info(mocker): + module = Mock() + inst = iscsi.IscsiInitiatorNetworkCollector() + + mocker.patch('sys.platform', 'aix6') + mocker.patch('ansible.module_utils.facts.network.iscsi.get_bin_path', return_value='/usr/sbin/lsattr') + mocker.patch.object(module, 'run_command', return_value=(0, LSATTR_OUTPUT, '')) + aix_iscsi_expected = {"iscsi_iqn": "iqn.localhost.hostid.7f000002"} + assert aix_iscsi_expected == inst.collect(module=module) + + mocker.patch('sys.platform', 'hp-ux') + mocker.patch('ansible.module_utils.facts.network.iscsi.get_bin_path', return_value='/opt/iscsi/bin/iscsiutil') + mocker.patch.object(module, 'run_command', return_value=(0, ISCSIUTIL_OUTPUT, '')) + hpux_iscsi_expected = {"iscsi_iqn": " iqn.2001-04.com.hp.stor:svcio"} + assert hpux_iscsi_expected == inst.collect(module=module) |