bundles/systemd-networkd: support bond and bridge interfaces

This commit is contained in:
Franzi 2020-11-12 19:38:10 +01:00
parent 633ccb97fd
commit f2a0f0b46a
Signed by: kunsi
GPG key ID: 12E3D2136B818350
7 changed files with 81 additions and 3 deletions

View file

@ -0,0 +1,6 @@
[NetDev]
Name=${bond}
Kind=bond
[Bond]
Mode=${mode}

View file

@ -0,0 +1,5 @@
[Match]
Name=${' '.join(sorted(match))}
[Network]
Bond=${bond}

View file

@ -0,0 +1,3 @@
[NetDev]
Name=${bridge}
Kind=bridge

View file

@ -0,0 +1,5 @@
[Match]
Name=${' '.join(sorted(match))}
[Network]
Bridge=${bridge}

View file

@ -25,11 +25,11 @@ directories = {
# config! # config!
for interface, config in node.metadata['interfaces'].items(): for interface, config in node.metadata['interfaces'].items():
if config.get('dhcp', False): if config.get('dhcp', False):
template = 'template-dhcp.network' template = 'template-iface-dhcp.network'
else: else:
template = 'template.network' template = 'template-iface-nodhcp.network'
files['/etc/systemd/network/10-{}.network'.format(interface)] = { files['/etc/systemd/network/50-iface-{}.network'.format(interface)] = {
'source': template, 'source': template,
'content_type': 'mako', 'content_type': 'mako',
'context': { 'context': {
@ -44,6 +44,65 @@ for interface, config in node.metadata['interfaces'].items():
}, },
} }
for bond, config in node.metadata.get('systemd-networkd', {}).get('bonds', {}).items():
files['/etc/systemd/network/20-bond-{}.netdev'.format(bond)] = {
'source': 'template-bond.netdev',
'content_type': 'mako',
'context': {
'bond': bond,
'mode': config.get('mode', '802.3ad'),
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
files['/etc/systemd/network/21-bond-{}.network'.format(bond)] = {
'source': 'template-bond.network',
'content_type': 'mako',
'context': {
'bond': bond,
'match': config['match'],
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
for brname, config in node.metadata.get('systemd-networkd', {}).get('bridges', {}).items():
files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = {
'source': 'template-bridge.netdev',
'content_type': 'mako',
'context': {
'bridge': brname,
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = {
'source': 'template-bridge.network',
'content_type': 'mako',
'context': {
'bridge': brname,
'match': config['match'],
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
svc_systemd = { svc_systemd = {
'systemd-networkd': {}, 'systemd-networkd': {},
} }