ansible-collections / netapp

Development area for Netapp collections
49 stars 36 forks source link

na_ontap_command throws : "AttributeError: 'NoneType' object has no attribute 'get_child_by_name'" #74

Closed SWADESNA closed 3 years ago

SWADESNA commented 3 years ago
SUMMARY

When na_ontap_command to list the volumes, it fails with the below error

{
    "exception": "Traceback (most recent call last):\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.storage.netapp.na_ontap_command', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 228, in <module>\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 224, in main\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 149, in apply\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 117, in run_command\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 111, in asup_log_for_cserver\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/module_utils/netapp.py\", line 525, in get_cserver\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/module_utils/netapp.py\", line 519, in get_cserver_zapi\r\nAttributeError: 'NoneType' object has no attribute 'get_child_by_name'\r\n",
    "_ansible_no_log": false,
    "module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 21\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to 10.173.234.25 closed.\r\n",
    "changed": false,
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/cloud-user/.ansible/tmp/ansible-tmp-1607709071.77-46722177438710/AnsiballZ_na_ontap_command.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.storage.netapp.na_ontap_command', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 228, in <module>\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 224, in main\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 149, in apply\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 117, in run_command\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/modules/storage/netapp/na_ontap_command.py\", line 111, in asup_log_for_cserver\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/module_utils/netapp.py\", line 525, in get_cserver\r\n  File \"/tmp/ansible_na_ontap_command_payload_8a8r0D/ansible_na_ontap_command_payload.zip/ansible/module_utils/netapp.py\", line 519, in get_cserver_zapi\r\nAttributeError: 'NoneType' object has no attribute 'get_child_by_name'\r\n",
    "rc": 1,
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }
}
ISSUE TYPE
COMPONENT NAME

na_ontap_command

ANSIBLE VERSION
2.9.6
CONFIGURATION
ansible-playbook 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Sep 26 2019, 13:23:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
OS / ENVIRONMENT

RHEL 7

STEPS TO REPRODUCE
---
- name: Listing the current TVS volumes
  hosts: all
  gather_facts: false
  tasks:
    - name: run ontap cli command
      na_ontap_command:
        hostname: "{{ v_tvs_virtual_storage }}"
        username: "{{ v_user_name }}"
        password: "{{ v_user_password }}"
        command: ['vol show'']
        privilege: 'admin'
        https: true
        validate_certs: false
        use_rest: Always
EXPECTED RESULTS

List the volume

ACTUAL RESULTS
AttributeError: 'NoneType' object has no attribute 'get_child_by_name'\r\n",
    "rc": 1,
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }
lonico commented 3 years ago

The is a very old version of our modules. Since September 2019, we switched to collections. They work with Ansible 2.9, though I would recommend 2.10. Our latest collection was released early December as 10.12.0. More on collections at: https://netapp.io/2019/09/17/coming-together-nicely/ (ignore the part about mazer, it's not applicable with 2.9 or 2.10).

lonico commented 3 years ago

This was fixed in the 19.10.0 collection (October 2019).