MJL85 / natlas

natlas - Network Discovery and Auto-Diagramming
GNU General Public License v2.0
514 stars 111 forks source link

failed to detect valid IP address #17

Open hslabbert opened 7 years ago

hslabbert commented 7 years ago

Getting this on a graph walk using current master (0.8.2; https://github.com/MJL85/mnet/commit/3ed921f1af5519e66e3bd840dbb8e99d5b97de9a).

Traceback (most recent call last):
  File "/usr/bin/mnet.py", line 5, in <module>
    pkg_resources.run_script('mnet==0.8.2', 'mnet.py')
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 528, in run_script
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 1401, in run_script
  File "/usr/lib/python2.6/site-packages/mnet-0.8.2-py2.6.egg/EGG-INFO/scripts/mnet.py", line 198, in <module>

  File "/usr/lib/python2.6/site-packages/mnet-0.8.2-py2.6.egg/EGG-INFO/scripts/mnet.py", line 67, in main

  File "/usr/lib/python2.6/site-packages/mnet-0.8.2-py2.6.egg/EGG-INFO/scripts/mnet.py", line 129, in graph

  File "build/bdist.linux-x86_64/egg/mnetsuite/graph.py", line 84, in crawl
  File "build/bdist.linux-x86_64/egg/mnetsuite/graph.py", line 246, in _crawl_node
  File "build/bdist.linux-x86_64/egg/mnetsuite/graph.py", line 246, in _crawl_node
  File "build/bdist.linux-x86_64/egg/mnetsuite/graph.py", line 223, in _crawl_node
  File "build/bdist.linux-x86_64/egg/mnetsuite/graph.py", line 258, in is_node_allowed
  File "/usr/lib/python2.6/site-packages/netaddr-0.7.19-py2.6.egg/netaddr/ip/__init__.py", line 306, in __init__
    'address from %r' % addr)
netaddr.core.AddrFormatError: failed to detect a valid IP address from '136.29.252.207.20.86'

I don't know which node would be reporting that, but I'm assuming some kit somewhere is reporting a bad IP in CDP adjacency. We have some IBM kit in there somewhere, and I would be shocked if they report anything worthwhile/valid, so possible that's the issue.

I'm assuming this would be a try/except to grab this in graph.py?

hslabbert commented 7 years ago

I threw a try/except around the relevant sections in graph.py and I can complete a run now. It's not necessarily the cleanest, but at least as a PoC it works. I opted to just pass the except statements, as the closing return 0 will be default not return the network/IP as valid if we get through to the end of is_node_allowed().

Forked this over to https://github.com/hslabbert/mnet/commit/fdcfcfd7af61c7858b4de05fe12d8f8c3c7a94d3. Let me know if you want a PR or if you'd prefer a cleaner way around this.