This commit is contained in:
mwiegand 2021-06-17 02:06:17 +02:00
parent 84e5176e07
commit 3a390e314e

View file

@ -5,23 +5,28 @@ from ipaddress import ip_interface
'interfaces',
)
def interfaces(metadata):
interface = {
'ips': [],
}
if metadata.get('network/ipv4', None):
interface['ips'].append(metadata.get('network/ipv4'))
interface['gateway4'] = metadata.get('network/gateway4')
if metadata.get('network/ipv6', None):
interface['ips'].append(metadata.get('network/ipv6'))
interface['gateway6'] = metadata.get('network/gateway6')
return {
'interfaces': {
metadata.get('network/interface'): {
'ips': list(filter(None.__ne__, [
metadata.get('network/ipv4', None),
metadata.get('network/ipv6', None),
])),
'gateway4': metadata.get('network/gateway4', None),
'gateway6': metadata.get('network/gateway6', None),
},
metadata.get('network/interface'): interface,
}
}
@metadata_reactor.provides(
'interfaces/gateway4',
'interfaces/gateway6',
'network/gateway4',
'network/gateway6',
)
def guess_gateway(metadata):
if metadata.get('network/gateway4', None):