cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1436
Views
0
Helpful
6
Replies

ACIToolkit - Listing Endpoints [Key Error]

Nik1709
Level 1
Level 1

Hi everyone, 

 

I am just studying for DevNet Associate exam and I am currently trying out DC Automation with Python. 

So i downloaded ACIToolkit and imported it into my script. I can list tenants, EPGs you name it... 

However when I try to list endpoints i do get an error message saying that there is an key error within some of the ACIToolkit files. 

 

I created this little test-script for showcasing: 

import sys
import acitoolkit.acitoolkit as aci

USER = "username"
PASS = "password"

# Login to APIC
SESSION = aci.Session(APIC_URL, USER, PASS)
RESP = SESSION.login()
if not RESP.ok:
    print("Could not login to APIC")
    sys.exit()
 
ENDPOINTS = aci.Endpoint.get(SESSION)
for ENDPOINT in ENDPOINTS:
    print(ENDPOINT.name)
 
However when I log in with the appropriate sandbox credentials I receive the following error message:
 
PS C:\Path_to_File> python .\acitoolkit_test.py
Traceback (most recent call last):
File "C:\Path_to_File\acitoolkit_test.py", line 27, in <module>
ENDPOINTS = aci.Endpoint.get(SESSION)
File "C:\Path_to_File\acitoolkit\acitoolkit.py", line 5432, in get
endpoints = Endpoint._get(session, endpoint_name, interfaces,
File "C:\Path_to_File\acitoolkit\acitoolkit.py", line 5388, in _get
endpoint.ip = str(ep['ip'])
KeyError: 'ip'
 
Does someone know what I am missing here ? Or is it an error within the acitoolkit.py file ? 
Like I said there are no problems in displaying tenants, epgs etc. but when i want to display the endpoints there is this error.
 
Looking forward to your answers.
 
Thanks in regards! 
Niklas
 
 
EDIT: 
So I did a little troubleshooting and I saw that in line 5388 the file "acitoolkit.py" which comes with the ACI Toolkit wants to get the endpoints IP address (endpoint.ip = str(ep['ip'])) however while testing with Postman I saw that the response does not contain a field for "ip".
 

So when commenting the "endpoint.ip = str(ep["ip"]))" out I started to receive data again. 


Does someone know how I can see the endpoints IP address then ? 

 

Thanks! 

 

6 Replies 6

RiekCyber
Level 1
Level 1

I get no error with TENTANTS = aci.Tenant.get(SESSION). I guess there is no Endpoint in that Pod.

 

 

euahmed
Level 1
Level 1

Dear All ,

I am getting this below error while trying to execute aci show endpoints details using ACITOOLKIT . 

euahmed_0-1704755916511.png

Please can anyone suggest me how to fix this Acitoolkits script for endpoints details . 

It would be highly appreciated if anyone reply on this issue .

 

with regards 

Erfan

Hi @euahmed, can you please post your code/script?

Thanks
Marcel

Hi @Marcel Zehnder ,

Thanks for your response. I have taken the script from below sample script. I am not sure why I am getting this error while executing below script from GitHub. I have installed Cobra SDK and ACITOOLKIT libraries and modules. On the other hand, other script is running properly from below sample GitHub folder.  

https://github.com/datacenter/acitoolkit/blob/master/samples/aci-show-endpoints.py

It would be highly appreciated if you assist me on this below script according to shared screenshot.

Thanking you.

Erfan

 

 

Hi @euahmed 

There is already an open issue for this: https://github.com/datacenter/acitoolkit/issues/388

Looking at the code, the problem is related to endpoint objects with no "ip" attribute: Line 5394 will not work (https://github.com/datacenter/acitoolkit/blob/master/acitoolkit/acitoolkit.py#L5394). We should get the dict values via ep.get(<attribute_name>) and not via ep[<attribute_name>], I will check if there is PR for this, if not I will create one.

Also I'm not sure if acitoolkit is still maintained.


Cheers
Marcel

Marcel Zehnder
Spotlight
Spotlight

Follow up, PR is already created: https://github.com/datacenter/acitoolkit/pull/382