datacenter / acitoolkit

A basic toolkit for accessing the Cisco APIC
Other
347 stars 266 forks source link

KeyError: 'ip' when retrieving endpoints #388

Open MrFanciful opened 1 year ago

MrFanciful commented 1 year ago

Hi

I'm getting the above error when running a script studying for the DevNet Associate exam using the ACI Reservable Sandbox.

Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2022.2.3\plugins\python\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm 2022.2.3\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:\Users\user\PycharmProjects\devnet_studies\apic\apic_all_endpoints.py", line 14, in ENDPOINTS = aci.Endpoint.get(SESSION) File "C:\Users\user\PycharmProjects\devnet_studies\venv\lib\site-packages\acitoolkit\acitoolkit.py", line 5409, in get endpoints = Endpoint._get(session, endpoint_name, interfaces, File "C:\Users\user\PycharmProjects\devnet_studies\venv\lib\site-packages\acitoolkit\acitoolkit.py", line 5369, in _get endpoint.ip = str(ep['ip']) KeyError: 'ip'

I'm using Python 3.10.8 and have corrected the "from collections import Sequence" to import it from collections.abc I've read over #374 but don't see a solution there. I've also got the latest version of the acitoolkit v0.4 installed.

My very simple code is below pulled from the office cert guide.

import sys import acitoolkit.acitoolkit as aci

APIC_URL = 'https://10.10.20.14' USERNAME = 'admin' PASSWORD = 'C1sco12345'

SESSION = aci.Session(APIC_URL, USERNAME, PASSWORD) RESP = SESSION.login() if not RESP.ok: print("Couldn't log in to APIC") sys.exit(0)

ENDPOINTS = aci.Endpoint.get(SESSION)

print(f"{'MAC Address':19s}{'| ':1}{'IP Address':14s}{'| ':1}{'Encap':10s}{'| ':1}{'Tenant':8s}{'| ':1}{'App Profile':17s}" f"{'| ':1}{'EPG':10s}")

2022-10-31 10_12_20-devnet_studies – C__Users_dlawson_PycharmProjects_devnet_studies_venv_Lib_site-p

2022-10-31 10_15_50-devnet_studies – C__Users_dlawson_PycharmProjects_devnet_studies_venv_Lib_site-p