bundles/systemd-networkd: remove unneeded bridge/bond stuff

This commit is contained in:
Franzi 2021-12-22 07:46:43 +01:00
parent 102af524be
commit d0b703a137
Signed by: kunsi
GPG key ID: 12E3D2136B818350
8 changed files with 8 additions and 172 deletions

View file

@ -1,13 +0,0 @@
[NetDev]
Name=${bond}
Kind=bond
[Bond]
Mode=${mode}
% if mode in {'balance-rr', '802.3ad', 'balance-tlp'}:
TransmitHashPolicy=layer3+4
% endif
MIIMonitorSec=0.1
% if mode == '802.3ad':
LACPTransmitRate=fast
% endif

View file

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

View file

@ -1,7 +0,0 @@
[Match]
Name=${bridge}
[Network]
% for vlan in sorted(vlans):
VLAN=${bridge}.${vlan}
% endfor

View file

@ -1,6 +0,0 @@
[NetDev]
Name=${bridge}
Kind=bridge
[Bridge]
STP=off

View file

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

View file

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

View file

@ -6,19 +6,11 @@ files = {
'/etc/network/interfaces': { '/etc/network/interfaces': {
'delete': True, 'delete': True,
}, },
} '/etc/resolv.conf': {
if node.metadata.get('systemd-networkd/enable-resolved', False):
symlinks['/etc/resolv.conf'] = {
'target': '/run/systemd/resolve/stub-resolv.conf',
}
svc_systemd['systemd-resolved'] = {}
else:
files['/etc/resolv.conf'] = {
'content_type': 'mako', 'content_type': 'mako',
},
} }
directories = { directories = {
'/etc/systemd/network': { '/etc/systemd/network': {
'purge': True, 'purge': True,
@ -34,9 +26,7 @@ directories = {
mac_host_prefix = '%04x' % (node.magic_number % 65534) mac_host_prefix = '%04x' % (node.magic_number % 65534)
generated_mac = f'52:54:00:{mac_host_prefix[0:2]}:{mac_host_prefix[2:4]}:{{}}' generated_mac = f'52:54:00:{mac_host_prefix[0:2]}:{mac_host_prefix[2:4]}:{{}}'
# Don't use .get() here. We might end up with a node without a network for interface, config in node.metadata.get('interfaces').items():
# config!
for interface, config in node.metadata['interfaces'].items():
if config.get('dhcp', False): if config.get('dhcp', False):
if 'vlans' in config: if 'vlans' in config:
raise BundleError(f'{node.name} interface {interface} cannot use vlans and dhcp!') raise BundleError(f'{node.name} interface {interface} cannot use vlans and dhcp!')
@ -62,22 +52,7 @@ for interface, config in node.metadata['interfaces'].items():
'svc_systemd:systemd-networkd:restart', 'svc_systemd:systemd-networkd:restart',
}, },
} }
elif interface.startswith('dummy'):
files[f'/etc/systemd/network/{interface}.netdev'] = {
'source': 'template-dummy.netdev',
'content_type': 'mako',
'context': {
'name': interface,
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
if not config.get('ignore', False):
files[f'/etc/systemd/network/{interface}.network'] = { files[f'/etc/systemd/network/{interface}.network'] = {
'source': template, 'source': template,
'content_type': 'mako', 'content_type': 'mako',
@ -93,89 +68,6 @@ for interface, config in node.metadata['interfaces'].items():
}, },
} }
for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
files[f'/etc/systemd/network/{bond}.netdev'] = {
'source': 'template-bond.netdev',
'content_type': 'mako',
'context': {
'bond': bond,
'mode': config.get('mode', '802.3ad'),
'prio': config.get('priority', '32768'),
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
files[f'/etc/systemd/network/{bond}.network'] = {
'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/bridges', {}).items():
filename = '{}-match-{}'.format(
brname,
'-'.join(sorted(config['match'])),
)
files[f'/etc/systemd/network/{brname}.netdev'] = {
'source': 'template-bridge.netdev',
'content_type': 'mako',
'context': {
'bridge': brname,
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
files[f'/etc/systemd/network/{filename}.network'] = {
'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',
},
}
if config.get('vlans', set()):
files[f'/etc/systemd/network/{brname}.network'] = {
'source': 'template-bridge-vlan.network',
'content_type': 'mako',
'context': {
'bridge': brname,
'vlans': config.get('vlans', set()),
},
'needed_by': {
'svc_systemd:systemd-networkd',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
}
svc_systemd = { svc_systemd = {
'systemd-networkd': {}, 'systemd-networkd': {},
} }

View file

@ -11,7 +11,6 @@ defaults = {
@metadata_reactor.provides( @metadata_reactor.provides(
'interfaces', 'interfaces',
'systemd-networkd/bridges',
) )
def add_vlan_infos_to_interface(metadata): def add_vlan_infos_to_interface(metadata):
interfaces = {} interfaces = {}
@ -26,21 +25,6 @@ def add_vlan_infos_to_interface(metadata):
interfaces.setdefault(interface, {}).setdefault('vlans', set()) interfaces.setdefault(interface, {}).setdefault('vlans', set())
interfaces[interface]['vlans'].add(vlan) 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 { return {
'interfaces': interfaces, 'interfaces': interfaces,
'systemd-networkd': {
'bridges': bridges,
},
} }