pynetbox
pynetbox copied to clipboard
NetBox API /dcim/interfaces/{id}/trace/ not working in pynetbox
NetBox v3.3.0 pynetbox v6.6.2
The screenshot below shows the mapping of cables from a physical interface, through some patch panels, to a circuit:

This can be queried via the NetBox API directly (using cURL) without issue. I want to get the ID of the circuit at the end of this cable trace (which has ID 2):

Via pynetbox this doesn't work though:
$python3
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pynetbox
>>> nb = pynetbox.api('http://localhost:8080',token='0123456789abcdef0123456789abcdef01234567')
>>> nb.dcim.interfaces.get(name="Ethernet2",device="router1-ber1-de").trace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bensley/Dokumente/gitlab/network-automation/.venv/lib/python3.10/site-packages/pynetbox/models/dcim.py", line 53, in trace
urlsplit(hop_item_data["url"])
TypeError: list indices must be integers or slices, not str
>>> x = nb.dcim.interfaces.get(name="Ethernet2",device="router1")
>>> x.trace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bensley/xyz/.venv/lib/python3.10/site-packages/pynetbox/models/dcim.py", line 53, in trace
urlsplit(hop_item_data["url"])
TypeError: list indices must be integers or slices, not str
>>> x.name
'Ethernet2'
>>> x.id
2
I am seeing this as well.
Same here
>>> list(api.dcim.interfaces.filter(id=54495))[0].trace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fschneider/repos/thesis/playground/.venv/lib/python3.11/site-packages/pynetbox/models/dcim.py", line 53, in trace
urlsplit(hop_item_data["url"])
~~~~~~~~~~~~~^^^^^^^
TypeError: list indices must be integers or slices, not str