bundles/systemd-networkd: better dhcp support
This commit is contained in:
parent
5e7c7671e0
commit
91fd33cfa0
3 changed files with 20 additions and 8 deletions
14
bundles/systemd-networkd/files/template-dhcp.network
Normal file
14
bundles/systemd-networkd/files/template-dhcp.network
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<%
|
||||||
|
from ipaddress import ip_network
|
||||||
|
%>\
|
||||||
|
[Match]
|
||||||
|
Name=${interface}
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
DHCP=yes
|
||||||
|
IPv6AcceptRA=yes
|
||||||
|
UseHostname=no
|
||||||
|
|
||||||
|
% if config.get('forwarding', False):
|
||||||
|
IPForward=yes
|
||||||
|
%endif
|
|
@ -4,7 +4,6 @@
|
||||||
[Match]
|
[Match]
|
||||||
Name=${interface}
|
Name=${interface}
|
||||||
|
|
||||||
|
|
||||||
% for addr in sorted(config.get('ips', set())):
|
% for addr in sorted(config.get('ips', set())):
|
||||||
[Address]
|
[Address]
|
||||||
<%
|
<%
|
||||||
|
@ -31,14 +30,8 @@ GatewayOnLink=yes
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
% if config.get('dhcp', False):
|
|
||||||
DHCP=yes
|
|
||||||
IPv6AcceptRA=yes
|
|
||||||
UseHostname=no
|
|
||||||
% else:
|
|
||||||
DHCP=no
|
DHCP=no
|
||||||
IPv6AcceptRA=no
|
IPv6AcceptRA=no
|
||||||
% endif
|
|
||||||
|
|
||||||
% if config.get('forwarding', False):
|
% if config.get('forwarding', False):
|
||||||
IPForward=yes
|
IPForward=yes
|
||||||
|
|
|
@ -15,8 +15,13 @@ directories = {
|
||||||
# Don't use .get() here. We might end up with a node without a network
|
# Don't use .get() here. We might end up with a node without a network
|
||||||
# config!
|
# config!
|
||||||
for interface, config in node.metadata['interfaces'].items():
|
for interface, config in node.metadata['interfaces'].items():
|
||||||
|
if config.get('dhcp', False):
|
||||||
|
template = 'template-dhcp.network'
|
||||||
|
else:
|
||||||
|
template = 'template.network'
|
||||||
|
|
||||||
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
||||||
'source': 'template.network',
|
'source': template,
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
'context': {
|
'context': {
|
||||||
'interface': interface,
|
'interface': interface,
|
||||||
|
|
Loading…
Reference in a new issue