diff --git a/bundles/dhcpd/items.py b/bundles/dhcpd/items.py index f3d7125..f6c09f4 100644 --- a/bundles/dhcpd/items.py +++ b/bundles/dhcpd/items.py @@ -2,7 +2,7 @@ files = { '/etc/dhcp/dhcpd.conf': { 'content_type': 'mako', 'context': { - 'dhcp_config': node.metadata.get('dhcpd'), + 'dhcp_config': node.metadata['dhcpd'], }, 'needs': { 'pkg_apt:isc-dhcp-server' @@ -14,7 +14,8 @@ files = { '/etc/default/isc-dhcp-server': { 'content_type': 'mako', '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': { 'pkg_apt:isc-dhcp-server' diff --git a/bundles/dhcpd/metadata.py b/bundles/dhcpd/metadata.py index 4c8e551..5712ead 100644 --- a/bundles/dhcpd/metadata.py +++ b/bundles/dhcpd/metadata.py @@ -28,7 +28,7 @@ def get_static_allocations(metadata): def get_listen_interfaces(metadata): listen_interfaces = [] for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items(): - listen_interfaces.append(subnet.get('interface')) + listen_interfaces.append(subnet['interface']) return { 'dhcpd': { @@ -41,7 +41,7 @@ def get_listen_interfaces(metadata): def iptables(metadata): iptables = set() 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 { 'iptables': {