Skip to content

DNAC HTTPAPI Plugin Python 3 #2

@jandiorio

Description

@jandiorio

Context

Current import statement in dnac.py httpapi plugin only supports python2 environments. Testing in python3 fails.

Process

  1. Install Ansible in Python 3 environment
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions