bundlewrap/bundles/systemd-networkd/metadata.py

53 lines
1.3 KiB
Python
Raw Permalink Normal View History

defaults = {
'apt': {
'packages': {
'isc-dhcp-client': {
'installed': False,
},
'network-manager': {
'installed': False,
},
'resolvconf': {
'installed': False,
},
},
},
}
@metadata_reactor.provides(
'interfaces',
'systemd-networkd/bridges',
)
def add_vlan_infos_to_interface(metadata):
interfaces = {}
bridges = {}
2021-02-12 19:37:36 +00:00
for iface in metadata.get('interfaces', {}):
if '.' not in iface:
continue
interface,vlan = iface.split('.')
interfaces.setdefault(interface, {}).setdefault('vlans', set())
interfaces[interface]['vlans'].add(vlan)
for bridge, config in metadata.get('systemd-networkd/bridges', {}).items():
for iface in config.get('match', {}):
if '.' not in iface:
continue
interface,vlan = iface.split('.')
bridges.setdefault(interface, {}).setdefault('vlans', set())
bridges[interface]['vlans'].add(vlan)
interfaces.setdefault(iface, {'ignore': True})
return {
'interfaces': interfaces,
'systemd-networkd': {
'bridges': bridges,
},
}