bundles/systemd-networkd: support vlans

This commit is contained in:
Franzi 2020-11-13 16:29:17 +01:00
parent 4213b60052
commit 75d86f3339
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 47 additions and 1 deletions

View file

@ -25,11 +25,31 @@ directories = {
# config!
for interface, config in node.metadata['interfaces'].items():
if config.get('dhcp', False):
assert not 'vlans' in config, f'interface {interface} cannot use vlans and dhcp!'
template = 'template-iface-dhcp.network'
else:
template = 'template-iface-nodhcp.network'
files['/etc/systemd/network/50-iface-{}.network'.format(interface)] = {
if '.' in interface:
files['/etc/systemd/network/60-iface-{}.netdev'.format(interface)] = {
'source': 'template-iface-vlan.netdev',
'content_type': 'mako',
'context': {
'interface': interface,
'vlan': interface.split('.')[1],
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
weight = 61
else:
weight = 50
files['/etc/systemd/network/{}-iface-{}.network'.format(weight, interface)] = {
'source': template,
'content_type': 'mako',
'context': {