From 2c517594bf6d7f57b1d0522b08195df586bd8407 Mon Sep 17 00:00:00 2001 From: Maciej Delmanowski Date: Mon, 13 Apr 2015 17:05:11 +0200 Subject: [PATCH] Fix support for subnets with only 1 host inside --- CHANGES.rst | 4 ++++ templates/etc/dhcp/macros.j2 | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index dfd639c..ff5f8dc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,10 @@ v0.1.1 - Make sure that files specified in ``dhcpd_includes`` list exist before the DHCP server is restarted. [drybjed] +- Correctly handle IPv4 subnets with only 1 host inside. Previously they were + parsed with errors, now ``debops.dhcpd`` will detect them hand handle + separately from normal networks. [drybjed] + v0.1.0 ------ diff --git a/templates/etc/dhcp/macros.j2 b/templates/etc/dhcp/macros.j2 index ae28e60..c7eb05f 100644 --- a/templates/etc/dhcp/macros.j2 +++ b/templates/etc/dhcp/macros.j2 @@ -71,7 +71,13 @@ group { {% if dhcpd_ipversion is defined and dhcpd_ipversion == '6' %} subnet6 {{ subnet.subnet | ipaddr('network') + '/' + subnet.subnet | ipaddr('prefix') | string }} { {% else %} -subnet {{ subnet.subnet | ipaddr('cidr') | ipaddr('network') }} netmask {{ subnet.netmask | default(subnet.subnet | ipaddr('netmask')) }} { +{% if (subnet.netmask is defined and (subnet.subnet + '/' + subnet.netmask) | ipaddr('cidr') | ipaddr('network')) %} +subnet {{ (subnet.subnet + '/' + subnet.netmask) | ipaddr('cidr') | ipaddr('network') }} netmask {{ subnet.netmask }} { +{% elif subnet.subnet | ipaddr('cidr') | ipaddr('network') %} +subnet {{ subnet.subnet | ipaddr('cidr') | ipaddr('network') }} netmask {{ subnet.subnet | ipaddr('netmask') }} { +{% else %} +subnet {{ subnet.subnet | ipaddr('cidr') | ipaddr('address') }} netmask 255.255.255.255 { +{% endif %} {% endif %} {% if subnet.routers is defined and subnet.routers %} {% if subnet.routers is string %}