CiscoDevNet / python-viptela

Cisco Viptela vManage Python CLI/SDK
GNU General Public License v3.0
96 stars 64 forks source link

JSONDecodeError on `vmanage_device_attachment` at viptela.logout() #156

Open briantsaunders opened 2 years ago

briantsaunders commented 2 years ago

Currently running vManage version 20.4.2.1. Attempting to run module vmanage_device_attachment and the template attachment succeeds but when it hits this point in the code it appears to error out -> https://github.com/CiscoDevNet/python-viptela/blob/37bdd399326630772a3fd181dae7b9d5e2e23976/ansible/modules/viptela/vmanage_device_attachment.py#L230.

This is how I'm calling the module:

    - name: attach customer {{ customer }} device template
      vmanage_device_attachment:
        host: "{{ vmanage_host }}"
        user: "{{ vmanage_user }}"
        password: "{{ vmanage_password }}"
        validate_certs: false
        device: "{{ inventory_hostname }}"
        template: "{{ device_template }}"
        variables: "{{ lookup('template', device_template + '_variables.yaml.j2') | from_yaml }}"
        state: present
        wait: true

This is the error message I receive (truncated to get to the point):

File \"/home/saunderb/.ansible/tmp/ansible-tmp-1642707552.1295621-220635-193965079848664/AnsiballZ_vmanage_device_attachment.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible.modules.vmanage_device_attachment', init_globals=dict(_module_fqn='ansible.modules.vmanage_device_attachment', _modlib_path=modlib_path),\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_vmanage_device_attachment_payload_5frjq5fl/ansible_vmanage_device_attachment_payload.zip/ansible/modules/vmanage_device_attachment.py\", line 233, in \n File \"/tmp/ansible_vmanage_device_attachment_payload_5frjq5fl/ansible_vmanage_device_attachment_payload.zip/ansible/modules/vmanage_device_attachment.py\", line 230, in main\n File \"/tmp/ansible_vmanage_device_attachment_payload_5frjq5fl/ansible_vmanage_device_attachment_payload.zip/ansible/modules/vmanage_device_attachment.py\", line 226, in run_module\n File \"/tmp/ansible_vmanage_device_attachment_payload_5frjq5fl/ansible_vmanage_device_attachment_payload.zip/ansible/module_utils/viptela.py\", line 134, in logout\n File \"/tmp/ansible_vmanage_device_attachment_payload_5frjq5fl/ansible_vmanage_device_attachment_payload.zip/ansible/module_utils/viptela.py\", line 177, in request\n File \"/usr/lib/python3/dist-packages/requests/models.py\", line 897, in json\n return complexjson.loads(self.text, **kwargs)\n File \"/usr/lib/python3/dist-packages/simplejson/init.py\", line 518, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib/python3/dist-packages/simplejson/decoder.py\", line 370, in decode\n obj, end = self.raw_decode(s)\n File \"/usr/lib/python3/dist-packages/simplejson/decoder.py\", line 400, in raw_decode\n return self.scan_once(s, idx=_w(s, idx).end())\nsimplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

If I comment out viptela.logout() the module runs without issue.

DelmiroCampelo commented 2 years ago

Hi Briant,

I'm running into the same issue as you. When commenting out viptela.out()the module runs fine.

jasonking3 commented 2 years ago

@briantsaunders - I am curious if this is an Ansible version issue. We mainly use the sdwan-devops repo to test the Ansible modules in this repo. It uses ansible==2.10.7. What version are you using?

DelmiroCampelo commented 2 years ago

Hi @jasonking3 I ran into the same issue using both ansible 2.9.0 and 2.9.6. I would try using 2.10.7 and see if that resolves the issue. Thank you.