diff --git a/confluent_server/confluent/config/attributes.py b/confluent_server/confluent/config/attributes.py index 89d58b7d..fb9a8558 100644 --- a/confluent_server/confluent/config/attributes.py +++ b/confluent_server/confluent/config/attributes.py @@ -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 ' diff --git a/confluent_server/confluent/netutil.py b/confluent_server/confluent/netutil.py index ba528669..4a44c3bb 100644 --- a/confluent_server/confluent/netutil.py +++ b/confluent_server/confluent/netutil.py @@ -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)