aristanetworks/cvprac

NameError: name 'CvpClient' is not defined

myuchi03 opened this issue · 3 comments

I got the issue when executing the playbook. Here is the detail
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'CvpClient' is not defined fatal: [cv_server]: FAILED! => changed=false module_stderr: |- Traceback (most recent call last): File "/Users/yahya/.ansible/tmp/ansible-local-32358y9pxthc0/ansible-tmp-1669818269.920038-32362-163461312702163/AnsiballZ_cv_device_v3.py", line 107, in <module> _ansiballz_main() File "/Users/yahya/.ansible/tmp/ansible-local-32358y9pxthc0/ansible-tmp-1669818269.920038-32362-163461312702163/AnsiballZ_cv_device_v3.py", line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/Users/yahya/.ansible/tmp/ansible-local-32358y9pxthc0/ansible-tmp-1669818269.920038-32362-163461312702163/AnsiballZ_cv_device_v3.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.arista.cvp.plugins.modules.cv_device_v3', init_globals=dict(_module_fqn='ansible_collections.arista.cvp.plugins.modules.cv_device_v3', _modlib_path=modlib_path), File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 225, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/var/folders/lr/vb01xydj25zb40b36yl87zw00000gn/T/ansible_arista.cvp.cv_device_v3_payload_9peps0w8/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_device_v3.py", line 262, in <module> File "/var/folders/lr/vb01xydj25zb40b36yl87zw00000gn/T/ansible_arista.cvp.cv_device_v3_payload_9peps0w8/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_device_v3.py", line 243, in main File "/var/folders/lr/vb01xydj25zb40b36yl87zw00000gn/T/ansible_arista.cvp.cv_device_v3_payload_9peps0w8/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/module_utils/tools_cv.py", line 52, in cv_connect NameError: name 'CvpClient' is not defined module_stdout: '' msg: |- MODULE FAILURE See stdout/stderr for the exact error rc: 1

Editing cvp_client.py by adding the following line
from json import JSONDecodeError

and removing JSONDecodeError from requests.exceptions fix the problem
from requests.exceptions import ConnectionError, HTTPError, Timeout, \ ReadTimeout, TooManyRedirects

Hi @myuchi03

What version of the requests package are you using? Upgrading the requests package to the latest version v2.28.1 (or v2.27.0 at a minimum) should resolve this issue.

Ah, got it. I am using 2.25.1 version. will upgrade it then. Thanks!

@myuchi03 please close this issue if you feel the issue has been resolved.