Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwbensley opened this issue Aug 30, 2022 · 3 comments
Open

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

jwbensley opened this issue Aug 30, 2022 · 3 comments
Labels
pynetbox status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jwbensley
Copy link

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
@robertlynch3
Copy link

I am seeing this as well.

@arthanson arthanson self-assigned this Oct 24, 2022
@abhi1693 abhi1693 added type: bug A confirmed report of unexpected behavior in the application status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Aug 28, 2023
@felixschndr
Copy link

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

@netixx
Copy link

netixx commented Sep 25, 2024

Same here,

I am using

from pynetbox.core.query import Request


def get_iface_trace(nb: pynetbox.api, iface_id: int):

    return Request(
        base="{}/dcim/interfaces/{}/trace/".format(
            nb.base_url,
            iface_id,
        ),
        token=nb.token,
        private_key=nb.private_key,
        http_session=nb.http_session,
    ).get()

as a workaround for now.

@jeremystretch jeremystretch added the pynetbox label Nov 1, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pynetbox status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

7 participants