bundles/systemd-networkd: no need for a specific order in /etc/systemd/network/
This commit is contained in:
parent
d787f8b0a3
commit
b679f568eb
1 changed files with 10 additions and 10 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from bundlewrap.exceptions import BundleError
|
||||||
|
|
||||||
assert node.has_bundle('systemd')
|
assert node.has_bundle('systemd')
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
|
@ -27,13 +29,14 @@ 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):
|
||||||
assert not 'vlans' in config, f'interface {interface} cannot use vlans and dhcp!'
|
if 'vlans' in config:
|
||||||
|
raise BundleError(f'{node.name} interface {interface} cannot use vlans and dhcp!')
|
||||||
template = 'template-iface-dhcp.network'
|
template = 'template-iface-dhcp.network'
|
||||||
else:
|
else:
|
||||||
template = 'template-iface-nodhcp.network'
|
template = 'template-iface-nodhcp.network'
|
||||||
|
|
||||||
if '.' in interface:
|
if '.' in interface:
|
||||||
files['/etc/systemd/network/60-iface-{}.netdev'.format(interface)] = {
|
files[f'/etc/systemd/network/{interface}.netdev'] = {
|
||||||
'source': 'template-iface-vlan.netdev',
|
'source': 'template-iface-vlan.netdev',
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
@ -47,12 +50,9 @@ for interface, config in node.metadata['interfaces'].items():
|
||||||
'svc_systemd:systemd-networkd:restart',
|
'svc_systemd:systemd-networkd:restart',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
weight = 61
|
|
||||||
else:
|
|
||||||
weight = 50
|
|
||||||
|
|
||||||
if not config.get('ignore', False):
|
if not config.get('ignore', False):
|
||||||
files['/etc/systemd/network/{}-iface-{}.network'.format(weight, interface)] = {
|
files[f'/etc/systemd/network/{interface}.network'] = {
|
||||||
'source': template,
|
'source': template,
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
@ -68,7 +68,7 @@ for interface, config in node.metadata['interfaces'].items():
|
||||||
}
|
}
|
||||||
|
|
||||||
for bond, config in node.metadata.get('systemd-networkd/bonds', {}).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',
|
'source': 'template-bond.netdev',
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
@ -83,7 +83,7 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
|
||||||
'svc_systemd:systemd-networkd:restart',
|
'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',
|
'source': 'template-bond.network',
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
@ -99,7 +99,7 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items():
|
||||||
}
|
}
|
||||||
|
|
||||||
for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
||||||
files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = {
|
files[f'/etc/systemd/network/{brname}.netdev'] = {
|
||||||
'source': 'template-bridge.netdev',
|
'source': 'template-bridge.netdev',
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
@ -112,7 +112,7 @@ for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items():
|
||||||
'svc_systemd:systemd-networkd:restart',
|
'svc_systemd:systemd-networkd:restart',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = {
|
files[f'/etc/systemd/network/{brname}.network'] = {
|
||||||
'source': 'template-bridge.network',
|
'source': 'template-bridge.network',
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
|
|
Loading…
Reference in a new issue