# Buggy code
def get_all(self):
    self.netapp_info["net_interface_info"] = self.get_generic_get_iter(
        "net-interface-get-iter",
        attribute="net-interface-info",
        field="interface-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["net_port_info"] = self.get_generic_get_iter(
        "net-port-get-iter",
        attribute="net-port-info",
        field=("node", "port"),
        query={"max-records": "1024"},
    )
    self.netapp_info["cluster_node_info"] = self.get_generic_get_iter(
        "cluster-node-get-iter",
        attribute="cluster-node-info",
        field="node-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["security_login_account_info"] = self.get_generic_get_iter(
        "security-login-get-iter",
        attribute="security-login-account-info",
        field=("user-name", "application", "authentication-method"),
        query={"max-records": "1024"},
    )
    self.netapp_info["aggregate_info"] = self.get_generic_get_iter(
        "aggr-get-iter",
        attribute="aggr-attributes",
        field="aggregate-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["volume_info"] = self.get_generic_get_iter(
        "volume-get-iter",
        attribute="volume-attributes",
        field=("name", "node", "aggr-name"),
        query={"max-records": "1024"},
    )
    self.netapp_info["lun_info"] = self.get_generic_get_iter(
        "lun-get-iter",
        attribute="lun-info",
        field="path",
        query={"max-records": "1024"},
    )
    self.netapp_info["storage_failover_info"] = self.get_generic_get_iter(
        "cf-get-iter",
        attribute="storage-failover-info",
        field="node",
        query={"max-records": "1024"},
    )

    self.netapp_info["net_ifgrp_info"] = self.get_ifgrp_info()

    self.netapp_info["vserver_motd_info"] = self.get_generic_get_iter(
        "vserver-motd-get-iter",
        attribute="vserver-motd-info",
        field="vserver",
        query={"max-records": "1024"},
    )

    self.netapp_info["vserver_login_banner_info"] = self.get_generic_get_iter(
        "vserver-login-banner-get-iter",
        attribute="vserver-login-banner-info",
        field="vserver",
        query={"max-records": "1024"},
    )

    self.netapp_info["security_key_manager_key_info"] = self.get_generic_get_iter(
        "security-key-manager-key-get-iter",
        attribute="security-key-manager-key-info",
        field=("node", "key-id"),
        query={"max-records": "1024"},
    )
    self.netapp_info["vserver_info"] = self.get_generic_get_iter(
        "vserver-get-iter",
        attribute="vserver-info",
        field="vserver-name",
        query={"max-records": "1024"},
    )

    return self.netapp_info


# Traceback (TypeError)
TASK [Test_gather] **************************************************************************************************************************************************************************************************************************
task path: /git/devel/gather_system.yml:21
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936 `" &amp;&amp; echo ansible-tmp-1536039256.01-6248969617936="` echo /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936 `" ) &amp;&amp; sleep 0'
Using module file /home/centos/ansible2.6/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_gather_facts.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-26695H5a1l7/tmpw3CAow TO /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936/na_ontap_gather_facts.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936/ /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936/na_ontap_gather_facts.py &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/centos/ansible2.6/bin/python /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936/na_ontap_gather_facts.py &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1536039256.01-6248969617936/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py", line 295, in <module>
main()
File "/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py", line 289, in main
g = v.get_all()
File "/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py", line 199, in get_all
query={'max-records': '1024'}
File "/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py", line 156, in get_generic_get_iter
unique_key = ':'.join([_finditem(d, el) for el in field])
TypeError: sequence item 1: expected string or Unicode, NoneType found

fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py\", line 295, in <module>\n    main()\n  File \"/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py\", line 289, in main\n    g = v.get_all()\n  File \"/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py\", line 199, in get_all\n    query={'max-records': '1024'}\n  File \"/tmp/ansible_eHzOnQ/ansible_module_na_ontap_gather_facts.py\", line 156, in get_generic_get_iter\n    unique_key = ':'.join([_finditem(d, el) for el in field])\nTypeError: sequence item 1: expected string or Unicode, NoneType found\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def get_all(self):
    self.netapp_info["net_interface_info"] = self.get_generic_get_iter(
        "net-interface-get-iter",
        attribute="net-interface-info",
        field="interface-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["net_port_info"] = self.get_generic_get_iter(
        "net-port-get-iter",
        attribute="net-port-info",
        field=("node", "port"),
        query={"max-records": "1024"},
    )
    self.netapp_info["cluster_node_info"] = self.get_generic_get_iter(
        "cluster-node-get-iter",
        attribute="cluster-node-info",
        field="node-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["security_login_account_info"] = self.get_generic_get_iter(
        "security-login-get-iter",
        attribute="security-login-account-info",
        field=("user-name", "application", "authentication-method"),
        query={"max-records": "1024"},
    )
    self.netapp_info["aggregate_info"] = self.get_generic_get_iter(
        "aggr-get-iter",
        attribute="aggr-attributes",
        field="aggregate-name",
        query={"max-records": "1024"},
    )
    self.netapp_info["volume_info"] = self.get_generic_get_iter(
        "volume-get-iter",
        attribute="volume-attributes",
        field=("name", "owning-vserver-name", "aggr-name"),
        query={"max-records": "1024"},
    )
    self.netapp_info["lun_info"] = self.get_generic_get_iter(
        "lun-get-iter",
        attribute="lun-info",
        field="path",
        query={"max-records": "1024"},
    )
    self.netapp_info["storage_failover_info"] = self.get_generic_get_iter(
        "cf-get-iter",
        attribute="storage-failover-info",
        field="node",
        query={"max-records": "1024"},
    )

    self.netapp_info["net_ifgrp_info"] = self.get_ifgrp_info()

    self.netapp_info["vserver_motd_info"] = self.get_generic_get_iter(
        "vserver-motd-get-iter",
        attribute="vserver-motd-info",
        field="vserver",
        query={"max-records": "1024"},
    )

    self.netapp_info["vserver_login_banner_info"] = self.get_generic_get_iter(
        "vserver-login-banner-get-iter",
        attribute="vserver-login-banner-info",
        field="vserver",
        query={"max-records": "1024"},
    )

    self.netapp_info["security_key_manager_key_info"] = self.get_generic_get_iter(
        "security-key-manager-key-get-iter",
        attribute="security-key-manager-key-info",
        field=("node", "key-id"),
        query={"max-records": "1024"},
    )

    self.netapp_info["vserver_info"] = self.get_generic_get_iter(
        "vserver-get-iter",
        attribute="vserver-info",
        field="vserver-name",
        query={"max-records": "1024"},
    )

    return self.netapp_info