Giter VIP home page Giter VIP logo

Comments (5)

lopes avatar lopes commented on June 19, 2024

It looks like a mismatch between pynetbox v3.4.6 and NetBox v2.5.8 --I built this script using NetBox v2.4.4 and current version of pynetbox is 4.0.6.

I can't reproduce this environment right now (NetBox v2.5.8), but just made a new commit updating all versions of dependencies. Please, try this new version and send me a reply (it worked for me pynetbox v4.0.6 and NetBox v2.4.4).

from netbox-scanner.

omarmarquez avatar omarmarquez commented on June 19, 2024

Ok,
downloaded new zip from master:

pip install --upgrade -r requirements.txt

root@b456e5f91474:~/netbox-scanner# pip freeze
asn1crypto==0.24.0
bcrypt==3.1.6
certifi==2019.3.9
cffi==1.12.2
chardet==3.0.4
cpe==1.2.1
cryptography==2.6.1
idna==2.8
netaddr==0.7.19
paramiko==2.4.2
pyasn1==0.4.5
pycparser==2.19
PyNaCl==1.3.0
pynetbox==4.0.6
python-nmap==0.6.1
requests==2.21.0
six==1.12.0
urllib3==1.24.1

i see pynetbox changing to 4.0.6 ...
Running the scanner, i get the same error:

root@b456e5f91474:~/netbox-scanner# python netbox-scanner-master/netbox-scanner/nbscanner
Traceback (most recent call last):
  File "netbox-scanner-master/netbox-scanner/nbscanner", line 75, in <module>
    nbs.sync(networks)
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 223, in sync
    self.sync_network(network)
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 157, in sync_network
    self.sync_host(host)       
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 131, in sync_host
    nbhost = self.netbox.ipam.ip_addresses.get(address=host[0])
  File "/usr/local/lib/python3.7/site-packages/pynetbox/core/endpoint.py", line 135, in get
    filter_lookup = self.filter(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/core/endpoint.py", line 220, in filter
    ret = [self._response_loader(i) for i in req.get()]
  File "/usr/local/lib/python3.7/site-packages/pynetbox/core/query.py", line 239, in get
    return req_all(self.url)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/core/query.py", line 217, in req_all
    req = make_request(url)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/core/query.py", line 214, in make_request
    raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request but more specific details were not returned in json. Check the NetBox Logs or investigate this exception's error attribute.

In the server side running in development mode with DEbug=True I see:

----------------------------------------
Exception happened during processing of request from ('10.0.4.6', 56748)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()
  File "/usr/local/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('10.0.4.6', 56752)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()
  File "/usr/local/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------


from netbox-scanner.

lopes avatar lopes commented on June 19, 2024
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request but more specific details were not returned in json. Check the NetBox Logs or investigate this exception's error attribute.

Connection reset errors could be related to network or web server issues. Using the same environment you're running the script, you could open Python shell and simulate that interaction:

>>> from pynetbox import api
>>> nb = api('netbox_addr', token='token_goes_here', ssl_verify=False)
>>> nb.ipam.ip_addresses.get(address='ip_addr')

Try with IP addresses that are registered and not registered in NetBox. You could even try with some invalid values, like address=None or address=84. How will NetBox behave?

from netbox-scanner.

lopes avatar lopes commented on June 19, 2024

Another clue:
https://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean

from netbox-scanner.

omarmarquez avatar omarmarquez commented on June 19, 2024

Thanks, this actually was helpful debugging.
The issue seems to have been caused by using the short name for the netbox server in the scanner config instead of the fqdn that Netbox has in the ALLOW_HOSTS setting.
With this and pynetbox==4.0.6 now the scanner is aadding new IPs to netbox!!!

from netbox-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.