2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-02-17 02:58:51 +00:00

Add firmwaredhcp method

In a case where static is
desired for the OS, but
PXE or HTTP boot will
receive an IP address from
a DHCP server, offer firmwaredhcp.

This tells confluent to refrain from offering an IP during firmware, but still telling the OS to use static.
This commit is contained in:
Jarrod Johnson 2020-08-03 11:42:27 -04:00
parent c7b8d05930
commit 585988b22a
3 changed files with 12 additions and 6 deletions

View File

@ -413,8 +413,10 @@ node = {
},
'net.ipv4_method': {
'description': 'Whether to use static or dhcp when configuring this '
'interface for IPv4.',
'validvalues': ('dhcp', 'static', 'none')
'interface for IPv4. "firmwaredhcp" means to defer to '
'external DHCP server during firmware execution, but '
'use static for OS',
'validvalues': ('dhcp', 'static', 'firmwaredhcp', 'none')
},
'net.ipv4_gateway': {
'description': 'The IPv4 gateway to use if applicable. As is the '

View File

@ -482,7 +482,7 @@ def check_reply(node, info, packet, sock, cfg, reqview):
# Received a request over a nic with no ipv4 configured, ignore it
return
clipn = None
if niccfg['ipv4_address']:
if niccfg['ipv4_address'] and niccfg['ipv4_method'] != 'firmwaredhcp':
clipn = socket.inet_aton(niccfg['ipv4_address'])
repview[16:20] = clipn
gateway = niccfg['ipv4_gateway']

View File

@ -184,17 +184,21 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
needsvrip = True
dhcprequested = False
nets = list(myiptonets(serverip))
genericmethod = 'static'
if nets is not None:
candgws = []
candsrvs = []
for net in nets:
net, prefix, svrip = net
ipmethod = cfgbyname[candidate].get('ipv4_method', 'static')
candsrvs.append(svrip)
cfgdata['deploy_server'] = svrip
for candidate in cfgbyname:
if cfgbyname[candidate].get('ipv4_method', None) == 'dhcp':
if ipmethod == 'dhcp':
dhcprequested = True
continue
if ipmethod == 'firmwaredhcp':
genericmethod = ipmethod
candip = cfgbyname[candidate].get('ipv4_address', None)
if candip and '/' in candip:
candip, candprefix = candip.split('/')
@ -205,7 +209,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
try:
if ip_on_same_subnet(net, candip, prefix):
cfgdata['ipv4_address'] = candip
cfgdata['ipv4_method'] = 'static'
cfgdata['ipv4_method'] = ipmethod
cfgdata['ipv4_gateway'] = cfgbyname[candidate].get(
'ipv4_gateway', None)
cfgdata['prefix'] = prefix
@ -228,7 +232,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
if ip_on_same_subnet(net, ipbynodename, prefix):
cfgdata['matchesnodename'] = True
cfgdata['ipv4_address'] = ipbynodename
cfgdata['ipv4_method'] = 'static'
cfgdata['ipv4_method'] = genericmethod
cfgdata['prefix'] = prefix
break
for svr in candsrvs: