netbox-community / Device-Type-Library-Import

This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
https://github.com/netbox-community/devicetype-library
MIT License
265 stars 80 forks source link

Netbox 4.0 failures #134

Open kollross opened 4 months ago

kollross commented 4 months ago

Since upgrading to Netbox 4.0, I'm running into an error when running nb-dt-import.py. I've performed a git pull but with no updates. I also performed a "[root@netbox-dev] # pip install -r requirements.txt", which updates some packages but nothing resolving the issue.

Netbox 4.0 Python 3.10.12 pynetbox 7.3.3

.env file

NETBOX_URL=https://netbox.mydomain.com
NETBOX_TOKEN=11111112222222223333333444444444
REPO_URL=https://github.com/netbox-community/devicetype-library.git
REPO_BRANCH=master
IGNORE_SSL_ERRORS=False
#SLUGS=c9300-48u isr4431 isr4331

Here is the error:

Package devicetype-library is already installed, updating /opt/Device-Type-Library-Import/repo
Traceback (most recent call last):
  File "/opt/Device-Type-Library-Import/./nb-dt-import.py", line 54, in <module>
    main()
  File "/opt/Device-Type-Library-Import/./nb-dt-import.py", line 17, in main
    netbox = NetBox(settings)
  File "/opt/Device-Type-Library-Import/netbox_api.py", line 28, in __init__
    self.verify_compatibility()
  File "/opt/Device-Type-Library-Import/netbox_api.py", line 50, in verify_compatibility
    version_split = [int(x) for x in self.netbox.version.split('.')]
  File "/opt/Device-Type-Library-Import/venv/lib/python3.10/site-packages/pynetbox/core/api.py", line 109, in version
    ).get_version()
  File "/opt/Device-Type-Library-Import/venv/lib/python3.10/site-packages/pynetbox/core/query.py", line 187, in get_version
    raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 403 Forbidden: {'detail': 'Authentication credentials were not provided.'}

On the Netbox side I'm seeing this error in the logs

2024-05-08 09:12:29,896 django.request WARNING: Forbidden: /api/
2024-05-08 09:12:38,751 django.request WARNING: Forbidden: /api/
2024-05-08 09:12:54,906 django.request WARNING: Forbidden: /api/
2024-05-08 09:13:47,340 django.request WARNING: Forbidden: /api/
2024-05-08 09:19:24,318 django.request WARNING: Forbidden: /api/
mjrduarte commented 4 months ago

I can confirm this error.

Netbox 4.0.2 Python 3.12.3 pynetbox 7.0.1

StillLoading commented 4 months ago

The "issue" seems to be related to this change netbox-community/netbox/pull/16122

Setting the option back to "False" allows the script to connect again.

licebmi commented 4 months ago

Issue seems to be caused by this line: https://github.com/netbox-community/Device-Type-Library-Import/blob/dda8ed8c2f8cd1a0fc533cd78df3548eebab7769/netbox_api.py#L50

The pynetbox library doesn't pass a token when getting netbox version https://github.com/netbox-community/pynetbox/blob/1b397f04ad104970e3f7d76efe990e56da8a7727/pynetbox/core/api.py#L111

https://github.com/netbox-community/pynetbox/issues/612

TalkBackJohnny commented 3 months ago

Having the same error. Is there a fix? Thanks

sevsev9 commented 3 months ago

Having the same error. Is there a fix? Thanks

This fix has been working for me so far: https://github.com/netbox-community/Device-Type-Library-Import/issues/141#issuecomment-2181105455

imuab commented 2 months ago

Authenticaion failure for Netbox 4.x is fixed in pynetbox 7.3.4: https://github.com/netbox-community/pynetbox/pull/616 I can confirm that the fix is working. The requirements.txt should be updated.