DNAC HTTPAPI Plugin Python 3
jandiorio opened this issue · 0 comments
jandiorio commented
Context
Current import statement in dnac.py httpapi plugin only supports python2 environments. Testing in python3 fails.
Process
- Install Ansible in Python 3 environment
- Attempt to use dnac.py connection plugin
Expected Result
Expectation would be a successful connection to the Cisco DNA Center Controller
Current Result
root@b6498371d394:/development/ansible-dnac/playbooks# ansible-playbook -i hosts.yml test_initial_connection.yml
PLAY [Testing ansible-dnac Collection] *******************************************************************************************
TASK [get devices] ***************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'urllib2'
fatal: [dnac-prod.campus.wwtatc.local]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
PLAY RECAP ***********************************************************************************************************************
dnac-prod.campus.wwtatc.local : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Possible Fix
In plugins/httpapi/dnac.py
replace:
from urllib2 import HTTPError
with:
try:
from urllib2 import HTTPError
except ImportError:
from urllib.request import HTTPError