2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Support explicit prefix in xcc discovery

This commit is contained in:
Jarrod Johnson 2022-07-21 10:13:00 -04:00
parent ef2c7b5bbc
commit d385ad1a0a
2 changed files with 9 additions and 3 deletions

View File

@ -554,13 +554,13 @@ class NodeHandler(immhandler.NodeHandler):
cd['hardwaremanagement.manager']['value'] and
not cd['hardwaremanagement.manager']['value'].startswith(
'fe80::')):
newip = cd['hardwaremanagement.manager']['value']
newip = newip.split('/', 1)[0]
rawnewip = cd['hardwaremanagement.manager']['value']
newip = rawnewip.split('/', 1)[0]
newipinfo = getaddrinfo(newip, 0)[0]
newip = newipinfo[-1][0]
if ':' in newip:
raise exc.NotImplementedException('IPv6 remote config TODO')
netconfig = netutil.get_nic_config(self.configmanager, nodename, ip=newip)
netconfig = netutil.get_nic_config(self.configmanager, nodename, ip=rawnewip)
newmask = netutil.cidr_to_mask(netconfig['prefix'])
currinfo = wc.grab_json_response('/api/providers/logoninfo')
currip = currinfo.get('items', [{}])[0].get('ipv4_address', '')

View File

@ -606,9 +606,15 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
def get_prefix_len_for_ip(ip):
plen = None
if '/' in ip:
ip, plen = ip.split('/', 1)
myaddrs = get_my_addresses()
found = False
for inf in socket.getaddrinfo(ip, 0, 0, socket.SOCK_DGRAM):
if plen:
yield (inf[0], plen)
return
for myaddr in myaddrs:
if inf[0] != myaddr[0]:
continue