aruba / aoscx-ansible-collection

Ansible collections for AOS-CX switches 
47 stars 23 forks source link

Error on aoscx_interface module #83

Closed aaronfs07 closed 1 month ago

aaronfs07 commented 11 months ago

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.

tchiapuziowong commented 11 months ago

@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?

aaronfs07 commented 11 months ago

It is a 6200F on 10.10.1060

And yes it is the first AOSCX_interface call.

tchiapuziowong commented 11 months ago

@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?

aaronfs07 commented 11 months ago

Yes it does.

aaronfs07 commented 11 months ago

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}

tchiapuziowong commented 11 months ago

@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

aaronfs07 commented 10 months ago

Sure,

arubanetworks.aos_switch 1.5.0
arubanetworks.aoscx 4.2.0

tchiapuziowong commented 10 months ago

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

aaronfs07 commented 10 months ago

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 commented 10 months ago

Any update on this issue?

tchiapuziowong commented 9 months ago

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