Closed alfista-sk closed 3 months ago
Hi, I have reinstalled the pynetbox to the latest version and it started working but still have now some errors and problems:
(venv) servicepc@mld-s-netbox:/Downloads/Device-Type-Library-Import$ ./nb-dt-import.py
Package devicetype-library is already installed, updating /Downloads/Device-Type-Library-Import/repo
/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/urllib3/connectionpool.py:1103: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.51.243'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(
Traceback (most recent call last):
File "/Downloads/Device-Type-Library-Import/./nb-dt-import.py", line 54, in <module>
main()
File "/Downloads/Device-Type-Library-Import/./nb-dt-import.py", line 17, in main
netbox = NetBox(settings)
^^^^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/netbox_api.py", line 28, in __init__
self.verify_compatibility()
File "/Downloads/Device-Type-Library-Import/netbox_api.py", line 50, in verify_compatibility
version_split = [int(x) for x in self.netbox.version.split('.')]
^^^^^^^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/api.py", line 113, in version
).get_version()
^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/query.py", line 198, in get_version
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 403 Forbidden: {'detail': 'Authentication credentials were not provided.'}
and I so edited the .env file:
NETBOX_URL=https://192.168.51.243
NETBOX_TOKEN=b078a7e1a4592c15e70e1c9016e0324bbd61723a
REPO_URL=https://github.com/netbox-community/devicetype-library.git
REPO_BRANCH=master
IGNORE_SSL_ERRORS=True
#SLUGS=c9300-48u isr4431 isr4331
So I don't know what credentials are missing? This Token was generated under Admin.
Thanks.
I'm currently running into the same problem. After some research, it seems to be a problem with the pynetbox package that is used here.
I've found the issue for it there => https://github.com/netbox-community/pynetbox/issues/612
I'm currently running into the same problem. After some research, it seems to be a problem with the pynetbox package that is used here.
I've found the issue for it there => netbox-community/pynetbox#612
OK and how I need to update it, while it looks that still revert back to the 7.0.1 and will it help while now I have a fallback to the first error. I have chenged the in the Importer requirments.txt file the pynetbox from 7.0.1 to 7.3.3 but still hav ethe same error. To resolvimg the pkg_resources error is needed to install setuptools too which isnt preinstalled and also isnt in requirments. I dont know what I need more to do?
After changing the line in the query.py locally, it works just fine, since the required API-Version is also in the 403 header.
If you're facing this issue, you can use the following workaround:
(I assume you have already installed the requirements and are in the python3 venv where those are installed)
When you are in the folder where the venv/
directory is located:
Open the file:
nano venv/lib/python3.12/site-packages/pynetbox/core/query.py
Edit the line according to this comment: https://github.com/netbox-community/pynetbox/issues/612#issuecomment-2160433751
Hi,
i tried to find the pynetbox forlder but I doesnt have found it.
If I understand it corectly it shoudl be inside this folder:
/opt/netbox/venv/lib/python3.12/site-packages/
but I dont heve ther the pynetbox ...
And sorry i'm not very familiar with python, so I dont understand what I shoudl edit there and what I shoudl write there.
Thanks.
According to your error you should edit the one that is located at /Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/query.py
OK I have it and it works, only I needed something to understand the python and find the needed place. But after some time and importing something ended it with the same error: Started with:
(venv) servicepc@mld-s-netbox:/Downloads/Device-Type-Library-Import$ ./nb-dt-import.py
Traceback (most recent call last):
File "/Downloads/Device-Type-Library-Import/./nb-dt-import.py", line 5, in <module>
import pynetbox
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/__init__.py", line 3, in <module>
from pynetbox.core.query import RequestError, AllocationError, ContentError
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/query.py", line 199
if req.ok or req.status_code == 403:
^
IndentationError: expected an indented block after 'if' statement on line 197
(venv) servicepc@mld-s-netbox:/Downloads/Device-Type-Library-Import$ ./nb-dt-import.py
Package devicetype-library is already installed, updating /Downloads/Device-Type-Library-Import/repo
/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.51.243'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(
/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.51.243'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
and ended with:
/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.51.243'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(
Traceback (most recent call last):
File "/Downloads/Device-Type-Library-Import/./nb-dt-import.py", line 54, in <module>
main()
File "/Downloads/Device-Type-Library-Import/./nb-dt-import.py", line 25, in main
netbox.create_device_types(device_types)
File "/Downloads/Device-Type-Library-Import/netbox_api.py", line 119, in create_device_types
self.device_types.create_interfaces(device_type["interfaces"], dt.id)
File "/Downloads/Device-Type-Library-Import/netbox_api.py", line 223, in create_interfaces
existing_interfaces = {str(item): item for item in self.netbox.dcim.interface_templates.filter(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/response.py", line 127, in __next__
next(self.response), self.endpoint.api, self.endpoint
^^^^^^^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/query.py", line 293, in get
req = self._make_call(add_params=add_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Downloads/Device-Type-Library-Import/venv/lib/python3.12/site-packages/pynetbox/core/query.py", line 260, in _make_call
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 502 Bad Gateway but more specific details were not returned in json. Check the NetBox Logs or investigate this exception's error attribute.
Thanks.
So at second time has finished it correctly and imported all. Thanks.
Glad it worked for you!
Please remember to close the issue.
The issue was resolved with an work around:
nano venv/lib/python3.12/site-packages/pynetbox/core/query.py
Edit the line according to this comment: netbox-community/pynetbox/issues/612
Hi, I try to import the Device Library, but it will not work. I follow each step but when I try to run this command: ./nb-dt-import.py Then I get this error message: Traceback (most recent call last):
I'm running on Ubuntu 24.04 TLS Server and NetBox 4.0.3 with Python 3.12.3.
Please can you help me to resolve it?