bundle/dhcpd: improvements #19

Merged
sophie merged 6 commits from kunsi-dhcpd-improvements into main 2020-11-15 12:34:41 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit d5bca495e0 - Show all commits

View file

@ -2,7 +2,7 @@ files = {
'/etc/dhcp/dhcpd.conf': { '/etc/dhcp/dhcpd.conf': {
'content_type': 'mako', 'content_type': 'mako',
'context': { 'context': {
'dhcp_config': node.metadata.get('dhcpd'), 'dhcp_config': node.metadata['dhcpd'],
}, },
'needs': { 'needs': {
'pkg_apt:isc-dhcp-server' 'pkg_apt:isc-dhcp-server'
@ -14,7 +14,8 @@ files = {
'/etc/default/isc-dhcp-server': { '/etc/default/isc-dhcp-server': {
'content_type': 'mako', 'content_type': 'mako',
'context': { 'context': {
'listen_interfaces': node.metadata.get('dhcpd', {}).get('listen_interfaces'), # Set by our own metadata reactor. Guaranteed to exist.
'listen_interfaces': node.metadata['dhcpd']['listen_interfaces'],
}, },
'needs': { 'needs': {
'pkg_apt:isc-dhcp-server' 'pkg_apt:isc-dhcp-server'

View file

@ -28,7 +28,7 @@ def get_static_allocations(metadata):
def get_listen_interfaces(metadata): def get_listen_interfaces(metadata):
listen_interfaces = [] listen_interfaces = []
for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items(): for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items():
listen_interfaces.append(subnet.get('interface')) listen_interfaces.append(subnet['interface'])
return { return {
'dhcpd': { 'dhcpd': {
@ -41,7 +41,7 @@ def get_listen_interfaces(metadata):
def iptables(metadata): def iptables(metadata):
iptables = set() iptables = set()
for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items(): for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items():
iptables.add('iptables -A INPUT -i {} -p udp --dport 67:68 -j ACCEPT'.format(subnet.get('interface'))) iptables.add('iptables -A INPUT -i {} -p udp --dport 67:68 -j ACCEPT'.format(subnet['interface']))
return { return {
'iptables': { 'iptables': {