defaults = {
    'apt': {
        'packages': {
            'isc-dhcp-client': {
                'installed': False,
            },
            'resolvconf': {
                'installed': False,
            },
        },
    },
}


@metadata_reactor.provides(
    'interfaces',
    'systemd-networkd/bridges',
)
def add_vlan_infos_to_interface(metadata):
    interfaces = {}
    bridges = {}

    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,
        },
    }
