aoscx-ansible-collection icon indicating copy to clipboard operation
aoscx-ansible-collection copied to clipboard

Error on aoscx_interface module

Open aaronfs07 opened this issue 1 year ago • 11 comments

Getting the following error from the aoscx_interface module

The full traceback is:
Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py", line 132, in interface
    interface_obj.apply()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py", line 40, in ensure_connected
    return fnct(self, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py", line 487, in apply
    modified = self.create()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py", line 40, in ensure_connected
    return fnct(self, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py", line 464, in create
    raise GenericOperationError(response.text, response.status_code)
pyaoscx.exceptions.generic_op_error.GenericOperationError: 'GENERIC OPERATION ERROR: cannot add a system interface\n: Code: 400'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py", line 102, in <module>
    _ansiballz_main()
  File "/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_interface', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_aoscx_interface_payload_hb0f_nn3/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py", line 649, in <module>
  File "/tmp/ansible_aoscx_interface_payload_hb0f_nn3/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py", line 510, in main
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py", line 138, in interface
    interface_obj.get()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py", line 40, in ensure_connected
    return fnct(self, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py", line 223, in get
    self.vlan_tag.get()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py", line 40, in ensure_connected
    return fnct(self, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/vlan.py", line 132, in get
    Mac.get_all(self.session, self)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/mac.py", line 214, in get_all
    mac_obj.port = Interface.from_response(session, mac["port"])
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py", line 375, in from_response
    interfaces_id_arr = session.api.get_keys(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/api.py", line 97, in get_keys
    for k, v in response_data.items():
AttributeError: 'NoneType' object has no attribute 'items'
fatal: [WRMS-MDF-02B]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py\", line 132, in interface\n    interface_obj.apply()\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n    return fnct(self, *args, **kwargs)\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 487, in apply\n    modified = self.create()\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n    return fnct(self, *args, **kwargs)\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 464, in create\n    raise GenericOperationError(response.text, response.status_code)\npyaoscx.exceptions.generic_op_error.GenericOperationError: 'GENERIC OPERATION ERROR: cannot add a system interface\\n: Code: 400'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/ubuntu/.ansible/tmp/ansible-local-23154l8fzlylq/ansible-tmp-1695393989.3166547-23245-24402955316394/AnsiballZ_aoscx_interface.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_interface', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_aoscx_interface_payload_hb0f_nn3/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py\", line 649, in <module>\n  File \"/tmp/ansible_aoscx_interface_payload_hb0f_nn3/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py\", line 510, in main\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py\", line 138, in interface\n    interface_obj.get()\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n    return fnct(self, *args, **kwargs)\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 223, in get\n    self.vlan_tag.get()\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n    return fnct(self, *args, **kwargs)\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/vlan.py\", line 132, in get\n    Mac.get_all(self.session, self)\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/mac.py\", line 214, in get_all\n    mac_obj.port = Interface.from_response(session, mac[\"port\"])\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 375, in from_response\n    interfaces_id_arr = session.api.get_keys(\n  File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/api.py\", line 97, in get_keys\n    for k, v in response_data.items():\nAttributeError: 'NoneType' object has no attribute 'items'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

I have checked all the usual suspects - switch settings (other playbooks work), updating packages

This same command works on other switches. I only have a few that throw this error.

Current Ansible Configuration part that is throwing this error

- name: MDF-02B Exceptions
  hosts: MDF-02B
  collections:
    - arubanetworks.aoscx

  tasks:
    - name: MDF-02B AP ETH1 Exceptions Port - 2/1/25
      aoscx_interface:
        name: 2/1/25
        enabled: false
        description: Access Point ETH1 -- Ansible
    - name: MDF-02B AP ETH1 Exceptions POE - 2/1/25
      aoscx_poe:
        interface: 2/1/25
        enable: false

    - name: MDF-02B AP ETH1 Exceptions Port - 2/1/6
      aoscx_interface:
        name: 2/1/6
        enabled: false
        description: Access Point ETH1 -- Ansible
    - name: MDF-02B AP ETH1 Exceptions POE - 2/1/6
      aoscx_poe:
        interface: 2/1/6
        enable: false

Expected Behavior

I expect that just like the other switches in this playbook that it will execute successfully. There is no config difference I can tell between the switches. I have even reloaded one of them to see.

aaronfs07 avatar Sep 22 '23 14:09 aaronfs07

@aaronfs07 can you share the firmware and model of the switch that's failing - also which task is is failing specifically is it the first aoscx_interface call?

tchiapuziowong avatar Sep 25 '23 18:09 tchiapuziowong

It is a 6200F on 10.10.1060

And yes it is the first AOSCX_interface call.

aaronfs07 avatar Sep 27 '23 13:09 aaronfs07

@aaronfs07 is the switch in VSF a stack at the point of execution of this playbook? The interfaces 2/1/15 exists on the switch at that time?

tchiapuziowong avatar Sep 27 '23 16:09 tchiapuziowong

Yes it does.

aaronfs07 avatar Oct 05 '23 19:10 aaronfs07

It will even fail on a switch with the same error on 1/1/19

See here

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'items' fatal: [DPPS-MDF-02]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py\", line 132, in interface\n interface_obj.apply()\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n return fnct(self, *args, **kwargs)\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 487, in apply\n modified = self.create()\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n return fnct(self, *args, **kwargs)\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 464, in create\n raise GenericOperationError(response.text, response.status_code)\npyaoscx.exceptions.generic_op_error.GenericOperationError: 'GENERIC OPERATION ERROR: cannot add a system interface\\n: Code: 400'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/home/ubuntu/.ansible/tmp/ansible-local-58622xqjkzzsj/ansible-tmp-1696534333.0329187-59633-239427269681588/AnsiballZ_aoscx_interface.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/ubuntu/.ansible/tmp/ansible-local-58622xqjkzzsj/ansible-tmp-1696534333.0329187-59633-239427269681588/AnsiballZ_aoscx_interface.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/ubuntu/.ansible/tmp/ansible-local-58622xqjkzzsj/ansible-tmp-1696534333.0329187-59633-239427269681588/AnsiballZ_aoscx_interface.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_interface', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_aoscx_interface_payload_5csl_yn1/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py\", line 649, in <module>\n File \"/tmp/ansible_aoscx_interface_payload_5csl_yn1/ansible_aoscx_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_interface.py\", line 510, in main\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_factory.py\", line 138, in interface\n interface_obj.get()\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n return fnct(self, *args, **kwargs)\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 223, in get\n self.vlan_tag.get()\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/pyaoscx_module.py\", line 40, in ensure_connected\n return fnct(self, *args, **kwargs)\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/vlan.py\", line 132, in get\n Mac.get_all(self.session, self)\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/mac.py\", line 214, in get_all\n mac_obj.port = Interface.from_response(session, mac[\"port\"])\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/interface.py\", line 375, in from_response\n interfaces_id_arr = session.api.get_keys(\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/api.py\", line 97, in get_keys\n for k, v in response_data.items():\nAttributeError: 'NoneType' object has no attribute 'items'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

aaronfs07 avatar Oct 05 '23 19:10 aaronfs07

@aaronfs07 Can you share what versions of the aoscx collection and the pyaoscx package you're using? I'm attempting to recreate the error but having difficulty

tchiapuziowong avatar Oct 09 '23 19:10 tchiapuziowong

Sure,

arubanetworks.aos_switch 1.5.0
arubanetworks.aoscx 4.2.0

aaronfs07 avatar Oct 16 '23 13:10 aaronfs07

Can you install the latest version of the arubanetworks.aoscx collection and verify if the issue is still seen? ansible-galaxy collection install arubanetworks.aoscx -f

Also please ensure the latest Python packages are installed as well: pip install --upgrade pyaoscx

tchiapuziowong avatar Oct 16 '23 17:10 tchiapuziowong

After an upgrade I now get a different error on those same switches of interfaces_id_arr = session.api.get_keys(\n File \"/home/ubuntu/.local/lib/python3.10/site-packages/pyaoscx/api.py\", line 97, in get_keys\n for k, v in response_data.items():\nAttributeError: 'NoneType' object has no attribute 'items'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

aaronfs07 avatar Oct 20 '23 12:10 aaronfs07

Any update on this issue?

aaronfs07 avatar Oct 31 '23 14:10 aaronfs07

@aaronfs07 can you update your pyaoscx & Ansible version and see if you're still receiving the same error?

tchiapuziowong avatar Dec 08 '23 21:12 tchiapuziowong