bundles/systemd-networkd: fix bridge-in-bridge-setup on home.nas not working properly
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
2662fa5976
commit
61e5591628
3 changed files with 55 additions and 12 deletions
|
@ -0,0 +1,7 @@
|
|||
[Match]
|
||||
Name=${bridge}
|
||||
|
||||
[Network]
|
||||
% for vlan in sorted(vlans):
|
||||
VLAN=${bridge}.${vlan}
|
||||
% endfor
|
|
@ -47,7 +47,7 @@ for interface, config in node.metadata['interfaces'].items():
|
|||
if '.' in interface:
|
||||
vlan_id = int(interface.split('.')[1])
|
||||
vlan_hex = '%02x' % (vlan_id % 255)
|
||||
files['/etc/systemd/network/60-iface-{}.netdev'.format(interface)] = {
|
||||
files[f'/etc/systemd/network/{interface}.netdev'] = {
|
||||
'source': 'template-iface-vlan.netdev',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -62,9 +62,8 @@ for interface, config in node.metadata['interfaces'].items():
|
|||
'svc_systemd:systemd-networkd:restart',
|
||||
},
|
||||
}
|
||||
weight = 61
|
||||
elif interface.startswith('dummy'):
|
||||
files[f'/etc/systemd/network/60-iface-{interface}.netdev'] = {
|
||||
files[f'/etc/systemd/network/{interface}.netdev'] = {
|
||||
'source': 'template-dummy.netdev',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -77,12 +76,9 @@ for interface, config in node.metadata['interfaces'].items():
|
|||
'svc_systemd:systemd-networkd:restart',
|
||||
},
|
||||
}
|
||||
weight = 61
|
||||
else:
|
||||
weight = 50
|
||||
|
||||
if not config.get('ignore', False):
|
||||
files['/etc/systemd/network/{}-iface-{}.network'.format(weight, interface)] = {
|
||||
files[f'/etc/systemd/network/{interface}.network'] = {
|
||||
'source': template,
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -98,7 +94,7 @@ for interface, config in node.metadata['interfaces'].items():
|
|||
}
|
||||
|
||||
for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
|
||||
files['/etc/systemd/network/20-bond-{}.netdev'.format(bond)] = {
|
||||
files[f'/etc/systemd/network/{bond}.netdev'] = {
|
||||
'source': 'template-bond.netdev',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -113,7 +109,8 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
|
|||
'svc_systemd:systemd-networkd:restart',
|
||||
},
|
||||
}
|
||||
files['/etc/systemd/network/21-bond-{}.network'.format(bond)] = {
|
||||
|
||||
files[f'/etc/systemd/network/{bond}.network'] = {
|
||||
'source': 'template-bond.network',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -129,7 +126,12 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
|
|||
}
|
||||
|
||||
for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
||||
files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = {
|
||||
filename = '{}-match-{}'.format(
|
||||
brname,
|
||||
'-'.join(sorted(config['match'])),
|
||||
)
|
||||
|
||||
files[f'/etc/systemd/network/{brname}.netdev'] = {
|
||||
'source': 'template-bridge.netdev',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -142,7 +144,8 @@ for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
|||
'svc_systemd:systemd-networkd:restart',
|
||||
},
|
||||
}
|
||||
files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = {
|
||||
|
||||
files[f'/etc/systemd/network/{filename}.network'] = {
|
||||
'source': 'template-bridge.network',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
|
@ -157,6 +160,22 @@ for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
|||
},
|
||||
}
|
||||
|
||||
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 = {
|
||||
'systemd-networkd': {},
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@ defaults = {
|
|||
|
||||
@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:
|
||||
if '.' not in iface:
|
||||
continue
|
||||
|
||||
interface,vlan = iface.split('.')
|
||||
|
@ -24,6 +26,21 @@ def add_vlan_infos_to_interface(metadata):
|
|||
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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue