cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3368
Views
5
Helpful
11
Replies

acitoolkit login issue script

Pradip
Level 1
Level 1

script a below:

from acitoolkit.acitoolkit import Session
from acitoolkit.aciphysobject import Node

url ='https://10.10.1.0'
user ='admin'
PASSWORD ='admin'
session=Session(url, user, PASSWORD)
print(session)
if session.login().ok:
print("sucess")
else:
print("failed")

**************************

ouput:

C:\python38\Scripts>apics.py
<acitoolkit.acisession.Session object at 0x000001766BAD79D0>
ERROR:root:Could not relogin to APIC due to ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
failed

C:\python38\Scripts>

 

 

please help to fix the login issue

3 Accepted Solutions

Accepted Solutions

Hi @Pradip ,

I'm running out of ideas.  I had a quick look at the source code (https://github.com/datacenter/acitoolkit/blob/master/acitoolkit/acisession.py) and can see that the message is thrown by an exception rather than a failure - in other words something didn't work the way it was expected to work. My suspicion is that it is caused by a missing file/directory in your Windows environment.  I know that when I tried to install Linux and acitoolkit on Windows10 I had so much trouble with permissions and the like I simply gave up. 

If I was in your situation I'd do one of two things:

  1. Create a Linux VM and install python and acitoolkit on it - then use the Linux VM as my development environment
  2. Install Docker and try running python and acitoolkit from a container.

I must say though, I've NEVER tried to use Docker on a Windows machine, and not sure how that would go.

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

View solution in original post

Hi Pardip,

 

I also tried your script and had no issue.

Are you using a virtual environment?  Its a good practice and it might be good to try a clean start on your system.

 

You can also try your script on a different APIC (like the DevNet Sandbox).  It may very well be your environment so if you get the same thing on the Sandbox APIC that is a good data point.  If it is environment related, definitely try the virtual environment if you can or try spinning up a linux environment.  I like to use Docker.  Here are some tips on doing that.

 

Using a Docker container I did the following:

Form my command line I started a docker container:

claudia@Claudias-iMac ~ % docker run -it cldeluna/disco-immigrant

 

  1. I created a virtual environment
  2. I activated the virtual environment
  3. I installed acitoolkit with pip
  4. I created your python script and executed it within the virtual environment

 

