pynetbox icon indicating copy to clipboard operation
pynetbox copied to clipboard

NetBox API /dcim/interfaces/{id}/trace/ not working in pynetbox

Open jwbensley opened this issue 3 years ago • 3 comments

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:

Bildschirmfoto vom 2022-08-30 10-43-17

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):

Bildschirmfoto vom 2022-08-30 10-45-38

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

jwbensley avatar Aug 30 '22 08:08 jwbensley

I am seeing this as well.

robertlynch3 avatar Aug 30 '22 20:08 robertlynch3

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

felixschndr avatar Oct 02 '23 15:10 felixschndr