bundles/dhcpd: remove some .get()
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2020-11-15 12:01:32 +01:00
parent ad569f073e
commit d5bca495e0
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 5 additions and 4 deletions

View file

@ -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'

View file

@ -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': {