mirror of
				https://github.com/xcat2/confluent.git
				synced 2025-11-04 13:22:42 +00:00 
			
		
		
		
	Fix implicit nic in confignet
If the implicit IP is not in any of the attribute groups of net, then auto-vivify from the normal place.
This commit is contained in:
		@@ -332,6 +332,18 @@ def get_full_net_config(configmanager, node, serverip=None):
 | 
			
		||||
    if serverip:
 | 
			
		||||
        myaddrs = get_addresses_by_serverip(serverip)
 | 
			
		||||
    nm = NetManager(myaddrs, node, configmanager)
 | 
			
		||||
    nnc = get_nic_config(configmanager, node, serverip=serverip)
 | 
			
		||||
    defaultnic = {}
 | 
			
		||||
    if nnc.get('ipv4_address', None):
 | 
			
		||||
        defaultnic['ipv4_address'] = '{}/{}'.format(nnc['ipv4_address'], nnc['prefix'])
 | 
			
		||||
    if nnc.get('ipv4_gateway', None):
 | 
			
		||||
        defaultnic['ipv4_gateway'] = nnc['ipv4_gateway']
 | 
			
		||||
    if nnc.get('ipv4_method', None):
 | 
			
		||||
        defaultnic['ipv4_method'] = nnc['ipv4_method']
 | 
			
		||||
    if nnc.get('ipv6_address', None):
 | 
			
		||||
        defaultnic['ipv6_address'] = '{}/{}'.format(nnc['ipv6_address'], nnc['ipv6_prefix'])
 | 
			
		||||
    if nnc.get('ipv6_method', None):
 | 
			
		||||
        defaultnic['ipv6_method'] = nnc['ipv6_method']
 | 
			
		||||
    if None in attribs:
 | 
			
		||||
        nm.process_attribs(None, attribs[None])
 | 
			
		||||
        del attribs[None]
 | 
			
		||||
@@ -345,6 +357,29 @@ def get_full_net_config(configmanager, node, serverip=None):
 | 
			
		||||
    retattrs['extranets'] = nm.myattribs
 | 
			
		||||
    for attri in retattrs['extranets']:
 | 
			
		||||
        add_netmask(retattrs['extranets'][attri])
 | 
			
		||||
        if retattrs['extranets'][attri].get('ipv4_address', None) == defaultnic.get('ipv4_address', 'NOPE'):
 | 
			
		||||
            defaultnic = {}
 | 
			
		||||
        if retattrs['extranets'][attri].get('ipv6_address', None) == defaultnic.get('ipv6_address', 'NOPE'):
 | 
			
		||||
            defaultnic = {}
 | 
			
		||||
    if 'default' not in retattrs and defaultnic:
 | 
			
		||||
        retattrs['default'] = defaultnic
 | 
			
		||||
        add_netmask(retattrs['default'])
 | 
			
		||||
        ipv4addr = defaultnic.get('ipv4_address', None)
 | 
			
		||||
        if '/' in ipv4addr:
 | 
			
		||||
            ipv4bytes = socket.inet_pton(socket.AF_INET, ipv4addr.split('/')[0])
 | 
			
		||||
            for addr in nm.myaddrs:
 | 
			
		||||
                if addr[0] != socket.AF_INET:
 | 
			
		||||
                    continue
 | 
			
		||||
                if ipn_on_same_subnet(addr[0], addr[1], ipv4bytes, addr[2]):
 | 
			
		||||
                    defaultnic['current_nic'] = True
 | 
			
		||||
        ipv6addr = defaultnic.get('ipv6_address', None)
 | 
			
		||||
        if '/' in ipv6addr:
 | 
			
		||||
            ipv6bytes = socket.inet_pton(socket.AF_INET6, ipv6addr.split('/')[0])
 | 
			
		||||
            for addr in nm.myaddrs:
 | 
			
		||||
                if addr[0] != socket.AF_INET6:
 | 
			
		||||
                    continue
 | 
			
		||||
                if ipn_on_same_subnet(addr[0], addr[1], ipv6bytes, addr[2]):
 | 
			
		||||
                    defaultnic['current_nic'] = True
 | 
			
		||||
    return retattrs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user