diff --git a/bundles/network/metadata.py b/bundles/network/metadata.py index abf2a02..2012168 100644 --- a/bundles/network/metadata.py +++ b/bundles/network/metadata.py @@ -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):