mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +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:
parent
0ac2bce883
commit
830c9e171f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user