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

Hosts with IPv6 primary address only fail discovery #295

Open
mathiaswegner opened this issue Feb 1, 2023 · 0 comments
Open

Hosts with IPv6 primary address only fail discovery #295

mathiaswegner opened this issue Feb 1, 2023 · 0 comments

Comments

@mathiaswegner
Copy link
Contributor

Environment

  • Python version: 3.10.9
  • Network Importer version: 3.1.0
  • Nautobot version: 1.5.6
  • pynautobot: 1.2.2

Steps to Reproduce

  1. select a device in Nautobot with an IPv6 primary address and no IPv4 address
  2. run network-importer apply --check-configs

Expected Behavior

I expected that the device would be discovered and the configuration saved.

Observed Behavior

The device was not discovered due to not being reachable.

2023-02-01 16:02:20,148 - network-importer - INFO - Updating configuration from devices .. 
2023-02-01 16:02:20,149 - nornir.core - WARNING - Task 'check_if_reachable' has not been run – 0 hosts selected
2023-02-01 16:02:20,149 - nornir.core - WARNING - Task 'warning_not_reachable' has not been run – 0 hosts selected
2023-02-01 16:02:20,149 - nornir.core - WARNING - Task 'dispatcher' has not been run – 0 hosts selected
2023-02-01 16:02:20,149 - network-importer - INFO - Import SOT Model
2023-02-01 16:02:24,076 - network-importer - INFO - Import Network Model
2023-02-01 16:02:25,311 - network-importer - ERROR - Unable to load the SOT Adapter : No valid configurations found in snapshot

The issue appears to be that when a socket is opened to tcp ping the device, it is opened as an ipv4 socket without first checking what ip version the primary ip is.

I was able to resolve it with this patch.

16d15
< import ipaddress
107,114d105
<     isipv6 = False
<     try:
<         ipaddr = ipaddress.ip_address(host)
<         if ipaddr.version == 6:
<             isipv6 = True
<     except ValueError:
<         pass
< 
117,120d107
<         if isipv6:
<             skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM, 0)
<         else:
<             skt = socket.socket()
124,128c111
<             if isipv6:
<                 hostargs = (host, port, 0, 0)
<             else:
<                 hostargs = (host, port)
<             status = skt.connect_ex(hostargs)
---
>             status = skt.connect_ex((host, port))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant