2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Add IP detection on local segment from remote registration

If an ip address is missing, but linklocal is set, try to search the
local nics for a viable connection to use.
This commit is contained in:
Jarrod Johnson 2022-07-22 17:17:35 -04:00
parent 0ac2bce883
commit 830c9e171f

View File

@ -59,6 +59,24 @@ class NodeHandler(immhandler.NodeHandler):
@property
def ipaddr(self):
if not self._ipaddr:
lla = self.info.get('linklocal', '')
tmplla = None
if lla:
for idx in util.list_interface_indexes():
tmplla = '{0}%{1}'.format(lla, idx)
addr = socket.getaddrinfo(tmplla, 443, 0, socket.SOCK_STREAM)[0][4]
try:
tsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
tsock.settimeout(1)
tsock.connect(addr)
tsock.close()
break
except Exception:
continue
else:
return ''
return tmplla
return self._ipaddr if self._ipaddr else ''
@classmethod