root@74db0f181da9:/ansible_local# python3 -m venv acitoolkitvenv
root@74db0f181da9:/ansible_local# source acitoolkitvenv/bin/activate
(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip install acitoolkit
(acitoolkitvenv) root@74db0f181da9:/ansible_local# vi apics.py
(acitoolkitvenv) root@74db0f181da9:/ansible_local# cat apics.py
from acitoolkit.acitoolkit import Session
from acitoolkit.aciphysobject import Node


url ='https://sandboxapicdc.cisco.com'
user ='admin'
PASSWORD ='ciscopsdt'
session=Session(url, user, PASSWORD)
print(session)
if session.login().ok:
  print("success")
else:
  print("failed")

(acitoolkitvenv) root@74db0f181da9:/ansible_local#
(acitoolkitvenv) root@74db0f181da9:/ansible_local# python apics.py
<acitoolkit.acisession.Session object at 0x7fd854f02a58>
success

Here is what got installed, in case you want to use the pip freeze output for a requests.txt file but all I did is run pip install acitoolkit.

 

(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip freeze
acitoolkit==0.4
attrs==20.2.0
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
deepdiff==5.0.2
dominate==2.5.2
Flask==1.1.2
Flask-Admin==1.5.6
Flask-Bootstrap==3.3.7.1
Flask-Cors==3.0.9
Flask-HTTPAuth==4.1.0
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
gitdb==4.0.5
GitPython==3.1.8
graphviz==0.14.1
idna==2.10
importlib-metadata==2.0.0
ipaddress==1.0.23
itsdangerous==1.1.0
Jinja2==2.11.2
jsonschema==3.2.0
MarkupSafe==1.1.1
ordered-set==4.0.2
pkg-resources==0.0.0
py-radix==0.10.0
PyMySQL==0.10.1
pyrsistent==0.17.3
requests==2.24.0
six==1.15.0
smmap==3.0.4
SQLAlchemy==1.3.19
tabulate==0.8.7
urllib3==1.25.10
visitor==0.1.3
websocket-client==0.57.0
Werkzeug==1.0.1
WTForms==2.3.3
zipp==3.2.0
(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip list
Package            Version
------------------ ---------
acitoolkit         0.4
attrs              20.2.0
certifi            2020.6.20
chardet            3.0.4
click              7.1.2
deepdiff           5.0.2
dominate           2.5.2
Flask              1.1.2
Flask-Admin        1.5.6
Flask-Bootstrap    3.3.7.1
Flask-Cors         3.0.9
Flask-HTTPAuth     4.1.0
Flask-SQLAlchemy   2.4.4
Flask-WTF          0.14.3
gitdb              4.0.5
GitPython          3.1.8
graphviz           0.14.1
idna               2.10
importlib-metadata 2.0.0
ipaddress          1.0.23
itsdangerous       1.1.0
Jinja2             2.11.2
jsonschema         3.2.0
MarkupSafe         1.1.1
ordered-set        4.0.2
pip                18.1
pkg-resources      0.0.0
py-radix           0.10.0
PyMySQL            0.10.1
pyrsistent         0.17.3
requests           2.24.0
setuptools         40.8.0
six                1.15.0
smmap              3.0.4
SQLAlchemy         1.3.19
tabulate           0.8.7
urllib3            1.25.10
visitor            0.1.3
websocket-client   0.57.0
Werkzeug           1.0.1
WTForms            2.3.3
zipp               3.2.0
(acitoolkitvenv) root@74db0f181da9:/ansible_local#

 

View solution in original post

Hi.

 

Im going to agree with what others on here have posted that it’s probably your local machine vs APIC. What I would do is uninstall python on your workstation. Go to the directory python was installed at and delete any files within it.

 

Then install the latest python 3. Then install the acitoolkit again via ‘pip install’ or download the whl. If you continue to have problems, then maybe just try and use a normal POST via requests to see if it works. 

Somebody else above recommended trying a different ACI fabric. I agree. Check out developer.cisco.com and find the ACI sandbox and try and connect to that to see if you have the same error. Best of luck

 

View solution in original post

11 Replies 11

Pradip
Level 1
Level 1

Hi,

 

please help to fix this error...

 

ERROR:root:Could not relogin to APIC due to ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

Hi @Pradip ,

I was not able to re-produce your error.

But for curiosity's sake, can you tell me if you get the same error on:

  1. The other APICs
  2. The leaves
  3. The Spines

I found your script worked just fine for me on all three instances

I'm using Python 3.8.2 on Mac OS X Version: 10.15.7 - too hard to get Python working on Windows10

 

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Pradip
Level 1
Level 1

Hi Chris, i have checked other apics as well same error found, unfortunately, spines/leaves, we cant access due to policy .

 

OK - One more question. Are you using an OOB IP address or have you set up inband management in the mgmt tenant?

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Hi Chris, It is OOB ip address. 

pls help...still issue not resolved

Hi Pardip,

 

I also tried your script and had no issue.

Are you using a virtual environment?  Its a good practice and it might be good to try a clean start on your system.

 

You can also try your script on a different APIC (like the DevNet Sandbox).  It may very well be your environment so if you get the same thing on the Sandbox APIC that is a good data point.  If it is environment related, definitely try the virtual environment if you can or try spinning up a linux environment.  I like to use Docker.  Here are some tips on doing that.

 

Using a Docker container I did the following:

Form my command line I started a docker container:

claudia@Claudias-iMac ~ % docker run -it cldeluna/disco-immigrant

 

  1. I created a virtual environment
  2. I activated the virtual environment
  3. I installed acitoolkit with pip
  4. I created your python script and executed it within the virtual environment

 

root@74db0f181da9:/ansible_local# python3 -m venv acitoolkitvenv
root@74db0f181da9:/ansible_local# source acitoolkitvenv/bin/activate
(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip install acitoolkit
(acitoolkitvenv) root@74db0f181da9:/ansible_local# vi apics.py
(acitoolkitvenv) root@74db0f181da9:/ansible_local# cat apics.py
from acitoolkit.acitoolkit import Session
from acitoolkit.aciphysobject import Node


url ='https://sandboxapicdc.cisco.com'
user ='admin'
PASSWORD ='ciscopsdt'
session=Session(url, user, PASSWORD)
print(session)
if session.login().ok:
  print("success")
else:
  print("failed")

(acitoolkitvenv) root@74db0f181da9:/ansible_local#
(acitoolkitvenv) root@74db0f181da9:/ansible_local# python apics.py
<acitoolkit.acisession.Session object at 0x7fd854f02a58>
success

Here is what got installed, in case you want to use the pip freeze output for a requests.txt file but all I did is run pip install acitoolkit.

 

(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip freeze
acitoolkit==0.4
attrs==20.2.0
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
deepdiff==5.0.2
dominate==2.5.2
Flask==1.1.2
Flask-Admin==1.5.6
Flask-Bootstrap==3.3.7.1
Flask-Cors==3.0.9
Flask-HTTPAuth==4.1.0
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
gitdb==4.0.5
GitPython==3.1.8
graphviz==0.14.1
idna==2.10
importlib-metadata==2.0.0
ipaddress==1.0.23
itsdangerous==1.1.0
Jinja2==2.11.2
jsonschema==3.2.0
MarkupSafe==1.1.1
ordered-set==4.0.2
pkg-resources==0.0.0
py-radix==0.10.0
PyMySQL==0.10.1
pyrsistent==0.17.3
requests==2.24.0
six==1.15.0
smmap==3.0.4
SQLAlchemy==1.3.19
tabulate==0.8.7
urllib3==1.25.10
visitor==0.1.3
websocket-client==0.57.0
Werkzeug==1.0.1
WTForms==2.3.3
zipp==3.2.0
(acitoolkitvenv) root@74db0f181da9:/ansible_local# pip list
Package            Version
------------------ ---------
acitoolkit         0.4
attrs              20.2.0
certifi            2020.6.20
chardet            3.0.4
click              7.1.2
deepdiff           5.0.2
dominate           2.5.2
Flask              1.1.2
Flask-Admin        1.5.6
Flask-Bootstrap    3.3.7.1
Flask-Cors         3.0.9
Flask-HTTPAuth     4.1.0
Flask-SQLAlchemy   2.4.4
Flask-WTF          0.14.3
gitdb              4.0.5
GitPython          3.1.8
graphviz           0.14.1
idna               2.10
importlib-metadata 2.0.0
ipaddress          1.0.23
itsdangerous       1.1.0
Jinja2             2.11.2
jsonschema         3.2.0
MarkupSafe         1.1.1
ordered-set        4.0.2
pip                18.1
pkg-resources      0.0.0
py-radix           0.10.0
PyMySQL            0.10.1
pyrsistent         0.17.3
requests           2.24.0
setuptools         40.8.0
six                1.15.0
smmap              3.0.4
SQLAlchemy         1.3.19
tabulate           0.8.7
urllib3            1.25.10
visitor            0.1.3
websocket-client   0.57.0
Werkzeug           1.0.1
WTForms            2.3.3
zipp               3.2.0
(acitoolkitvenv) root@74db0f181da9:/ansible_local#

 

Pradip
Level 1
Level 1

chris, also want to let you know that it was working before , but some reason i did uninstall acitoolkit , install again..then issue started,

 

i tried everything, even i uninstall python, all the pakages... really tired....last 5 days, i am working on that..but no solution...really appreciated , what could be the soultion to fix this....

Hi @Pradip ,

I'm running out of ideas.  I had a quick look at the source code (https://github.com/datacenter/acitoolkit/blob/master/acitoolkit/acisession.py) and can see that the message is thrown by an exception rather than a failure - in other words something didn't work the way it was expected to work. My suspicion is that it is caused by a missing file/directory in your Windows environment.  I know that when I tried to install Linux and acitoolkit on Windows10 I had so much trouble with permissions and the like I simply gave up. 

If I was in your situation I'd do one of two things:

  1. Create a Linux VM and install python and acitoolkit on it - then use the Linux VM as my development environment
  2. Install Docker and try running python and acitoolkit from a container.

I must say though, I've NEVER tried to use Docker on a Windows machine, and not sure how that would go.

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Hi.

 

Im going to agree with what others on here have posted that it’s probably your local machine vs APIC. What I would do is uninstall python on your workstation. Go to the directory python was installed at and delete any files within it.

 

Then install the latest python 3. Then install the acitoolkit again via ‘pip install’ or download the whl. If you continue to have problems, then maybe just try and use a normal POST via requests to see if it works. 

Somebody else above recommended trying a different ACI fabric. I agree. Check out developer.cisco.com and find the ACI sandbox and try and connect to that to see if you have the same error. Best of luck

 

Pradip
Level 1
Level 1

 

 

thanks chris,Claudias &  Brandon....over your helps, issue was related to local machine, nothing related with apic, i did clean everything includes pycharm, ven, install python, acitoolkit......

 

thanks..!! helps...was trying from last 1 week... thanks a millions...!! 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Save 25% on Day-2 Operations Add-On License