Skip to content

Commit

Permalink
Allow empty range parameter
Browse files Browse the repository at this point in the history
When a user would pass an empty range parameter, it would result into

pool
{
  range ;
}

dhcpd would fail to start after that. With this patch, the whole pool
block is omitted.

Closes GH-29
  • Loading branch information
ekohl committed Jan 27, 2015
1 parent ca6372b commit b1503c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions spec/defines/pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
}
end

describe 'with empty string range' do
let :params do {
:network => '10.0.0.0',
:mask => '255.255.255.0',
:range => '',
} end

it {
content = subject.resource('concat_fragment', 'dhcp.conf+70_mypool.dhcp').send(:parameters)[:content]
content.split("\n").reject { |c| c =~ /(^\s*#|^$)/ }.should == [
"subnet 10.0.0.0 netmask 255.255.255.0 {",
" option subnet-mask 255.255.255.0;",
"}",
]
}
end

describe 'full parameters' do
let :params do {
:network => '10.0.0.0',
Expand Down
2 changes: 1 addition & 1 deletion templates/dhcpd.pool.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# <%= @name %>
#################################
subnet <%= @network %> netmask <%= @mask %> {
<% if @range -%>
<% if @range and !@range.empty? -%>
pool
{
range <%= @range %>;
Expand Down

0 comments on commit b1503c7

Please sign in to comment.