2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-28 20:07:48 +00:00

Fix multinet support and prefix

This commit is contained in:
Jarrod Johnson 2020-03-24 10:31:19 -04:00
parent 96cbfa5568
commit a1bb603570
2 changed files with 25 additions and 9 deletions

View File

@ -371,6 +371,19 @@ node = {
'description': 'Whether or not the indicated network interface is to be used for booting. This is used by '
'the discovery process to decide where to place the mac address of a detected PXE nic.',
},
'net.ipv4_address': {
'description': 'When configuring static, use this address. If '
'unspecified, it will check if the node name resolves '
'to an IP address. Additionally, the subnet prefix '
'may be specified with a suffix, e.g. "/16". If not '
'specified, it will attempt to autodetect based on '
'current network configuration.'
},
'net.ipv4_method': {
'description': 'Whether to use static or dhcp when configuring this '
'interface for IPv4.',
'validvalues': ('dhcp', 'static', 'none')
},
'net.ipv4_gateway': {
'description': 'The IPv4 gateway to use if applicable. As is the '
'case for other net attributes, net.eth0.ipv4_gateway '

View File

@ -151,7 +151,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None):
}
if ifidx is not None:
dhcprequested = False
nets = idxtonets(ifidx)
nets = list(idxtonets(ifidx))
candgws = []
for net in nets:
net, prefix = net
@ -184,14 +184,17 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None):
node, 0, socket.AF_INET, socket.SOCK_DGRAM)[0][-1][0]
except Exception:
return cfgdata
if ip_on_same_subnet(net, ipbynodename, prefix):
cfgdata['ipv4_address'] = ipbynodename
cfgdata['ipv4_method'] = 'static'
cfgdata['prefix']
for gw in candgws:
if ip_on_same_subnet(gw, ipbynodename, prefix):
cfgdata['ipv4_gateway'] = gw
break
for net in nets:
net, prefix = net
if ip_on_same_subnet(net, ipbynodename, prefix):
cfgdata['ipv4_address'] = ipbynodename
cfgdata['ipv4_method'] = 'static'
cfgdata['prefix'] = prefix
break
for gw in candgws:
if ip_on_same_subnet(gw, ipbynodename, prefix):
cfgdata['ipv4_gateway'] = gw
break
return cfgdata
if ip is not None:
prefixlen = get_prefix_len_for_ip(ip)